Exception Specification

Exception Specification

#include <exception>
 
class SysException { };
 
void f( ) throw (SysException)
{
    throw std::exception();
}
 
int main()
{
    f();
}

Calling f() should result in std::unexpected being called …

http://www.devx.com/tips/Tip/15140

The Standard Library defines a function called std::unexpected() which is invoked when a function throws an exception not listed in its exception specification. std::unexpected invokes a user-defined function that was registered by std::set_unexpected. If the user hasn't registered such a function, unexpected() will invoke std::terminate(), which in turn calls abort() and terminates the program. (…)

Exception specifications are apparently evil: http://www.gotw.ca/publications/mill22.htm

See http://groups.google.com/group/comp.lang.c++.moderated/browse_thread/thread/653f69b07a9f7052

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License