Namespaces
Variants
Views
Actions

std::current_exception

From cppreference.com
< cpp‎ | error
Revision as of 19:26, 2 April 2012 by Cubbi (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Template:cpp/error/sidebar

Defined in header <exception>
std::exception_ptr current_exception()
(since C++11)

If called during exception handling (typically, in a Template:cpp clause), captures the current exception object and creates an Template:cpp that holds a reference to that exception object, or to a copy of that exception object (it is implementation-defined if a copy is made)

If the implementation of this function requires a call to Template:cpp and the call fails, the returned pointer will hold a reference to an instance of Template:cpp

If the implementation of this function requires to copy the captured exception object and its copy constructor throws an exception, the returned pointer will hold a reference to the exception thrown. If the copy constructor of the thrown exception object also throws, the returned pointer may hold a reference to an instance of Template:cpp to break the endless loop.

If the function is called when no exception is being handled, an empty Template:cpp is returned.

Contents

Parameters

(none)

Return value

An instance of Template:cpp holding a reference to the exception object, or a copy of the exception object, or to an instance of Template:cpp or to an instance of Template:cpp.

Exceptions

noexcept specification:  
noexcept
  

Example

Template:cpp/error/exception/example exception ptr

See also

Template:cpp/error/exception/dcl list exception ptrTemplate:cpp/error/exception/dcl list rethrow exceptionTemplate:cpp/error/exception/dcl list make exception ptr