chsvlib
chsv helper source code

◆ rethrow_if_nested()

void Chusov::Exceptions::rethrow_if_nested ( E &&  e)

Implements a behaviour of the standard std::rethrow_if_nested function checking if the most derived dynamic type of the specified exception inherits the nested_exception class and, if that is true, throws an exception stored by the nested_exception object calling nested_exception::rethrow_nested(). If an exception object given by the parameter is not dynamically connected with the nested_exception class through inheritance, the function does nothing. .

Template Parameters
Eis a type of an exception given by the parameter.
Parameters
eis a universal reference to an exception to rethrow.

Together with throw_with_nested function and with nested_exception class the function implements a behaviour of the standard C++11 nested exceptions mechanism as defined by the std::rethrow_if_nested, std::throw_with_nested functions and by the std::nested_exception class respectively.

Warning
Neither the class nor the functions constituting the nested exceptions facility are supposed to be used with any other implementation of nested exceptions, including the one provided by the standard library, if any.
Examples
chsvexception\nested_exceptions.cpp.