template <class T, class... Args> void emplace(Args&&... args); | (1) | (since C++17) |
template <class T, class U, class... Args> void emplace(std::initializer_list<U> il, Args&&... args); | (2) | (since C++17) |
template <size_t I, class... Args> void emplace(Args&&... args); | (3) | (since C++17) |
template <size_t I, class U, class... Args> void emplace(std::initializer_list<U> il, Args&&... args); | (4) | (since C++17) |
Creates a new value in-place, in an existing variant
object.
emplace<I>(std::forward<Args>(args)...)
, where I
is the zero-based index of T
in Types...
. This overload only participates in overload resolution if std::is_constructible_v<T, Args...>
is true
, and T
occurs exactly once in Types...
emplace<I>(il, std::forward<Args>(args)...)
, where I
is the zero-based index of T
in Types...
. This overload only participates in overload resolution if std::is_constructible_v<T, std::initializer_list<U>&, Args...>
is true
, and T
occurs exactly once in Types...
T_I
with the arguments std::forward<Args>(args)...
. If an exception is thrown, *this
may become valueless_by_exception. This overload only participates in overload resolution if std::is_constructible_v<T_I, Args...>
is true
. The behavior is undefined if I
is not less than sizeof...(Types)
.T_I
with the arguments il, std::forward<Args>(args)...
. If an exception is thrown, *this
may become valueless_by_exception. This overload only participates in overload resolution if std::is_constructible_v<T_I, initializer_list<U>&, Args...>
is true
. The behavior is undefined if I
is not less than sizeof...(Types)
.args | - | constructor arguments to use when constructing the new value |
il | - | initializer_list argument to use when constructing the new value |
(none).
assigns a variant (public member function) |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
http://en.cppreference.com/w/cpp/utility/variant/emplace