Why does the std::scope_success destructor check if uncaught exceptions are less or equal

113 views Asked by At

According to

https://en.cppreference.com/w/cpp/experimental/scope_success/~scope_success

The destructor of std::scope_success checks if the current number of uncaught exception (std::uncaught_exceptions) is less or equal than when it was constructed.

It makes sense that it compares it to the previous value (on its construction) instead of zero, so that scope_success can be used during stack unwinding.

But why does it check if the count is less or equal, and not just equal? Is there a situation where std::uncaught_exceptions will be lower in its destructor, than in its constructor?

0

There are 0 answers