On Monday, 30 March 2015 at 17:20:30 UTC, matovitch wrote:
Yes but you know what they say does it really do a copy of the struct or is the compiler smart enougth most of the time to avoid copy. (I think it's called return value optimization).

Copying isn't necessarily a problem, for small structs it is more efficient to copy than passing by ref. But the return value optimization *is* typically done, yes.

Why is this only restricted to templates ?

It makes two versions of the function, like overloading on the two types of arguments automatically.

Reply via email to