exception safety

Exception safety covers a variety of considerations that are necessary in order to write code that behaves predictably in the event of a thrown exception.

When move semantics were introduced in C++11, it sparked a lot of discussion about how to pass arguments to functions that will take a copy of the argument value (for example, the “set” half of get/set functions). That confusion seemed to subside when the “by value by default” suggestion started to make the rounds, but in his CppCon2014 talk, Herb Sutter set off a whole new round of debate. Sutter makes two arguments for why “by const-ref by default” is the best rule. I don’t buy them. Continue Reading