[#absl-Cleanup-0a]
= xref:absl.adoc[absl]::Cleanup
:relfileprefix: ../
:mrdocs:

Scope guard that invokes a callback on scope exit&period;

== Synopsis

Declared in `&lt;absl&sol;cleanup&sol;cleanup&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    typename Arg,
    typename Callback = void()&gt;
class &lsqb;&lsqb;nodiscard&rsqb;&rsqb; Cleanup final
----

== Description

`absl&colon;&colon;Cleanup` implements the scope guard idiom, invoking the contained callback&apos;s `operator()() &amp;&amp;` on scope exit&period;

This class doesn&apos;t allocate or take any locks, and is safe to use in a signal handler&period; Of course the callback with which it is constructed also must be signal safe in order for this to be useful&period;

== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:absl/Cleanup-0a/2constructor-0e.adoc[`Cleanup`]         [.small]#[constructor]#
| Constructors
| xref:absl/Cleanup-0a/2destructor.adoc[`&#126;Cleanup`] [.small]#[destructor]#
| Invoke the callback, if still engaged, on scope exit&period;
| xref:absl/Cleanup-0a/Cancel.adoc[`Cancel`] 
| Prevent the callback from executing&period;
| xref:absl/Cleanup-0a/Invoke.adoc[`Invoke`] 
| Execute the callback early and prevent it from running on destruction&period;
|===


== Deduction Guides

[cols="1,4"]
|===
| Name| Description
| xref:absl/Cleanup-03.adoc[`Cleanup&lt;cleanup&lowbar;internal::Tag, Callback&gt;`] 
| Deduction guide for creating an `absl&colon;&colon;Cleanup` from a callback&period;
|===


== Non-Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:absl/MakeCleanup.adoc[`MakeCleanup`]
| Create an `absl&colon;&colon;Cleanup` from a callback&period;
|===

== Return Value

[NOTE]
====
The return value https://en.cppreference.com/cpp/language/attributes/nodiscard[should not be discarded^].
====

[.small]#Created with https://www.mrdocs.com[MrDocs]#
