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
Show parent comment
5
u/Remi_Coulom Jul 11 '26
An alternative pattern is to have a transaction function that takes a lambda as a parameter, and performs cleanup after calling the lambda, outside of a destructor. This allows properly catching write errors in the final buffer flush.