diff --git a/docs/headers.md b/docs/headers.md index 498340f..b67e7f3 100644 --- a/docs/headers.md +++ b/docs/headers.md @@ -816,7 +816,7 @@ explicit final_action(F&& ff) noexcept; Construct an object with the action to invoke in the destructor. ```cpp -~final_action() noexcept; +~final_action() noexcept(std::is_nothrow_invocable_v); ``` The destructor will call the action that was passed in the constructor. diff --git a/include/gsl/util b/include/gsl/util index 7a3caed..55f8db7 100644 --- a/include/gsl/util +++ b/include/gsl/util @@ -103,7 +103,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) { if (invoke) f(); } final_action(final_action&& other) noexcept : f(std::move(other.f)), invoke(std::exchange(other.invoke, false))