The class template std::optional manages an optional contained value, i.e. a value that may or may not be present. It is a great alternative for std::unique_ptr, or raw pointer, when used solely to express that a value is indeed optional. The type of the variable explicitly states that a contained...
I was recently investigating a bug and would like to share an unexpected, yet interesting discovery regarding the cause of the issue.
In order to provide an idea of what I was working on, consider the following code as a simplified representation: