The std::optional (C++17) is a container for representing a single optional value.
The class offers several interfaces for accessing and querying the presence of a contained value. The choice depends on your coding style and your desired exception semantics.