Boost.Optional uses a dummy type to allow constructing uninitialized instances of boost::optional
. This type is called none_t
, and an inst
Ah, I had never thought to dig deeper.
One (more or less obvious) advantage to a regular struct
, is that now none
evaluates to false
in boolean contexts.
One advantage over another "evaluates to false" is that pointer to member are prevented from harmful promotion to integral types.
So, I guess that it offers a safe and concise way of having a object that evaluates to false
.
EDIT: One should recognize here (hum...) the structure of the Safe Bool Idiom.