Boost logo

Boost :

Subject: Re: [boost] [proposal] raw move (was: [interest] underlying type library)
From: Nevin Liber (nevin_at_[hidden])
Date: 2011-08-23 12:53:48


On 23 August 2011 10:08, Julian Gonggrijp <j.gonggrijp_at_[hidden]> wrote:

> However, I don't really see why you would want to include operations
> in your code of which you know beforehand that they schould be
> optimized away by the compiler.

In the C++11 move case, the moved-from object itself doesn't know if it is
about to be destroyed or reused, so it has to be put in a state where either
can happen. The compiler, of course, knows, and I want the optimizer to
take advantage of this.

[As a parallel: I still write a correct copy constructor for a copyable
object even if all my uses involve RVO and it never gets called; as I'd
rather have correct but slower code than incorrect code if a non-RVO case
happens to pop up.]

raw_move is a user optimization over C++11 moves in that it assumes the
moved-from object is going to be reused; destruction would be very bad,
which is why there is all this worry over exception safety.

-- 
 Nevin ":-)" Liber  <mailto:nevin_at_[hidden]>  (847) 691-1404

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