Execute a callback function when this scope gets destroyed.
More...
#include <asyncpp/scope_guard.h>
|
| | scope_guard (TFunction func, bool engaged=true) noexcept(std::is_nothrow_move_constructible_v< TFunction >) |
| | Construct a new scope guard.
|
| |
|
| scope_guard (const scope_guard &)=delete |
| |
|
scope_guard & | operator= (const scope_guard &)=delete |
| |
|
| ~scope_guard () |
| | Destructor.
|
| |
|
void | disengage () noexcept |
| | Disengage the guard, making sure the callback is not executed on destruction.
|
| |
|
void | engage () noexcept |
| | Engage the guard, making sure the callback is executed on destruction.
|
| |
| bool | is_engaged () const noexcept |
| | Check if the guard is engaged.
|
| |
|
TFunction & | function () noexcept |
| | Get a reference to the contained function.
|
| |
|
const TFunction & | function () const noexcept |
| | Get a const reference to the contained function.
|
| |
template<typename TFunction>
class asyncpp::scope_guard< TFunction >
Execute a callback function when this scope gets destroyed.
- Note
- Because the callback is executed in the destructor it is required to be marked noexcept.
- Template Parameters
-
| TFunction | Type of the callback function |
◆ scope_guard()
template<typename TFunction >
Construct a new scope guard.
- Parameters
-
| func | The function to invoke |
| engaged | true if the guard is engaged right away. |
◆ is_engaged()
template<typename TFunction >
Check if the guard is engaged.
- Returns
- true if the callback will execute on destruction, false if not.
The documentation for this class was generated from the following file: