In your case, there is NO exception guarantee. (This is basically case 0). The Wikipedia article you quoted is clear: "The rules apply to class implementations". Furthermore, after you throw, the variable j
is out of scope and no longer exists. You can't even talk about its address anymore, let alone the value
Usually, class invariants are defined by the class author, so it means whatever the class author means. I don't understand your point 1. NULL
is a valid value for a pointer.
Your second point is a good one. The definition isn't absolute. For instance, an operation on a string data member may increase its capacity. You can observe this on the outside via a const&
. Yet, that string capacity usually is not considered as part of the string value, and therefore not as part of the class invariant.