has_value() explicitly checks whether a std::optional currently contains a value. It returns true when the optional is set and false when it is empty, making legitimate absence distinct from a reserved integer. section 3.1.2
Checking optional input
After reading optional numeric input, use if (value.has_value()) before accessing the contained integer. The same presence test can also be written with optional's explicit operator bool, such as while (guess = read_number(std::cin)). section 3.1.2
int actual_value = value.value();
Once has_value() confirms presence, value() retrieves the contained integer; calling value() on an empty optional throws an exception. section 3.1.2
