r/cpp • u/pavel_v • Apr 02 '26
What happens when a destructor throws
https://www.sandordargo.com/blog/2026/04/01/when-a-destructor-throws
102
Upvotes
r/cpp • u/pavel_v • Apr 02 '26
View all comments
Show parent comment
3
u/tyler1128 Apr 02 '26
You need a mechanism to handle that, though. There is a quite valid argument that exceptions are a poor choice for such a mechanism, but then you need something like
std::expected<T, E>,Result<T, R>again invoking Rust that inspired it, or use return codes/errno which is in my opinion a worse option than exceptions.