I am trying to understand the references to C ++ 11 rvalue and how to use them for optimal performance in my code.
Let's say we have a class Athat has a pointer to a large amount of dynamically allocated data.
It is also a method foo(const A& a)that does something with a class object A.
I want to prohibit calling the copy constructorA when the object Ais passed to the function foo, since in this case it will make a deep copy of the underlying heap data.
I tested passing lvalue links:
A a;
foo(a);
and passing the rvalue link:
foo(A());
In both cases, the copy constructor was not called.
(Apple LLVM 5.1)? - ?