22 General utilities library [utilities]

22.6 Variants [variant]

22.6.3 Class template variant [variant.variant]

22.6.3.5 Modifiers [variant.mod]

template<class T, class. Args> constexpr T& emplace(Args&&. args);
Constraints: is_constructible_v<T, Args..> is true, and T occurs exactly once in Types.
Effects: Equivalent to: return emplace<I>(std::forward<Args>(args).); where I is the zero-based index of T in Types.
template<class T, class U, class. Args> constexpr T& emplace(initializer_list<U> il, Args&&. args);
Constraints: is_constructible_v<T, initializer_list<U>&, Args..> is true, and T occurs exactly once in Types.
Effects: Equivalent to: return emplace<I>(il, std::forward<Args>(args).); where I is the zero-based index of T in Types.
template<size_t I, class. Args> constexpr variant_alternative_t<I, variant<Types..>& emplace(Args&&. args);
Effects: Destroys the currently contained value if valueless_by_exception() is false.
Then direct-non-list-initializes the contained value of type
Remarks: If an exception is thrown during the initialization of the contained value, the variant is permitted to not hold a value.
template<size_t I, class U, class. Args> constexpr variant_alternative_t<I, variant<Types..>& emplace(initializer_list<U> il, Args&&. args);
Effects: Destroys the currently contained value if valueless_by_exception() is false.
Then direct-non-list-initializes the contained value of type
Remarks: If an exception is thrown during the initialization of the contained value, the variant is permitted to not hold a value.

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