Defined in header <optional> | ||
---|---|---|
template< class T > constexpr std::optional<std::decay_t<T>> make_optional( T&& value ); | (1) | (since C++17) |
template< class T, class... Args > constexpr std::optional<T> make_optional( Args&&... args ); | (2) | (since C++17) |
template< class T, class U, class... Args > constexpr std::optional<T> make_optional( std::initializer_list<U> il, Args&&... args ); | (3) | (since C++17) |
value
. Effectively calls std::optional<std::decay_t<T>>(std::forward<T>(value))
args...
. Equivalent to return std::optional<T>(std::in_place, std::forward<Args>(args)...);
.il
and args...
. Equivalent to return std::optional<T>(std::in_place, il, std::forward<Args>(args)...);
.value | - | the value to construct optional object with |
il, args | - | arguments to be passed to the constructor of T . |
The constructed optional object.
Throws any exception thrown by the constructor of T
.
T
need not be movable for overloads (2-3) due to guaranteed copy elision.
constructs the optional object (public member function) |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
http://en.cppreference.com/w/cpp/utility/optional/make_optional