std::any::emplace
From cppreference.com
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) |
Changes the contained object to one of type T
constructed from the arguments.
First destroys the current contained object (if any) by reset(), then:
1) constructs an object of type
T
, direct-non-list-initialized from std::forward<Args>(args)..., as the contained object. If std::is_constructible_v<T, Args...> is false, the behavior is undefined.
2) constructs an object of type
T
, direct-non-list-initialized from il, std::forward<Args>(args)..., as the contained object. This overload only participates in overload resolution if std::is_constructible_v<T, std::initializer_list<U>&, Args...> is true. [edit] Exceptions
Throws any exception thrown by T
's constructor. If an exception is thrown, the previously contained object (if any) has been destroyed, and *this
does not contain a value.
[edit] Example
This section is incomplete Reason: no example |
[edit] See also
constructs an any object (public member function) |
|
destroys contained object (public member function) |