Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2004-02-11 14:09:02


"Powell, Gary" <powellg_at_[hidden]> writes:

> Just because I like this sort of stuff, I added a test case with 1
> level of inheritence, and it works pretty well. There is a minor
> amount of trickiness to get the derived class to call the right base
> class constructor. Just need to remember to use the ref.p.

Nice. I think we'd implement a "move" function which could handle
that explicitly in any real implementation:

    Y(ref rhs)
      : X( move(*rhs.p) ) // <== here
      , id(++cnt)
      , owner(rhs.p->owner)
    {
        std::cout << "MOVE #" << id << " <== #" << rhs.p->id << std::endl;
        rhs.p->owner = false;
        assert(owner);
    }

> All in all
> I like it better than the MOJO soln which IMO was much more
> invasive.

What about the MOJO approach seems more invasive to you?

> (I still like the core soln of adding && to indicate you are
> taking a move reference though, seems to be less error prone to code
> IMHO.)

Definitely.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

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