Exception Safety
 
 
 

Good C++ programming practices dictates that classes should be exception-safe. This can improve the stability of code, by preventing the possibility of partial construction of objects.

One mechanism to achieve this is to use member initialization lists in a constructor instead of making assignments in the body of the constructor. This also improves the ability of the compiler to optimize your code. For more information consult the book The C++ Programming Language by Bjarne Stroustrup.

Another mechanism is usage of the resource acquisition is initialization (RAII) pattern. This pattern is well-documented in various books on C++, and is out of the scope of this documentation.

The 3ds Max SDK provides the MaxSDK::VariableGuard class which is a simple example of the RAII pattern in action. MaxSDK::VariableGuard automates the task of setting a variable to a new value, then resetting it to its old value in an exception safe manner. For more details see maxsdk\include\VariableGuard.h.