[PATCH] Exploit move semantics in std::accumulate.
Marc Glisse
marc.glisse@inria.fr
Tue Jan 11 16:16:00 GMT 2011
On Tue, 11 Jan 2011, Christopher Jefferson wrote:
> It is my belief that indeed we can't be sure that x=move(x) will behave
> correctly.
>
> However, doing x = f(move(x), y) should be fine. Unless of course f just
> returns an rvalue reference to it's first argument. But then f is a very
> badly behaved function, possibly with other issues.
Hmm, I believe the issue can happen even if f returns an object (not a
reference). Indeed that object may still "be x", either because it was
move-initialized from x, or because of copy elision (yes I know compilers
don't usually perform the elision here).
(we might want to move the discussion to csc++ or some such place)
--
Marc Glisse
More information about the Libstdc++
mailing list