std::optional operator*() and operator->() - undefined behavior
c++
Solution
Runtime performance.
See the proposal, revision 4, which said:
Using the indirection operator for a disengaged object is an undefined behavior. This behavior offers maximum runtime performance.
Problem
What was the motivation for having both operator*() and operator->() - undefined behavior when the instance is not initialized? Why not treat it as an error and throw an exception?