|
| constexpr | variant (detail::enable_overload_if_t< is_default_constructible, variant_ctor >={}) noexcept(std::is_nothrow_default_constructible< first_type >::value) |
| | Default constructor. More...
|
| |
| | variant (detail::enable_overload_if_t< is_copy_constructible, const variant & > other) noexcept(bpstd::conjunction< bpstd::is_nothrow_copy_constructible< Types >... >::value) |
| | Copy constructor. More...
|
| |
|
| variant (detail::disable_overload_if_t< is_copy_constructible, const variant & > other)=delete |
| |
| | variant (detail::enable_overload_if_t< is_move_constructible, variant && > other) noexcept(bpstd::conjunction< bpstd::is_nothrow_move_constructible< Types >... >::value) |
| | Move constructor. More...
|
| |
|
| variant (detail::disable_overload_if_t< is_move_constructible, variant && > other)=delete |
| |
| template<typename T , typename = enable_if_convertible<T>> |
| constexpr | variant (T &&t) noexcept(bpstd::is_nothrow_constructible< typename bpstd::variant< Types... >::template T_j< T >, T >::value) |
| | Converting constructor. More...
|
| |
| template<typename T , typename... Args, typename = enable_if_t<bpstd::is_constructible<T,Args...>::value>> |
| constexpr | variant (in_place_type_t< T >, Args &&... args) |
| | Constructs a variant with the specified alternative T and initializes the contained value with the arguments std::forward<Args>(args).... More...
|
| |
| template<typename T , typename U , typename... Args, typename = enable_if_t<bpstd::is_constructible<T,std::initializer_list<U>,Args...>::value>> |
| constexpr | variant (in_place_type_t< T >, std::initializer_list< U > il, Args &&... args) |
| | Constructs a variant with the specified alternative T and initializes the contained value with the arguments il, std::forward<Args>(args)..... More...
|
| |
| template<std::size_t I, typename... Args, typename = enable_if_t<i_is_in_range<I>::value && std::is_constructible<variant_alternative_t<I,variant>,Args...>::value>> |
| constexpr | variant (in_place_index_t< I >, Args &&... args) |
| | Constructs a variant with the alternative T_i specified by the index I and initializes the contained value with the arguments std::forward<Args>(args).... More...
|
| |
| template<std::size_t I, typename U , typename... Args, typename = enable_if_t<i_is_in_range<I>::value && std::is_constructible<variant_alternative_t<I,variant>,std::initializer_list<U>,Args...>::value>> |
| constexpr | variant (in_place_index_t< I >, std::initializer_list< U > il, Args &&... args) |
| | Constructs a variant with the alternative T_i specified by the index I and initializes the contained value with the arguments il, std::forward<Args>(args).... More...
|
| |
| variant & | operator= (detail::enable_overload_if_t< is_copy_assignable, const variant & > other) |
| | Copy assigns the contents of other to this. More...
|
| |
|
variant & | operator= (detail::disable_overload_if_t< is_copy_assignable, const variant & > other)=delete |
| |
| variant & | operator= (detail::enable_overload_if_t< is_move_assignable, variant && > other) noexcept(conjunction< std::is_nothrow_move_constructible< Types >..., std::is_nothrow_move_assignable< Types >... >::value) |
| | Move assigns the contents of other to this. More...
|
| |
|
variant & | operator= (detail::disable_overload_if_t< is_move_assignable, variant && > other)=delete |
| |
|
template<typename T , typename = enable_if_convert_assignable<T>> |
| variant & | operator= (T &&t) noexcept(std::is_nothrow_assignable< typename bpstd::variant< Types... >::template T_j< T >, T >::value &&std::is_nothrow_constructible< typename bpstd::variant< Types... >::template T_j< T >, T >::value) |
| |
| constexpr std::size_t | index () const noexcept |
| | Returns the zero-based index of the alternative that is currently held by the variant. More...
|
| |
| constexpr bool | valueless_by_exception () const noexcept |
| | Returns false if and only if the variant holds a value. More...
|
| |
| template<typename T , typename... Args, typename = enable_if_t<std::is_constructible<T,Args...>::value>> |
| T & | emplace (Args &&... args) |
| | Creates a new value in-place. More...
|
| |
| template<typename T , typename U , typename... Args, typename = enable_if_t<std::is_constructible<T,std::initializer_list<U>&,Args...>::value>> |
| T & | emplace (std::initializer_list< U > il, Args &&... args) |
| | Creates a new value in-place. More...
|
| |
| template<std::size_t I, typename... Args, typename = enable_if_t<std::is_constructible<detail::nth_type_t<I,Types...>,Args...>::value>> |
| variant_alternative_t< I, variant > & | emplace (Args &&... args) |
| | Creates a new value in-place. More...
|
| |
| template<std::size_t I, typename U , typename... Args, typename = enable_if_t<std::is_constructible<detail::nth_type_t<I,Types...>,std::initializer_list<U>&,Args...>::value>> |
| variant_alternative_t< I, variant > & | emplace (std::initializer_list< U > il, Args &&... args) |
| | Creates a new value in-place. More...
|
| |
| void | swap (variant &rhs) noexcept(bpstd::conjunction< bpstd::is_nothrow_move_constructible< Types >..., bpstd::is_nothrow_swappable< Types >... >::value) |
| | Swaps the contents of this and rhs. More...
|
| |
|
template<typename T , typename > |
| constexpr BPSTD_INLINE_VISIBILITY | variant (T &&t) noexcept(bpstd::is_nothrow_constructible< typename bpstd::variant< Types... >::template T_j< T >, T >::value) |
| |
|
template<typename T , typename... Args, typename > |
| constexpr BPSTD_INLINE_VISIBILITY | variant (in_place_type_t< T >, Args &&... args) |
| |
|
template<typename T , typename U , typename... Args, typename > |
| constexpr BPSTD_INLINE_VISIBILITY | variant (in_place_type_t< T >, std::initializer_list< U > il, Args &&... args) |
| |
|
template<std::size_t I, typename... Args, typename > |
| constexpr BPSTD_INLINE_VISIBILITY | variant (in_place_index_t< I >, Args &&... args) |
| |
|
template<std::size_t I, typename U , typename... Args, typename > |
| constexpr BPSTD_INLINE_VISIBILITY | variant (in_place_index_t< I >, std::initializer_list< U > il, Args &&... args) |
| |
|
template<typename T , typename > |
| BPSTD_INLINE_VISIBILITY bpstd::variant< Types... > & | operator= (T &&t) noexcept(std::is_nothrow_assignable< typename bpstd::variant< Types... >::template T_j< T >, T >::value &&std::is_nothrow_constructible< typename bpstd::variant< Types... >::template T_j< T >, T >::value) |
| |
|
template<typename T , typename... Args, typename > |
| BPSTD_INLINE_VISIBILITY T & | emplace (Args &&...args) |
| |
|
template<typename T , typename U , typename... Args, typename > |
| BPSTD_INLINE_VISIBILITY T & | emplace (std::initializer_list< U > il, Args &&...args) |
| |
|
template<std::size_t I, typename... Args, typename > |
| BPSTD_INLINE_VISIBILITY bpstd::variant_alternative_t< I, bpstd::variant< Types... > > & | emplace (Args &&...args) |
| |
|
template<std::size_t I, typename U , typename... Args, typename > |
| BPSTD_INLINE_VISIBILITY bpstd::variant_alternative_t< I, bpstd::variant< Types... > > & | emplace (std::initializer_list< U > il, Args &&... args) |
| |
|
|
template<typename... UTypes> |
| BPSTD_CPP14_CONSTEXPR bool | operator== (const variant< UTypes... > &, const variant< UTypes... > &) noexcept |
| |
|
template<typename... UTypes> |
| BPSTD_CPP14_CONSTEXPR bool | operator!= (const variant< UTypes... > &, const variant< UTypes... > &) noexcept |
| |
|
template<typename... UTypes> |
| BPSTD_CPP14_CONSTEXPR bool | operator< (const variant< UTypes... > &, const variant< UTypes... > &) noexcept |
| |
|
template<typename... UTypes> |
| BPSTD_CPP14_CONSTEXPR bool | operator> (const variant< UTypes... > &, const variant< UTypes... > &) noexcept |
| |
|
template<typename... UTypes> |
| BPSTD_CPP14_CONSTEXPR bool | operator<= (const variant< UTypes... > &, const variant< UTypes... > &) noexcept |
| |
|
template<typename... UTypes> |
| BPSTD_CPP14_CONSTEXPR bool | operator>= (const variant< UTypes... > &, const variant< UTypes... > &) noexcept |
| |
| template<typename Visitor , typename Variant > |
| BPSTD_CPP14_CONSTEXPR friend detail::variant_visitor_invoke_result_t< Visitor, Variant > | visit (Visitor &&, Variant &&) |
| | Visits the variant v with the given visitor. More...
|
| |
|
template<std::size_t I, typename... UTypes> |
| BPSTD_CPP14_CONSTEXPR variant_alternative_t< I, variant< UTypes... > > & | get (variant< UTypes... > &) |
| |
|
template<std::size_t I, typename... UTypes> |
| BPSTD_CPP14_CONSTEXPR variant_alternative_t< I, variant< UTypes... > > && | get (variant< UTypes... > &&) |
| |
|
template<std::size_t I, typename... UTypes> |
| const BPSTD_CPP14_CONSTEXPR variant_alternative_t< I, variant< UTypes... > > & | get (const variant< UTypes... > &) |
| |
|
template<std::size_t I, typename... UTypes> |
| const BPSTD_CPP14_CONSTEXPR variant_alternative_t< I, variant< UTypes... > > && | get (const variant< UTypes... > &&) |
| |
|
template<std::size_t I, typename... UTypes> |
| constexpr friend add_pointer_t< variant_alternative_t< I, variant< UTypes... > > > | get_if (variant< UTypes... > *) noexcept |
| |
|
template<std::size_t I, typename... UTypes> |
| constexpr friend add_pointer_t< const variant_alternative_t< I, variant< UTypes... > > > | get_if (const variant< UTypes... > *) noexcept |
| |
template<typename... Types>
class bpstd::variant< Types >
The class template variant represents a type-safe union.
An instance of variant at any given time either holds a value of one of its alternative types, or it holds no value (this state is hard to achieve,
- See also
- valueless_by_exception ).
As with unions, if a variant holds a value of some object type T, the object representation of T is allocated directly within the object representation of the variant itself. Variant is not allowed to allocate additional (dynamic) memory.
A variant is not permitted to hold references, arrays, or the type void. Empty variants are also ill-formed (variant<monostate> can be used instead).
A variant is permitted to hold the same type more than once, and to hold differently cv-qualified versions of the same type.
As with unions, the default-initialized variant holds a value of its first alternative, unless that alternative is not default-constructible (in which case default constructor won't compile: the helper class monostate can be used to make such variants default-constructible)
- Template Parameters
-
| Types | the types that may be stored in this variant. All types must be (possibly cv-qualified) non-array object types |
Definition at line 76 of file variant.hpp.