std::experimental::optional::emplace - cppreference.com

##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# std::experimental::optional::emplace

From cppreference.com
< cpp‎ | experimental‎ | optional

template< class... Args > void emplace( Args&&... args ); |  | (library fundamentals TS)
template< class U, class... Args > void emplace( std::initializer_list<U> ilist, Args&&... args ); |  | (library fundamentals TS)

Constructs the contained value in-place. If *this is in engaged state before the call, the contained value is destroyed by calling its destructor.

1) Initializes the contained value by calling its constructor with `args...` as parameters.
2) Initializes the contained value by calling its constructor with `ilist` and `args...` as parameters.

### [edit] Parameters

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...`

### [edit] Return value

(none)

### [edit] Exceptions

Any exception thrown by the selected constructor of `T`. If an exception is thrown, *this is in disengaged state after the call.

### [edit] See also

operator= | assigns contents (public member function) [edit]

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=cpp/experimental/optional/emplace&oldid=68702"