"Joel de Guzman" <[EMAIL PROTECTED]> writes: > ----- Original Message ----- > From: "Fernando Cacciola" <[EMAIL PROTECTED]> > > > >> 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. > > Hi, > > 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, nil_t> > in disguise. Correct me if I'm wrong.
Someone once said that if a theorem in Physics involves numbers other than zero, 1, or infinity, it's lacking in purity. optional captures the zero/one distinction, which, as its analogy to pointers makes clear, is a very useful one. A type which can contain any number of different types would have a much more complicated interface. Maybe it's just a different library? -- David Abrahams [EMAIL PROTECTED] * http://www.boost-consulting.com Boost support, enhancements, training, and commercial distribution _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost