terminologyexception-safe

How do I describe a method that has no side effects if an exception is thrown during execution?


I just can't remember the terminology used for this and other related properties.

EDIT - Maybe such a concept doesn't exist but I remember reading something in Effective C++ (or More Effective C++) where he advocated using swaps to commit changes last in the function because the vector swap functions were guaranteed not to throw an exception.


Solution

  • I think you mean to say that the function is "exception-safe". See e.g. http://en.wikipedia.org/wiki/Exception_safety.

    The Wikipedia article further divides the safety into various levels. This is the one that is relevant here:

    2. Commit or rollback semantics, also known as strong exception safety or no-change guarantee: Operations can fail, but failed operations are guaranteed to have no side effects so all data retain original values.

    There's a reference to an STL design document that introduces exception safety and commit-or-rollback semantics: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/1997/N1077.asc