----- Original Message -----
From: "Peter Dimov" <[EMAIL PROTECTED]>
To: "Boost mailing list" <[EMAIL PROTECTED]>
Sent: Tuesday, December 10, 2002 3:33 PM
Subject: Re: [boost] Formal review: Optional library


> From: "Fernando Cacciola" <[EMAIL PROTECTED]>
> > > 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.
>
I understand your reasoning, but what do you suggest?
Leaving optional<bool> inherently unsafe? with a strong remark on the
documentation that you should been using optional<bool> in the first place?
Or specializing optional<bool>, perhaps, with a empty definition so that it
is explicitly banned?

It worries me that any of the options above will create problems when
optional is used generically, as in optional<T>.

Fernando Cacciola

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Reply via email to