Namespaces
Variants
Views
Actions

Difference between revisions of "cpp/error/throw with nested"

From cppreference.com
< cpp‎ | error
m (Mention how it nests)
(fmt)
Line 7: Line 7:
 
}}
 
}}
  
Throws an exception of unspecified type that is derived from both {{cpp|std::nested_exception}} and from {{cpp|std::remove_reference<T>::type}}, and constructed from {{cpp|std::forward<T>(t)}}. The default constructor of the nested_exception parent calls std::current_exception, capturing the currently handled exception object, if any, in std::exception_ptr.  
+
Throws an exception of unspecified type that is derived from both {{cpp|std::nested_exception}} and from {{cpp|std::remove_reference<T>::type}}, and constructed from {{cpp|std::forward<T>(t)}}. The default constructor of the nested_exception parent calls {{cpp|std::current_exception}}, capturing the currently handled exception object, if any, in {{cpp|std::exception_ptr}}.  
  
 
If {{cpp|std::remove_reference<T>::type}} is already derived from {{cpp|std::nested_exception}}, simply throws {{cpp|std::forward<T>(t)}}.
 
If {{cpp|std::remove_reference<T>::type}} is already derived from {{cpp|std::nested_exception}}, simply throws {{cpp|std::forward<T>(t)}}.

Revision as of 11:04, 29 March 2012

Template:cpp/error/sidebar

Defined in header <exception>
template< class T >
[[noreturn]] void throw_with_nested( T&& t );
(since C++11)

Throws an exception of unspecified type that is derived from both Template:cpp and from Template:cpp, and constructed from Template:cpp. The default constructor of the nested_exception parent calls Template:cpp, capturing the currently handled exception object, if any, in Template:cpp.

If Template:cpp is already derived from Template:cpp, simply throws Template:cpp.

Requires that Template:cpp is Template:concept

Contents

Parameters

t - the exception object to throw

Return value

(none)

Example

Template:cpp/error/exception/example nested exception

See also

Template:cpp/error/exception/dcl list nested exceptionTemplate:cpp/error/exception/dcl list rethrow if nested