Sunday, December 5, 2010

Exception Specifications

The prototype: allocator() throw(); means the allocator constructor does not throw exceptions.

The exception specification (whose use is typically discouraged by the C++ community) says that the function does not intentionally throw any exceptions. If an exception is inadvertently thrown, the function unexpected() would be called. This function can be set by <unexpected.h>::set_unexpected(). If the default one is called, then the function terminate() is called.

This function can be set by <terminate.h>::set_terminate(). If the default one is called, then the function abort() is called. If the user-defined terminate() does not call abort(), abort() will be called automatically at the end of the user-defined terminate function.

No comments:

Post a Comment