std::optional
std::optional
Defined in header <optional> | ||
---|---|---|
template< class T > class optional; | (since C++17) |
The class template std::optional
manages an optional contained value, i.e. a value that may or may not be present.
A common use case for optional
is the return value of a function that may fail. As opposed to other approaches, such as std::pair<T,bool>
, opti