std::experimental::optional::optional
From cppreference.com
< cpp | experimental | optional
constexpr optional();
|
(1) | (library fundamentals TS) |
constexpr optional( std::nullopt_t );
|
(1) | (library fundamentals TS) |
optional( const optional& other);
|
(2) | (library fundamentals TS) |
optional( optional&& other );
|
(3) | (library fundamentals TS) |
constexpr optional( const T& value );
|
(4) | (library fundamentals TS) |
constexpr optional( T&& value );
|
(5) | (library fundamentals TS) |
template< class... Args >
constexpr explicit optional( std::in_place_t, Args&&... args ); |
(6) | (library fundamentals TS) |
template< class U, class... Args >
constexpr explicit optional( std::in_place_t, std::initializer_list<U> ilist, |
(7) | (library fundamentals TS) |
Constructs a new optional
object.
1) Constructs the object without initializing the contained value. The object is in disengaged state after the call.
2-3) Initializes the contained value by copying (2) or moving(3) the contained value of
other
, but only if other
is engaged. other
is still in engaged state if it was in engaged state before the call.
4-7) Initializes the contained value from various sources. *this is in engaged state after the call.
4) Initializes the contained value by copying
value
.
5) Initializes the contained value by moving
value
.
6) Initializes the contained value by constructing it in-place and passing
args...
to the constructor.
7) Initializes the contained value by constructing it in-place and passing the initializer list
ilist
and arguments args...
to the constructor. The function does not participate in the overload resolution if
std::is_constructible<T, std::initializer_list<U>&, Args&&...>::value != true
[edit] Parameters
other | - | another optional object whose contained value to copy
|
value | - | value to initialize the contained value with |
args... | - | arguments to initialize the contained value with |
ilist | - | initializer list to initialize the contained value with |
Type requirements | ||
-
T must meet the requirements of CopyConstructible in order to use overloads (2,4).
|
||
-
T must meet the requirements of MoveConstructible in order to use overloads (3,5).
|
[edit] Exceptions
1)
noexcept specification:
noexcept
2) Throws any exception thrown by the constructor of
T
.
3) Throws any exception thrown by the constructor of
T
. Has the following noexcept
declaration:
noexcept specification:
.noexcept(std::is_nothrow_move_constructible<T>::value)
4-5) Throws any exception thrown by the constructor of
T
.[edit] See also
creates an optional object (function template) |