Pass by Value
When passing an object by value, the initialization of the formal parameter with the actual parameter is equivalent to the following form [ES90]:
T formalArg = actualArg;
where T is the class type. Suppose g() is some function expecting a T argument when invoked:
void g (T formalArg) { ... }
A typical invocation of g() may look like:
T t; g(t);
The activation record for g() has a place holder on the stack for its local argument formalArg. The compiler must copy the content of object t into g()'s formalArg on the stack. One popular technique of doing this will generate a temporary [Lip96I].
The compiler will create a temporary object of type T and copy-construct it using t as an input argument. This temporary will then be passed ...
Get Efficient C++ Performance Programming Techniques now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.