r/cpp • u/User_Deprecated • Jul 11 '26
Propagating exceptions from destructors with std::exception_ptr
https://www.sandordargo.com/blog/2026/07/08/exception_ptr
80
Upvotes
r/cpp • u/User_Deprecated • Jul 11 '26
View all comments
47
u/teo-tsirpanis Jul 11 '26
Having your destructor throw remains a bad idea; you should design your code to move any clean-up that might fail (or perform expensive operations for that matter) outside the destructor, and just free memory or other resources in the destructor.