-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Description
There is a similar rule in the SEI CERT C++ Coding Standard: ERR60-CPP. Exception objects must be nothrow copy constructible (down at the time of submitting this issue).
Rationale: exception objects are copy-initialized, and if an implementation chooses to not elide this copy, or there is an additional copy at the catch site (i.e. not following E.15: Throw by value, catch exceptions from a hierarchy by reference), and the copy constructor throws, then std::terminate
is called.
It's sufficient if the exception type is nothrow copy constructible, but I can't see why someone would want to make a throwing copy assignment operator at the same time, aside from doing some magic in the copy constructor and not bothering to define a copy assignment operator, but that already violates the rule of three / five.