microfmt
Zero-allocation C++ formatting for constrained environments
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
microfmt::variant_view< Ts > Class Template Reference

Non-owning view over a std::variant with optional decorations. More...

#include <variant.hpp>

Public Types

using variant_type = std::variant< Ts... >
 The wrapped std::variant type.
 

Public Member Functions

constexpr variant_view (const variant_type &var RELOCO_LIFETIMEBOUND, microfmt::string_view prefix="", microfmt::string_view suffix="", bool show_index=false) noexcept
 Constructs the view.
 
constexpr variant_view (variant_type &&, microfmt::string_view="", microfmt::string_view="", bool=false)=delete
 
constexpr variant_view (const variant_type &&, microfmt::string_view="", microfmt::string_view="", bool=false)=delete
 
constexpr const variant_type & get () const noexcept
 Returns the referenced variant.
 
constexpr microfmt::string_view prefix () const noexcept
 Returns the prefix decoration.
 
constexpr microfmt::string_view suffix () const noexcept
 Returns the suffix decoration.
 
constexpr bool show_index () const noexcept
 Reports whether the alternative index is displayed.
 

Detailed Description

template<typename... Ts>
class microfmt::variant_view< Ts >

Non-owning view over a std::variant with optional decorations.

Template Parameters
TsThe alternative types of the wrapped variant.

Member Typedef Documentation

◆ variant_type

template<typename... Ts>
using microfmt::variant_view< Ts >::variant_type = std::variant<Ts...>

The wrapped std::variant type.

Constructor & Destructor Documentation

◆ variant_view() [1/3]

template<typename... Ts>
constexpr microfmt::variant_view< Ts >::variant_view ( const variant_type &var  RELOCO_LIFETIMEBOUND,
microfmt::string_view  prefix = "",
microfmt::string_view  suffix = "",
bool  show_index = false 
)
inlineexplicitconstexprnoexcept

Constructs the view.

Parameters
varReferenced variant.
prefixText emitted before the active alternative.
suffixText emitted after the active alternative.
show_indexWhen true, include the alternative index.

◆ variant_view() [2/3]

template<typename... Ts>
constexpr microfmt::variant_view< Ts >::variant_view ( variant_type &&  ,
microfmt::string_view  = "",
microfmt::string_view  = "",
bool  = false 
)
explicitconstexprdelete

◆ variant_view() [3/3]

template<typename... Ts>
constexpr microfmt::variant_view< Ts >::variant_view ( const variant_type &&  ,
microfmt::string_view  = "",
microfmt::string_view  = "",
bool  = false 
)
explicitconstexprdelete

Member Function Documentation

◆ get()

template<typename... Ts>
constexpr const variant_type & microfmt::variant_view< Ts >::get ( ) const
inlineconstexprnoexcept

Returns the referenced variant.

Returns
The wrapped std::variant.

◆ prefix()

template<typename... Ts>
constexpr microfmt::string_view microfmt::variant_view< Ts >::prefix ( ) const
inlineconstexprnoexcept

Returns the prefix decoration.

Returns
Text emitted before the active alternative.

◆ show_index()

template<typename... Ts>
constexpr bool microfmt::variant_view< Ts >::show_index ( ) const
inlineconstexprnoexcept

Reports whether the alternative index is displayed.

Returns
true when the index is included in output.

◆ suffix()

template<typename... Ts>
constexpr microfmt::string_view microfmt::variant_view< Ts >::suffix ( ) const
inlineconstexprnoexcept

Returns the suffix decoration.

Returns
Text emitted after the active alternative.

The documentation for this class was generated from the following file: