From 8ffd43043d0c10c4a6067a3efbab861ed67139d0 Mon Sep 17 00:00:00 2001 From: apenn-msft <62863214+apenn-msft@users.noreply.github.com> Date: Mon, 3 Feb 2025 18:01:15 -0500 Subject: [PATCH] allow final action to invoke throwing actions where an action is provided to final action to execute at end of scope and that action throws, because final action's destructor is marked noexcept, the program will terminate. Instead, allow final action's destructor to be noexcept dependent upon whether the action throws. --- include/gsl/util | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/gsl/util b/include/gsl/util index fb7572e..b7baf20 100644 --- a/include/gsl/util +++ b/include/gsl/util @@ -77,7 +77,7 @@ public: explicit final_action(const F& ff) noexcept : f{ff} { } explicit final_action(F&& ff) noexcept : f{std::move(ff)} { } - ~final_action() noexcept { if (invoke) f(); } + ~final_action() noexcept(std::is_nothrow_invocable_v) final_action(final_action&& other) noexcept : f(std::move(other.f)), invoke(std::exchange(other.invoke, false))