std::optional
cppreference.com
<tbody>
</tbody>
| <optional> .
|
||
template< class T > class optional; |
(since C++14) | |
std::optional . .
{{tt|optional} . std::pair<T,bool> optional .
optional . , optional operator*() operator->() .
optional . optional engaged , disengaged .
optional engaged .:
-
T - engaged
optional
disengaged .:
- std::nullopt_t disengaged
optional - std::nullopt_t disengaged
optional
| T | - | . Destructible .
|
| Member type | Definition |
value_type
|
T
|
| constructs the optional object (public member function) | |
| if engaged, destroys the contained value (public member function) | |
| assigns contents (public member function) | |
Observers | |
| accesses the contained value (public member function) | |
| checks whether the object is in engaged state (public member function) | |
| returns the contained value (public member function) | |
| returns the contained value if engaged, another value otherwise (public member function) | |
Modifiers | |
| exchanges the contents (public member function) | |
| constructs the contained value in-place (public member function) | |
Non-member functions
compares optional objects (function template) | |
creates an optional object (function template) | |
| specializes the std::swap algorithm (function) |
| specializes the std::hash algorithm (class template specialization) |