From: Joel de Guzman (djowel_at_[hidden])
Date: 2002-12-12 20:17:34
----- Original Message -----
From: "David Abrahams" <dave_at_[hidden]>
> > Optional does not have pointer semantics. Two optionals can never alias each
> > other. "Consistent with pointer semantics" doesn't make sense. Optional is
> > not a pointer. Don't try to make it into one; you'll arrive at shared_ptr.
> > ;-)
> As usual, I agree with Peter
I completely agree with Peter as well. Optional is not a pointer.
I will reiterate my position on this: optional<T> is equivalent to
variant<T, nit_t> in behavior. Is it a container as Peter suggested?
Yes, in the same way that variant<T0, T1,...TN> is a container that
holds one of T0..TN (one at a time) and in the same way that
tuple<T0...TN> is also a container that holds T0..TN simultaneously.
Implementation issues notwithstanding (and we've shown that
optional can be implemented in terms of variant), The behavior
of the optional should be that of the variant<T, nil_t>.
While on the surface, optional looks like a pointer, and in fact
it is meant to replace some uses of pointers, A replaced by B
does not automatically mean that B is an A!
Joel de Guzman
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk