chsvlib
chsv helper source code

◆ throw_with_nested()

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

Implements a behaviour of the standard std::throw_with_nested function storing an exception having been caught by a caller and retrieved by a call to the std::current_exception function in the constructed nested_exception object and throwing an exception specified by the only parameter. .

Template Parameters
Eis a type of an exception to be thrown by the function.
Parameters
eis a universal reference to an exception to be thrown after storing the current exception.

Together with rethrow_if_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::throw_with_nested, std::rethrow_if_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.