C++ exception safety paranoia: how much is too much?
问题 The strong exception safety guarantee says that an operation won't change any program state if an exception occurs. An elegant way of implementing exception-safe copy-assignment is the copy-and-swap idiom. My questions are: Would it be overkill to use copy-and-swap for every mutating operation of a class that mutates non-primitive types? Is performance really a fair trade for strong exception-safety? For example: class A { public: void increment() { // Copy A tmp(*this); // Perform throwing