<exception>namespace std {
class exception;
class bad_exception;
typedef void (*terminate_handler)();
typedef void (*unexpected_handler)();
terminate_handler
set_terminate(terminate_handler ph) throw();
unexpected_handler
set_unexpected(unexpected_handler ph) throw();
void terminate();
void unexpected();
bool uncaught_exception();
};
Include the standard header <exception>
to define several types and functions related to the handling of
exceptions.
bad_exceptionclass bad_exception : public exception {
};
The class describes an exception that can be thrown from an unexpected
handler. The value returned by what() is an
implementation-defined C string. None of
the member functions throw any exceptions.
exceptionclass exception {
public:
exception() throw();
exception(const exception& rhs) throw();
exception& operator=(const exception& rhs) throw();
virtual ~exception() throw();
virtual const char *what() const throw();
};
The class serves as the base class for all exceptions thrown
by certain expressions and by the Standard C++ library. The C string value
returned by what()
is left unspecified by the default constructor, but may be
defined by the constructors for certain derived classes as an
implementation-defined C string. None of
the member functions throw any exceptions.
set_terminateterminate_handler
set_terminate(terminate_handler ph) throw();
The function establishes a new terminate handler
as the function *ph. Thus, ph must not
be a null pointer. The function returns the address of the
previous terminate handler.
set_unexpectedunexpected_handler
set_unexpected(unexpected_handler ph) throw();
The function establishes a new unexpected handler
as the function *ph. Thus, ph must not
be a null pointer. The function returns the address of the
previous unexpected handler.
terminatevoid terminate();
The function calls a terminate
handler, a function of type void (). If terminate
is called directly by the program, the terminate handler is the
one most recently set by a call to set_terminate.
If terminate is called for any of several other
reasons during evaluation of a throw expression, the terminate
handler is the one in effect immediately after evaluating the
throw expression.
A terminate handler may not return to its caller. At program startup,
the terminate handler is a function that calls abort().
terminate_handlertypedef void (*terminate_handler)();
The type describes a pointer to a function suitable for use as a terminate handler.
uncaught_exceptionbool uncaught_exception();
The function returns true only if a thrown exception is being
currently processed. Specifically, it returns true after
completing evaluation of a throw expression and before completing
initialization of the exception declaration in the matching
handler or calling unexpected as a
result of the throw expression.
unexpectedvoid unexpected();
The function calls an unexpected
handler, a function of type void (). If unexpected
is called directly by the program, the unexpected handler is the
one most recently set by a call to set_unexpected.
If unexpected is called when control leaves a
function by a thrown exception of a type not permitted by an exception specification
for the function, as in:
void f() throw() // function may throw no exceptions
{throw "bad"; } // throw calls unexpected()
the unexpected handler is the one in effect immediately after evaluating the throw expression.
An unexpected handler may not return to its caller. It may terminate execution by:
bad_exceptionterminate(),
abort(), or exit(int)At program
startup, the unexpected handler is a function that calls terminate().
unexpected_handlertypedef void (*unexpected_handler)();
The type describes a pointer to a function suitable for use as an unexpected handler.
See also the Table of Contents .
Copyright © 1992-1996 by P.J. Plauger. All rights reserved.