|
template<typename T = nth_type<0>, std::enable_if_t< std::is_default_constructible< T >::value, int > = 0> |
constexpr | variant () noexcept(std::is_nothrow_default_constructible< nth_type< 0 > >::value) |
|
constexpr | variant (const variant &other)=default |
|
constexpr | variant (variant &&other) noexcept(tys::nothrow_move_constructible)=default |
|
template<typename U, std::size_t Ix = detail::var::best_converting_ctor_index_v<U, Ts...>, std::enable_if_t<(Ix< std::numeric_limits< std::size_t >::max()), int > = 0, typename Alt = nth_type<Ix>, std::enable_if_t< std::is_constructible< Alt, U >::value, int > = 0, std::enable_if_t<!std::is_same< std::decay_t< U >, variant >::value, int > = 0, std::enable_if_t<!detail::is_in_place_type< std::decay_t< U > >::value, int > = 0, std::enable_if_t<!detail::is_in_place_index< std::decay_t< U > >::value, int > = 0> |
constexpr | variant (U &&from) noexcept(std::is_nothrow_constructible< nth_type< Ix >, U >::value) |
|
template<typename T, std::size_t Ix = index_of<T>, typename... Args, std::enable_if_t< is_unique< T > &&std::is_constructible< T, Args... >::value, int > = 0> |
constexpr | variant (const in_place_type_t< T >, Args &&... args) |
|
template<typename T, std::size_t Ix = index_of<T>, typename U, typename... Args, std::enable_if_t< is_unique< T > &&std::is_constructible< T, std::initializer_list< U > &, Args... >::value, int > = 0> |
constexpr | variant (const in_place_type_t< T >, const std::initializer_list< U > il, Args &&... args) |
|
template<std::size_t Ix, typename... Args, std::enable_if_t<(Ix< sizeof...(Ts)) &&std::is_constructible< nth_type< Ix >, Args... >::value, int > = 0> |
constexpr | variant (const in_place_index_t< Ix >, Args &&... args) |
|
template<std::size_t Ix, typename U, typename... Args, std::enable_if_t<(Ix< sizeof...(Ts)) &&std::is_constructible< nth_type< Ix >, std::initializer_list< U > &, Args... >::value, int > = 0> |
constexpr | variant (const in_place_index_t< Ix >, const std::initializer_list< U > il, Args &&... args) |
|
constexpr variant & | operator= (const variant &rhs)=default |
|
constexpr variant & | operator= (variant &&rhs) noexcept(tys::nothrow_move_constructible &&tys::nothrow_move_assignable)=default |
|
template<typename U, std::size_t Ix = detail::var::best_converting_assignment_index_v<U, Ts...>, std::enable_if_t<(Ix< std::numeric_limits< std::size_t >::max()), int > = 0, typename Alt = nth_type<Ix>, std::enable_if_t< std::is_constructible< Alt, U >::value &&std::is_assignable< Alt &, U >::value, int > = 0, std::enable_if_t<!std::is_same< std::decay_t< U >, variant >::value, int > = 0, std::enable_if_t<!detail::is_in_place_type< std::decay_t< U > >::value, int > = 0, std::enable_if_t<!detail::is_in_place_index< std::decay_t< U > >::value, int > = 0> |
variant & | operator= (U &&from) noexcept(std::is_nothrow_constructible< Alt, U >::value &&std::is_nothrow_assignable< Alt &, U >::value) |
|
constexpr void | swap (variant &other) noexcept(tys::nothrow_move_constructible &&tys::nothrow_swappable) |
|
CETL_NODISCARD constexpr std::size_t | index () const noexcept |
|
CETL_NODISCARD constexpr bool | valueless_by_exception () const noexcept |
|
|
template<typename T, typename... Args, std::size_t Ix = index_of<T>, std::enable_if_t< std::is_constructible< T, Args... >::value, int > = 0> |
T & | emplace (Args &&... ar) |
|
template<typename T, typename U, typename... Args, std::size_t Ix = index_of<T>, std::enable_if_t< std::is_constructible< T, Args... >::value, int > = 0> |
T & | emplace (const std::initializer_list< U > il, Args &&... ar) |
|
template<std::size_t Ix, typename... Args, std::enable_if_t<(Ix< sizeof...(Ts)), int > = 0, typename T = variant_alternative_t<Ix, variant>, std::enable_if_t< std::is_constructible< T, Args... >::value, int > = 0> |
T & | emplace (Args &&... ar) |
|
template<std::size_t Ix, typename U, typename... Args, std::enable_if_t<(Ix< sizeof...(Ts)), int > = 0, typename T = variant_alternative_t<Ix, variant>, std::enable_if_t< std::is_constructible< T, Args... >::value, int > = 0> |
T & | emplace (const std::initializer_list< U > il, Args &&... ar) |
|
|
template<std::size_t Ix, typename... Us> |
constexpr std::add_pointer_t< variant_alternative_t< Ix, variant< Us... > > > | get_if (variant< Us... > *const var) noexcept |
|
template<std::size_t Ix, typename... Us> |
constexpr std::add_pointer_t< const variant_alternative_t< Ix, variant< Us... > > > | get_if (const variant< Us... > *const var) noexcept |
|
template<std::size_t Ix, typename... Us> |
constexpr variant_alternative_t< Ix, variant< Us... > > & | get (variant< Us... > &var) |
|
template<std::size_t Ix, typename... Us> |
constexpr variant_alternative_t< Ix, variant< Us... > > && | get (variant< Us... > &&var) |
|
template<std::size_t Ix, typename... Us> |
constexpr const variant_alternative_t< Ix, variant< Us... > > & | get (const variant< Us... > &var) |
|
template<std::size_t Ix, typename... Us> |
constexpr const variant_alternative_t< Ix, variant< Us... > > && | get (const variant< Us... > &&var) |
|
template<typename Fun, typename V> |
constexpr decltype(auto) | detail::var::visit (Fun &&fun, V &&var) |
|
template<typename... Ts>
class cetl::variant< Ts >
An implementation of std::variant.
The valueless state cannot occur unless exceptions are enabled.
In this implementation, the address of the variant object is equivalent to the address of the active alternative; this can sometimes be useful for low-level debugging.
- Template Parameters
-
Ts | The list of alternatives. At least one alternative is required. |