It is very useful to be able to compare for equality a std::optional<T>
with T
:
std::optional<int> opt_value;
int value = 123;
opt_value == value; // will always be 'false'
I think the behavior in this case is well defined and clear.
What I do not get is why is this allowed:
opt_value < value; // this will always be 'true'
I was expecting this to not even compile. I think it is very obscure what is happening here. What is the reason why this has been even added to the STL?