TL DR : I wouldn’t do this because exand eptr(maybe?) They refer to various exceptions. (see edit: it can be guaranteed, but the standard is not entirely clear so I cannot rely on it)
The lifetime of exceptions is determined by §15.1 [except.throw] , namely:
4/ , , . 7.3.4.1. , . , , , std::exception_ptr (§18.8.5), , , . , , , . std::exception_ptr. ; . [: , , ; . §18.8.5 §30.6. -end note]
:
3/ (§8.5, §12.8) , . lvalue , (§15.3). [...]
, :
eptr , , , ,ex , eptr- catch,
msg , , ... .
, , - std::exception_ptr, .
, , §18.8.5 [] :
7/[...] [: rethrow_exception ( ), . exception_ptr, , . -end note]
, :
[[noreturn]] void rethrow_exception(exception_ptr p);
9/: p .
10/Throws: , p.
Throws throw *p;, , throw; ( , ). , if, 7, , ...
: , ... ; , - -, .