libstdc++
Exceptions
Collaboration diagram for Exceptions:

Classes

class  __cxxabiv1::__forced_unwind
 Thrown as part of forced unwinding.A magic placeholder class that can be caught by reference to recognize forced unwinding. More...
struct  __gnu_cxx::forced_error
 Thown by exception safety machinery. More...
class  __gnu_cxx::recursive_init_error
 Exception thrown by __cxa_guard_acquire.6.7[stmt.dcl]/4: If control re-enters the declaration (recursively) while the object is being initialized, the behavior is undefined. More...
class  std::__exception_ptr::exception_ptr
 An opaque pointer to an arbitrary exception. More...
class  std::bad_alloc
 Exception possibly thrown by new.bad_alloc (or classes derived from it) is used to report allocation errors from the throwing forms of new. More...
class  std::bad_cast
 Thrown during incorrect typecasting.If you attempt an invalid dynamic_cast expression, an instance of this class (or something derived from this class) is thrown. More...
class  std::bad_exception
class  std::bad_function_call
 Exception class thrown when class template function's operator() is called with an empty target. More...
class  std::bad_typeid
 Thrown when a NULL pointer in a typeid expression is used. More...
class  std::bad_weak_ptr
 Exception possibly thrown by shared_ptr. More...
class  std::domain_error
class  std::exception
 Base class for all library exceptions. More...
class  std::future_error
 Exception type thrown by futures. More...
class  std::invalid_argument
class  std::ios_base::failure
 These are thrown to indicate problems with io.27.4.2.1.1 Class ios_base::failure. More...
class  std::length_error
class  std::logic_error
 One of two subclasses of exception. More...
class  std::nested_exception
 Exception class with exception_ptr data member. More...
class  std::out_of_range
class  std::overflow_error
class  std::range_error
class  std::regex_error
 A regular expression exception class.The regular expression library throws objects of this class on error. More...
class  std::runtime_error
 One of two subclasses of exception. More...
class  std::system_error
 Thrown to indicate error code of underlying system. More...
class  std::underflow_error

Typedefs

typedef void(* std::terminate_handler )()
typedef void(* std::unexpected_handler )()

Functions

template<typename _Ex >
const nested_exception * std::__get_nested_exception (const _Ex &__ex)
template<typename _Ex >
void std::__throw_with_nested (_Ex &&, const nested_exception *=0) __attribute__((__noreturn__))
template<typename _Ex >
void std::__throw_with_nested (_Ex &&,...) __attribute__((__noreturn__))
void __gnu_cxx::__verbose_terminate_handler ()
template<typename _Ex >
exception_ptr std::copy_exception (_Ex __ex) _GLIBCXX_USE_NOEXCEPT
exception_ptr std::current_exception () _GLIBCXX_USE_NOEXCEPT
template<typename _Ex >
exception_ptr std::make_exception_ptr (_Ex __ex) _GLIBCXX_USE_NOEXCEPT
void std::rethrow_exception (exception_ptr) __attribute__((__noreturn__))
template<typename _Ex >
void std::rethrow_if_nested (const _Ex &__ex)
void std::rethrow_if_nested (const nested_exception &__ex)
terminate_handler std::set_terminate (terminate_handler) _GLIBCXX_USE_NOEXCEPT
unexpected_handler std::set_unexpected (unexpected_handler) _GLIBCXX_USE_NOEXCEPT
void std::terminate () _GLIBCXX_USE_NOEXCEPT __attribute__((__noreturn__))
template<typename _Ex >
void std::throw_with_nested (_Ex __ex)
bool std::uncaught_exception () _GLIBCXX_USE_NOEXCEPT __attribute__((__pure__))
void std::unexpected () __attribute__((__noreturn__))

Detailed Description

Classes and functions for reporting errors via exception classes.


Typedef Documentation

typedef void(* std::terminate_handler)()

If you write a replacement terminate handler, it must be of this type.

Definition at line 89 of file exception.

typedef void(* std::unexpected_handler)()

If you write a replacement unexpected handler, it must be of this type.

Definition at line 92 of file exception.


Function Documentation

void __gnu_cxx::__verbose_terminate_handler ( )

A replacement for the standard terminate_handler which prints more information about the terminating exception (if any) on stderr.

Call

to use. For more info, see http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt02ch06s02.html

In 3.4 and later, this is on by default.

template<typename _Ex >
exception_ptr std::copy_exception ( _Ex  __ex)

Obtain an exception_ptr pointing to a copy of the supplied object.

Definition at line 167 of file exception_ptr.h.

References std::current_exception().

exception_ptr std::current_exception ( )

Obtain an exception_ptr to the currently handled exception. If there is none, or the currently handled exception is foreign, return the null value.

Referenced by std::copy_exception().

template<typename _Ex >
exception_ptr std::make_exception_ptr ( _Ex  __ex)

Obtain an exception_ptr pointing to a copy of the supplied object.

Definition at line 186 of file exception_ptr.h.

void std::rethrow_exception ( exception_ptr  )

Throw the object pointed to by the exception_ptr.

template<typename _Ex >
void std::rethrow_if_nested ( const _Ex &  __ex)
inline

If __ex is derived from nested_exception, __ex.rethrow_nested().

Definition at line 146 of file nested_exception.h.

void std::rethrow_if_nested ( const nested_exception &  __ex)
inline

Overload, See N2619.

Definition at line 154 of file nested_exception.h.

terminate_handler std::set_terminate ( terminate_handler  )

Takes a new handler function as an argument, returns the old function.

unexpected_handler std::set_unexpected ( unexpected_handler  )

Takes a new handler function as an argument, returns the old function.

void std::terminate ( )

The runtime will call this function if exception handling must be abandoned for any reason. It can also be called by the user.

template<typename _Ex >
void std::throw_with_nested ( _Ex  __ex)
inline

If __ex is derived from nested_exception, __ex. Else, an implementation-defined object derived from both.

Definition at line 136 of file nested_exception.h.

bool std::uncaught_exception ( )

[18.6.4]/1: 'Returns true after completing evaluation of a throw-expression until either completing initialization of the exception-declaration in the matching handler or entering unexpected() due to the throw; or after entering terminate() for any reason other than an explicit call to terminate(). [Note: This includes stack unwinding [15.2]. end note]'

2: 'When uncaught_exception() is true, throwing an exception can result in a call of terminate() (15.5.1).'

Referenced by std::basic_ostream< _CharT, _Traits >::sentry::~sentry().

void std::unexpected ( )

The runtime will call this function if an exception is thrown which violates the function's exception specification.