Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
HP.com home

HP C++ User Documentation

 

unexpected (3C++std) - Tru64 UNIX

Standard C++ Library

NAME

  unexpected_handler, set_unexpected, unexpected, uncaught_exception -  The
  type unexpected_handler and functions set_unexpected(), unexpected(), and
  uncaught_exception support abnormal program termination.

SYNOPSIS

  #include <exception>

  namespace std {
    typedef void (*unexpected_handler)();
    unexpected_handler set_unexpected(unexpected_handler new_h) throw();
    void unexpected();
    bool uncaught_exception();
  }

DESCRIPTION

  typedef void (*unexpected_handler)();

  unexpected_handler is the type of a handler function called by unexpected()
  when a function attempts to throw an exception not listed in its
  exception-specification. The required behavior of an unexpected_handler is
  to throw an exception or terminate program execution without returning to
  the caller.  The unexpected_handler may perform any of the following:

    o throw an exception that satisfies the exception specification
      (if the call to unexpected() is from the program not from
       the implementation any exception may be thrown)
    o throw an exception of class bad_exception or of any
      class directly or indirectly derived from bad_exception.
    o call terminate()
    o call abort() or exit()

  The Standard C++ Library provides a unexpected_handler which is called by
  default.  The library provided unexpected_handler calls terminate().

  unexpected_handler set_unexpected(unexpected_handler new_h) throw();

  set_unexpected() sets the current unexpected_handler to the function passed
  in as its unexpected_handler input parameter.  It returns the previous
  unexpected_handler.  The function is not allowed to be a null pointer.

  void unexpected();

  unexpected() is called by the implementation when a function exits by an
  exception not allowed by its exception specification.  It may be directly
  called by a user program.  If called by the implementation, unexpected()
  calls the unexpected_handler function in effect after evaluating the
  throw-expression.  If called by the program, unexpected() calls the current
  unexpected_handler function.

  bool uncaught_exception();

  uncaught_exception() returns true if a thrown exception is currently being
  processed.

SEE ALSO

  bad_exception, terminate

STANDARDS CONFORMANCE

  ANSI X3J16/ISO WG21 Joint C++ Committee
About PDF files: The PDF files on this site can be read online or printed using Adobe® Acrobat® Reader. If you do not have this software on your system, you may download it from Adobe's website.
Privacy statement Using this site means you accept its terms C++ support
© 2008 Hewlett-Packard Development Company, L.P.