mirror of
https://github.com/microsoft/GSL.git
synced 2025-04-01 08:56:29 -04:00
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.
This commit is contained in:
parent
355982daf6
commit
8ffd43043d
@ -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<F>)
|
||||
|
||||
final_action(final_action&& other) noexcept
|
||||
: f(std::move(other.f)), invoke(std::exchange(other.invoke, false))
|
||||
|
Loading…
x
Reference in New Issue
Block a user