Breaking News
Loading...
Tuesday 16 September 2008

copy elision and copy-and-swap idiom

20:50
An updated writeup of the copy-and-swap idiom is now available on the More C++ Idioms wikibook. A comparison of two different styles of assignment operator is shown. First version accepts the parameter as pass-by-const-reference whereas the second version accepts it as pass-by-value. For some classes pass-by-value turns out to be more efficient as a copy of the object is elided when the right hand side is a rvalue.

0 comments:

Post a Comment

 
Toggle Footer