From: Fernando Cacciola (fernando_cacciola_at_[hidden])
Date: 2002-12-10 16:30:54
----- Original Message -----
From: "Joel de Guzman" <djowel_at_[hidden]>
To: "Boost mailing list" <boost_at_[hidden]>
Sent: Tuesday, December 10, 2002 5:21 PM
Subject: Re: [boost] Formal review: Optional library
> ----- Original Message -----
> From: "Fernando Cacciola" <fernando_cacciola_at_[hidden]>
> > optional<> is trying to model using C++ a concept that
> > it is not really covered by the language, that of uninitialzed values.
> > It uses pointer semantics *just* because pointers are the only sort of
> > C++ objects which has a clear uninitialized state.
> Probably a dumb question but allow me to ask anyway:
> Wouldn't a more generic variant<T0, T1...TN> class do what the
> optional is trying to do? I feel that optional<T> is just a variant<T,
> in disguise. Correct me if I'm wrong.
The difference is that optional<> *explicitly* deals with the possibility of
uninitialized, while variant<T,nil_t> doesn't. (for the later, nil_t is just
another possible value).
In this regard optional<> is more handy for its intended usage.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk