
On 23 August 2011 10:08, Julian Gonggrijp <j.gonggrijp@gmail.com> 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@eviloverlord.com> (847) 691-1404