On 5/4/2013 5:36 PM, Daniel Frey wrote:
On 04.05.2013, at 21:45, Michael Marcin <mike.marcin@gmail.com> wrote:
Here is another data point: http://ideone.com/GgaZZV
And here are msvc11 results: http://codepad.org/XFT5qVyE
based on: http://stackoverflow.com/questions/1693005/copy-elision-on-visual-c-2010-bet...
From what I can see these are some more basic tests and they confirm that copy elision does not take place for pass-by-value (for MSVC, but my tests also confirmed that for GCC/Clang), i.e., the last test case "identity( rvalue() )" does not eliminate the temporary. Is there anything else that can be learned from the above that I missed?
MSVC11 does do copy elision when only trivial types are involved it seems. For example try instead of std::vector try: typedef std::array<std::pair<int,int>,4> pod; Direct initialization from rvalue, constructed with pod X a(( rvalue(pod()) )) =========== X5: construct (with pod) X5: destroy ----------- 0/1 possible copies made 0/1 possible moves made 1/1 possible elisions performed However any more complicated it seems to give up. To my mind the following should be a trivial change that has no impact. Indeed gcc-4.7.2 has no change but msvc11: Direct initialization from rvalue, constructed with pod X a(( true, rvalue(pod()) )) =========== X3: construct (with pod) X4: <- X3: **move** X3: destroy X4: destroy ----------- 0/1 possible copies made 1/1 possible moves made 0/1 possible elisions performed