On 05.05.2013, at 01:22, Michael Marcin <mike.marcin@gmail.com> wrote:
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
I am not concerned about direct initialization, the important case (for the discussion of Boost.Operators' future) is the "identity( rvalue() )"-case. Of course MSVC (like other compilers) does perform copy elision in some cases, but I am still looking for a case like identity(), where a parameter is pass-by-value and that parameter is returned from the function. Is there some way that the copy/move of the parameter can be avoided? In the test-program I wrote, is there a way to beat STANDARD with PASS_BY_VALUE?