template< class... Args > T& emplace( Args&&... args ); | (since C++17) | |
template< class U, class... Args > T& emplace( std::initializer_list<U> ilist, Args&&... args ); | (since C++17) |
Constructs the contained value in-place. If *this
already contains a value before the call, the contained value is destroyed by calling its destructor.
std::forward<Args>(args)...
as parameters.ilist, std::forward<Args>(args)...
as parameters. This overload only participates in overload resolution if std::is_constructible<T, std::initializer_list<U>&, Args&&...>::value
is true
.args... | - | the arguments to pass to the constructor |
ilist | - | the initializer list to pass to the constructor |
Type requirements | ||
-T must be constructible from Args... |
||
-T must be constructible from std::initializer_list and Args... |
A reference to the new contained value.
Any exception thrown by the selected constructor of T
. If an exception is thrown, *this
does not contain a value after this call (the previously contained value, if any, had been destroyed).
assigns contents (public member function) |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
http://en.cppreference.com/w/cpp/utility/optional/emplace