Month: May 2014

Want speed? Don’t (always) pass by value.

As the title indicates, this post is motivated by Dave Abrahams’ influential blog post “Want speed? Pass by Value”. In that post, Abrahams makes the case that often passing and returning by value is cheaper than passing by reference, or trying to engineer some means to return pointers or references. This is due to copy elision, which has been a part of the language since standardization, and move semantics, which were introduced with C++11. Often, passing and returning by value results in code that is both clearer and safer. This in itself is a compelling argument, speed considerations aside.

(more…)

Advertisements