# Boost Exception

### exception_ptr

#include <boost/exception_ptr.hpp>

    namespace
    boost
        {
        typedef ---unspecified--- exception_ptr;
        }

The exception_ptr type can be used to refer to a copy of an exception object. It is Default Constructible, Copy Constructible, Assignable and Equality Comparable; exception_ptr's operations do not throw.

The referenced object remains valid at least as long as there is an exception_ptr object that refers to it.

Two instances of exception_ptr are equivalent and compare equal if and only if they refer to the same exception.

The default constructor of exception_ptr produces the null value of the type. The null value is equivalent only to itself.

#### Thread safety:

The exception_ptr type is "as thread-safe as built-in types":

- An exception_ptr instance can be "read" simultaneously by multiple threads
- Different exception_ptr instances can be "written to" simultaneously by multiple threads, even when these instances refer to the same exception object

All other simultaneous accesses result in undefined behavior.

#### Nesting of exceptions:

An exception_ptr can be added as error_info to any boost::exception. This is a convenient way to nest exceptions. There is no limit on the depth of the nesting, however cyclic references result in undefined behavior.

See also: Boost Exception | boost/exception/errinfo_nested_exception.hpp | boost/exception_ptr.hpp | copy_exception | current_exception | diagnostic_information | enable_current_exception | Frequently Asked Questions | original_exception_type | rethrow_exception | unknown_exception