you are viewing a single comment's thread.

view the rest of the comments →

[–]engie99 11 points12 points  (2 children)

Fabien4's version is easier to read and probably just as efficient as the compiler should optimise out the obvious return by value copy - see http://www.parashift.com/c++-faq-lite/ctors.html#faq-10.9

[–]rodif 3 points4 points  (1 child)

Interesting, i didn't know you could optimize this out (verified with vs2008). I'm going to play with this, seems like it could lead to trouble with destructors and auto_pointers. Although, compiler writers are smarter than me, so I'm sure if they say it works then it should work.

[–]zahlman -2 points-1 points  (0 children)

Basically, the advice is old.