Boost logo

Boost :

From: Brian McNamara (lorgon_at_[hidden])
Date: 2003-10-31 02:10:08


On Fri, Oct 31, 2003 at 01:26:28PM +0800, Joel de Guzman wrote:
> Brian McNamara <lorgon_at_[hidden]> wrote:
> > 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.
> >
> > I am clearly missing something, but I don't know what. :)
>
> Oh yes, you can always coerce an API to have it your way <wink ;>

So does my code above work for you? If not, can you show me the problem?
I'm still confused what the issue is here.

-- 
-Brian McNamara (lorgon_at_[hidden])

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk