The book C++ Concurrency in Action by Anthony Williams states in 4.2.4 Saving an exception for the future that it is possible to store an exception directl
tl;dr: std::copy_exception
was renamed to std::make_exception_ptr
in <exception>
for the final C++11 standard.
The committee decided that the name copy_exception
(probably copied into the standard from boost::copy_exception) was misleading for the following reasons.
The copy_exception
function returns an exception_ptr
to a copy of its argument, as if
template <class E>
exception_ptr copy_exception(E e) {
try {
throw e;
} catch (...) {
return current_exception();
}
}
When called with an exception_ptr
as argument, the function would return another exception_ptr
pointing to a copy of the exception_ptr
given as argument, instead of pointing to what the exception_ptr
argument points to. Because the name copy_exception
was misleading for this case, the function was renamed to std::make_exception_ptr
for the final C++11 standard. See the C++ Standard Library Defect Report 1130 for details and discussion on this issue.
The std::make_exception_ptr
function is defined in <exception>
.