Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-12-10 07:23:16

From: "Fernando Cacciola" <fernando_cacciola_at_[hidden]>
> The conversion to bool for a smart pointer unambiguously refers to the
> NULL state of the pointer wrapped.
> In the case of optional, a conversion to bool will be ambiguous in those
> cases were the wrapped T in optional<> is bool itself.

On the other hand, it would enable the useful idiom

if(optional<T> pt = get_optional_T())
// use *pt

I don't think that optional<bool> is an important use case (outside of
generic contexts) since optional<bool> is simply a tri-state type with an
inconvenient interface.

Boost list run by bdawes at, gregod at, cpdaniel at, john at