|
Boost : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-12-10 13:33:49
From: "Fernando Cacciola" <fernando_cacciola_at_[hidden]>
> > 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.
> >
> Good point. I've been using optional<bool> long before tribool existed.
> Now I might replace optional<bool> with tribool; but, a user still
> can have optional<bool>.
But what is gained by using optional<bool> instead of
enum optional_bool { uninitialized, true_, false_ };
?
Especially if you take into account that with the enum you can use
descriptive identifiers. It's a good idea to use enums in interfaces even
for non-optional bools when the meaning of 'true' isn't immediately
apparent.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk