By Abrahams we have 3 types of exception :

  1. Nothrow
  2. Basic exception guarantee
  3. Strong exception guarantee

Basic means (please correct me if I'm wrong) that Invariants are preserved e.g that the invariants of the component are preserved, and no resources are leaked , where Strong that the operation has either completed successfully or thrown an exception, leaving the program state exactly as it was before the operation started .

  1. What does it mean that Invariants are preserved ? that if I have a valid value in one of my variables then it wouldn't (take for example a pointer) hold a NULL ?

  2. Referring to Strong exception guarantee , does it mean that all my variables would store the exact same values before the exception was thrown ?

for example :

int main()

{
    int j = 1;
    int *p = &j;

    // do some stuff
    j = 2;
    throw 1;

}

Then after I throw , j would hold the value 2 or 1 ?

Regards

Edit
Report