![]() |
Arene Base
Fundamental Utilities For Safety Critical C++
|
RAII utility for executing logic on scope exit. More...
Public Member Functions | |
| template<typename Func2, constraints< std::enable_if_t< std::is_constructible< Func, Func2 >::value >, std::enable_if_t<!std::is_same< remove_cvref_t< Func2 >, scope_guard >::value > > = nullptr> | |
| scope_guard (Func2 &&supplied_callable) noexcept(std::is_nothrow_constructible< Func, Func2 >::value) | |
| Construct a new scope_guard that decay-copies the function and ensure that it is called upon destruction of the scope_guard object. | |
| scope_guard (scope_guard &&other) noexcept | |
| Move constructor. | |
| scope_guard (scope_guard const &)=delete | |
| copy-construction is deleted as two guards cannot own the same function. | |
| ~scope_guard () | |
| Destroy the scope guard and invoke the function if it should be executed. | |
| void | cancel () noexcept |
| Declares the held function should not be invoked. | |
| void | invoke_now () noexcept |
| Invokes the held function if it has not be otherwise canceled. | |
| auto | operator= (scope_guard &&other) -> scope_guard &=delete |
| Move assignment is deleted as allowing it would overwrite the existing guard function without executing it. | |
| auto | operator= (scope_guard const &) -> scope_guard &=delete |
| copy-assignment is deleted as two guards cannot own the same function. | |
RAII utility for executing logic on scope exit.
The scope_guard type is a utility that helps writing exception-safe code by ensuring that some code gets run on scope-exit, regardless of how the scope is exited (return, exception, flowing off end, etc). The destructor of the scope_guard class invokes the function passed to the constructor.
scope_guard instances.| Func | The functor to be called on scope exit. Must have signature void(void) noexcept . It also must be nothrow move constructable for scope_guard to be move-constructable. |
|
inlineexplicitnoexcept |
Construct a new scope_guard that decay-copies the function and ensure that it is called upon destruction of the scope_guard object.
| Func2 | The type of the supplied callable |
| supplied_callable | The supplied callable |
|
inlinenoexcept |
Move constructor.
Moves ownership of the function and responsibility for calling the function on destruction to the newly constructed scope_guard object.
| other | The scope_guard to move from. |
other other scope_guard can be safely destructed.
|
delete |
copy-construction is deleted as two guards cannot own the same function.
|
inline |
Destroy the scope guard and invoke the function if it should be executed.
invoke_now() .
|
inlinenoexcept |
Declares the held function should not be invoked.
invoke_now() will be noops.
|
inlinenoexcept |
Invokes the held function if it has not be otherwise canceled.
cancel() has not been called, invokes the held functor. invoke_now() are noops as if cancel() had been called.
|
delete |
Move assignment is deleted as allowing it would overwrite the existing guard function without executing it.
|
delete |
copy-assignment is deleted as two guards cannot own the same function.