Compare commits

...

5 Commits

Author SHA1 Message Date
apenn-msft
7ee701d3d1
Merge 49371c5f298707209c5f947bec747558bcd955a6 into 7fabaa499dcb22fa81f8028449cb56fda7fa6aa7 2025-02-14 15:44:22 -08:00
apenn-msft
49371c5f29
syntax fix 2025-02-03 18:24:21 -05:00
apenn-msft
e00c1ccf55
fix syntax 2025-02-03 18:22:26 -05:00
apenn-msft
628b2c5c27
Update headers.md 2025-02-03 18:07:56 -05:00
apenn-msft
8ffd43043d
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.
2025-02-03 18:01:15 -05:00
2 changed files with 2 additions and 2 deletions

View File

@ -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<F>);
```
The destructor will call the action that was passed in the constructor.

View File

@ -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<F>) { if (invoke) f(); }
final_action(final_action&& other) noexcept
: f(std::move(other.f)), invoke(std::exchange(other.invoke, false))