Skip to content

Commit 9a765c4

Browse files
committed
Dbo::Transaction: fix C++20 compilation
uncaught_exception() is deprecated, so let's use std::uncaught_exceptions when __cpp_lib_uncaught_exceptions is set. This caused compilation to fail on latest MSVC
1 parent 09c8964 commit 9a765c4

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/Wt/Dbo/Transaction.C

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,15 @@ Transaction::~Transaction() noexcept(false)
4040
// Either this Transaction shell was not committed (first condition)
4141
// or the commit failed (we are still active and need to rollback)
4242
if (!committed_ || impl_->needsRollback_) {
43+
#if defined(__cpp_lib_uncaught_exceptions) && __cpp_lib_uncaught_exceptions >= 201411L
44+
const bool uncaughtException = std::uncaught_exceptions() != 0;
45+
#else
46+
const bool uncaughtException = std::uncaught_exception();
47+
#endif
4348
// A commit attempt failed (and thus we need to rollback) or we
4449
// are unwinding a stack while an exception is thrown
45-
if (impl_->needsRollback_ || std::uncaught_exception()) {
46-
bool canThrow = !std::uncaught_exception();
50+
if (impl_->needsRollback_ || uncaughtException) {
51+
bool canThrow = !uncaughtException;
4752
try {
4853
rollback();
4954
} catch (...) {

0 commit comments

Comments
 (0)