hi,guys
I see that some codes in cc like this one.
e.g.
void functionname (const classname& var)
{
classname localvar = var;
......
}
here,in the function body functionname, why it make a copy for "var".
if want to make a copy for "var",why not use it in this way??
void functionname (const classname var)
{
//classname localvar = var;
......
}
correct me if I am wrong,thanks.
Why do you care?
Some people say that the second way of doing it might be faster ( http://cpp-next.com/archive/2009/08/want-speed-pass-by-value/ ).
Thanks for your reply. :D
I am going to rewrite the cc search function,but I see that in some funciton body it make a copy for the function arguments,I dont know why it was used here,
e.g.
the function arguments (var) here.
is it relatived to something(like thread-safe or else)? :D
if not,I will omit it in my new cc search function. :D
RVO optimization capability is very limited!
There might be no particular reason at all, or it might be not wanting to change the function's signature for SDK compatibility at a later time.