
on Mon Jun 11 2012, "Simonson, Lucanus J" <lucanus.j.simonson-AT-intel.com> wrote:
In C++03, func_modify() would be the choice of performance-conscious programmers. In C++11, as we've told that "return by value is free" and the syntax is more elegant, I'm afraid everyone will write "func_factory". And func_factory() is less efficient when used in loops and other situations where resource reusing is essential.
If you aren't in a loop you probably don't care about performance. I know I intend to stick with pass by reference. It is very useful to clearly understand and be able to easily reason about the ownership of resources in a program.
If that's your primary concern, why on earth wouldn't you use pass-by-value? -- Dave Abrahams BoostPro Computing http://www.boostpro.com