libcaf  0.16.0
Public Types | Public Member Functions | Static Public Attributes | Related Functions | List of all members
caf::variant< Ts > Class Template Reference

A variant represents always a valid value of one of the types Ts.... More...

#include <variant.hpp>

Public Types

using types = detail::type_list< Ts... >
 
using type0 = typename detail::tl_at< types, 0 >::type
 

Public Member Functions

template<class U >
 variant (U &&arg) noexcept(std::is_rvalue_reference< U &&>::value &&nothrow_move_assign)
 
 variant (variant &&other) noexcept(nothrow_move_construct)
 
 variant (const variant &other)
 
variantoperator= (const variant &other)
 
variantoperator= (variant &&other) noexcept(nothrow_move_assign)
 
template<class U >
variantoperator= (U &&arg) noexcept(nothrow_move_assign)
 
constexpr size_t index () const
 
bool valueless_by_exception () const
 

Static Public Attributes

static constexpr int max_type_id = sizeof...(Ts) - 1
 Stores the ID for the last type.
 
static constexpr bool nothrow_move_construct
 Stores whether all types are nothrow constructible. More...
 
static constexpr bool nothrow_move_assign
 Stores whether all types are nothrow assignable and constructible. More...
 

Related Functions

(Note that these are not member functions.)

template<class... Ts>
bool operator== (const variant< Ts... > &x, const variant< Ts... > &y)
 
template<class... Ts>
bool operator!= (const variant< Ts... > &x, const variant< Ts... > &y)
 
template<class... Ts>
bool operator< (const variant< Ts... > &x, const variant< Ts... > &y)
 
template<class... Ts>
bool operator> (const variant< Ts... > &x, const variant< Ts... > &y)
 
template<class... Ts>
bool operator<= (const variant< Ts... > &x, const variant< Ts... > &y)
 
template<class... Ts>
bool operator>= (const variant< Ts... > &x, const variant< Ts... > &y)
 
template<class Inspector , class... Ts>
Inspector::result_type inspect (Inspector &f, variant_reader< variant< Ts... >> &x)
 
template<class Inspector , class... Ts>
std::enable_if< Inspector::reads_state, typename Inspector::result_type >::type inspect (Inspector &f, variant< Ts... > &x)
 
template<class Inspector , class... Ts>
Inspector::result_type inspect (Inspector &f, variant_writer< variant< Ts... >> &x)
 
template<class Inspector , class... Ts>
std::enable_if< Inspector::writes_state, typename Inspector::result_type >::type inspect (Inspector &f, variant< Ts... > &x)
 

Detailed Description

template<class... Ts>
class caf::variant< Ts >

A variant represents always a valid value of one of the types Ts....

Friends And Related Function Documentation

◆ inspect() [1/4]

template<class Inspector , class... Ts>
Inspector::result_type inspect ( Inspector &  f,
variant_reader< variant< Ts... >> &  x 
)
related

◆ inspect() [2/4]

template<class Inspector , class... Ts>
std::enable_if< Inspector::reads_state, typename Inspector::result_type >::type inspect ( Inspector &  f,
variant< Ts... > &  x 
)
related

◆ inspect() [3/4]

template<class Inspector , class... Ts>
Inspector::result_type inspect ( Inspector &  f,
variant_writer< variant< Ts... >> &  x 
)
related

◆ inspect() [4/4]

template<class Inspector , class... Ts>
std::enable_if< Inspector::writes_state, typename Inspector::result_type >::type inspect ( Inspector &  f,
variant< Ts... > &  x 
)
related

◆ operator!=()

template<class... Ts>
bool operator!= ( const variant< Ts... > &  x,
const variant< Ts... > &  y 
)
related

◆ operator<()

template<class... Ts>
bool operator< ( const variant< Ts... > &  x,
const variant< Ts... > &  y 
)
related

◆ operator<=()

template<class... Ts>
bool operator<= ( const variant< Ts... > &  x,
const variant< Ts... > &  y 
)
related

◆ operator==()

template<class... Ts>
bool operator== ( const variant< Ts... > &  x,
const variant< Ts... > &  y 
)
related

◆ operator>()

template<class... Ts>
bool operator> ( const variant< Ts... > &  x,
const variant< Ts... > &  y 
)
related

◆ operator>=()

template<class... Ts>
bool operator>= ( const variant< Ts... > &  x,
const variant< Ts... > &  y 
)
related

Member Data Documentation

◆ nothrow_move_assign

template<class... Ts>
constexpr bool caf::variant< Ts >::nothrow_move_assign
static
Initial value:
=
&& detail::conjunction<
std::is_nothrow_move_assignable<Ts>::value...
>::value

Stores whether all types are nothrow assignable and constructible.

We need to check both, since assigning to a variant results in a move-contruct unless the before and after types are the same.

◆ nothrow_move_construct

template<class... Ts>
constexpr bool caf::variant< Ts >::nothrow_move_construct
static
Initial value:
=
detail::conjunction<
std::is_nothrow_move_constructible<Ts>::value...
>::value

Stores whether all types are nothrow constructible.


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