diff options
Diffstat (limited to 'butl/diagnostics.cxx')
-rw-r--r-- | butl/diagnostics.cxx | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/butl/diagnostics.cxx b/butl/diagnostics.cxx index e4c22dc..ad84810 100644 --- a/butl/diagnostics.cxx +++ b/butl/diagnostics.cxx @@ -28,14 +28,19 @@ namespace butl diag_record:: ~diag_record () noexcept (false) { - // Don't flush the record if this destructor was called as part of - // the stack unwinding. Right now this means we cannot use this - // mechanism in destructors, which is not a big deal, except for - // one place: exception_guard. So for now we are going to have - // this ugly special check which we will be able to get rid of - // once C++17 uncaught_exceptions() becomes available. + // Don't flush the record if this destructor was called as part of the + // stack unwinding. + // +#ifdef BUTL_CXX17_UNCAUGHT_EXCEPTIONS + if (uncaught_ == std::uncaught_exceptions ()) + flush (); +#else + // Fallback implementation. Right now this means we cannot use this + // mechanism in destructors, which is not a big deal, except for one + // place: exception_guard. Thus the ugly special check. // if (!std::uncaught_exception () || exception_unwinding_dtor) flush (); +#endif } } |