Boost logo

Boost :

From: Fernando Cacciola (fernando_cacciola_at_[hidden])
Date: 2003-10-30 21:40:23

"Brian McNamara" <lorgon_at_[hidden]> escribió en el mensaje
> On Fri, Oct 31, 2003 at 09:50:47AM +0800, Joel de Guzman wrote:
> > be swayed. Here's my use-case:
> This is good (I agree use-cases are better than "theory" here).
And so do I, so Joel's case is definitely shifting the balance so far.

> [snipped]

> Why doesn't this:
> template <class T>
> class match {
> optional<T> data;
> ...
> public:
> match( T x ) : data(x) {}
> ...
> void value( T y ) {
> *data = y;
> }
> };
> do what you want? If T is a reference type, the match's constructor
> puts the reference in the optional, and then calls to value() change the
> value of the referred-to object. If T is a non-reference type, it also
> works, as far as I can tell.
Maybe the problem is genericity.
I guess the implementation of 'value()' cannot use the '*' syntax because
'data' might be something different than an optional<>.

Joel, your use case seems to indicate that the required aliasing semantics
are actually needed in case 'data' is in fact initialized.
If I'm right, this would suggest that my recommended semantic for the
uninitialized lhs case (treat it as initialization) won't conflict with your
case here.

Fernando Cacciola

Boost list run by bdawes at, gregod at, cpdaniel at, john at