#
In the descriptions that follow, let i be in the range [0, sizeof.(Types)), and
constexpr variant() noexcept(see below);
Throws: Any exception thrown by the value-initialization of
Remarks: This function is constexpr if and only if the value-initialization of the alternative type
The exception specification is equivalent to is_nothrow_default_constructible_v<
[Note 1: 
See also class monostate.
— end note]
constexpr variant(const variant& w) noexcept(see below);
Effects: If w holds a value, initializes the variant to hold the same alternative as w and direct-initializes the contained value with GET<j>(w), where j is w.index().
Otherwise, initializes the variant to not hold a value.
Remarks: This constructor is defined as deleted unless is_copy_constructible_v<
If is_trivially_copy_constructible_v<
The exception specification is equivalent to the logical and of is_nothrow_copy_constructible_v<
constexpr variant(variant&& w) noexcept(see below);
Effects: If w holds a value, initializes the variant to hold the same alternative as w and direct-initializes the contained value with GET<j>(std​::​move(w)), where j is w.index().
Otherwise, initializes the variant to not hold a value.
Remarks: The exception specification is equivalent to the logical and of is_nothrow_move_constructible_v<
If is_trivially_move_constructible_v<
template<class T> constexpr variant(T&& t) noexcept(see below);
Let
The overload FUN(
Constraints:
  • sizeof.(Types) is nonzero,
  • is_same_v<remove_cvref_t<T>, variant> is false,
  • remove_cvref_t<T> is neither a specialization of in_place_type_t nor a specialization of in_place_index_t,
  • is_constructible_v<
  • the expression FUN(std​::​forward<T>(t)) (with FUN being the above-mentioned set of imaginary functions) is well-formed.
    [Note 2: 
    variant<string, string> v("abc"); is ill-formed, as both alternative types have an equally viable constructor for the argument.
    — end note]
Effects: Initializes *this to hold the alternative type
Remarks: The exception specification is equivalent to is_nothrow_constructible_v<
If
template<class T, class. Args> constexpr explicit variant(in_place_type_t<T>, Args&&. args);
Effects: Direct-non-list-initializes the contained value of type T with std​::​forward<Args>(args)..
Remarks: If T's selected constructor is a constexpr constructor, this constructor is a constexpr constructor.
template<class T, class U, class. Args> constexpr explicit variant(in_place_type_t<T>, initializer_list<U> il, Args&&. args);
Effects: Direct-non-list-initializes the contained value of type T with il, std​::​forward<Args>(​args)..
Remarks: If T's selected constructor is a constexpr constructor, this constructor is a constexpr constructor.
template<size_t I, class. Args> constexpr explicit variant(in_place_index_t<I>, Args&&. args);
Effects: Direct-non-list-initializes the contained value of type
Remarks: If
template<size_t I, class U, class. Args> constexpr explicit variant(in_place_index_t<I>, initializer_list<U> il, Args&&. args);
Effects: Direct-non-list-initializes the contained value of type
Remarks: If

Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant