mirror of
https://github.com/microsoft/GSL.git
synced 2025-04-02 09:18:33 -04:00
explicitly document finally actions must be non-throwing
because the gsl::final_action destructor is marked noexcept(true), the action cannot throw else the program will terminate; this nuance should be documented explicitly and (to be investigated later) ideally enforced in code.
This commit is contained in:
parent
355982daf6
commit
8eb3205aab
@ -794,7 +794,7 @@ template <class F>
|
|||||||
class final_action { ... };
|
class final_action { ... };
|
||||||
```
|
```
|
||||||
|
|
||||||
`final_action` allows you to ensure something gets run at the end of a scope.
|
`final_action` allows you to ensure non-throwing code is executed at the end of a scope.
|
||||||
|
|
||||||
See [E.19: Use a final_action object to express cleanup if no suitable resource handle is available](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Re-finally)
|
See [E.19: Use a final_action object to express cleanup if no suitable resource handle is available](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Re-finally)
|
||||||
|
|
||||||
@ -805,13 +805,13 @@ explicit final_action(const F& ff) noexcept;
|
|||||||
explicit final_action(F&& ff) noexcept;
|
explicit final_action(F&& ff) noexcept;
|
||||||
```
|
```
|
||||||
|
|
||||||
Construct an object with the action to invoke in the destructor.
|
Construct an object with the non-throwing action to invoke in the destructor.
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
~final_action() noexcept;
|
~final_action() noexcept;
|
||||||
```
|
```
|
||||||
|
|
||||||
The destructor will call the action that was passed in the constructor.
|
The destructor will invoke the action that was passed in the constructor; if the action throws an exception the program will terminate.
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
final_action(final_action&& other) noexcept;
|
final_action(final_action&& other) noexcept;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user