Optional
Optional
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
Any instance of optional<T> at any given point in time either contains a value or does not contain a value.
1 2 3 4 5 6 7 8 | |
1 2 3 4 | |
1 2 3 4 5 6 | |
1 2 3 4 | |