Boost logo

Boost :

Subject: Re: [boost] [move] moving temporaries of copyable types
From: David Abrahams (dave_at_[hidden])
Date: 2009-08-10 09:44:05

on Wed Jun 24 2009, klaus triendl <> wrote:

>> Sorry for not catching this yet because I can't find time to fully
>> understand your approach and do some portability tests. Just to make
>> things a bit easier when I have some time, what do you mean with "make
>> copyable types *implicitly* movable"? Can you give me a concrete example
>> of what's possible with your approach that was not possible before?
> Ok, I'm working on my ability to explain :)
> Simply put:
> <code>
> clone_ptr<int> return_rvalue()
> {
> return clone_ptr<int>(new int(1));
> }
> clone_ptr<int> p;
> // Boost.Move ---> temporary gets copied
> // my approach ---> temporary gets moved
> p = return_rvalue();
> </code>

In both cases the temporary should get RVO'd (i.e. the copy should be
elided) on all modern compilers. If you can find a modern compiler
where Boost.Move does not RVO, then its design needs to be fixed.

Dave Abrahams
BoostPro Computing

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