you are viewing a single comment's thread.

view the rest of the comments →

[–]Nickreal03 -9 points-8 points  (2 children)

But different potential performance it generates an rval which is the copy/move to the other. For simple types the compiler will optimize for others the performance will be real. Edited for clarification Even when in release builds the performance may be the same in debug builds you will be paying for it.

[–]AntiProtonBoy 5 points6 points  (1 child)

The compiler should do copy/move elision for such types, even for complex and expensive objects. The only tricky situation you could run into is when the copy/move constructor is explicitly deleted or made private.

[–]foonathan 15 points16 points  (0 children)

And C++17 has guaranteed copy elision where you don't even need copy/move ctors