Scope guard that invokes a callback on scope exit.
Declared in <absl/cleanup/cleanup.h>
template<
typename Arg,
typename Callback = void()>
class [[nodiscard]] Cleanup final
absl::Cleanup implements the scope guard idiom, invoking the contained callback's operator()() && on scope exit.
This class doesn't allocate or take any locks, and is safe to use in a signal handler. Of course the callback with which it is constructed also must be signal safe in order for this to be useful.
| Name | Description |
|---|---|
Cleanup [constructor] | Constructors |
~Cleanup [destructor] | Invoke the callback, if still engaged, on scope exit. |
Cancel | Prevent the callback from executing. |
Invoke | Execute the callback early and prevent it from running on destruction. |
| Name | Description |
|---|---|
Cleanup<cleanup_internal::Tag, Callback> | Deduction guide for creating an absl::Cleanup from a callback. |
| Name | Description |
|---|---|
MakeCleanup | Create an absl::Cleanup from a callback. |
The return value should not be discarded.