Article

Propagating exceptions from destructors with std::exception_ptr

raymii ·Lobsters ·Published 2026-07-08

A few weeks ago, I wrote about what happens when a destructor actually throws and why it is a dangerous idea. One of the readers commented that he was once in a situation where he had to propagate an exception from a destructor. But as a…

From the article

A few weeks ago, I wrote about what happens when a destructor actually throws and why it is a dangerous idea. One of the readers commented that he was once in a situation where he had to propagate an exception from a destructor. But as a destructor cannot safely throw and it also cannot return any value, he needed a better solution.

And that solution was std::exception_ptr .

Let’s look into what this type is and how it can be used.


Share this resource


Discovered 2026-08-02 Source Lobsters Archive 2026-08 →