[#absl-FlagSaver]
= xref:absl.adoc[absl]::FlagSaver
:relfileprefix: ../
:mrdocs:

A `FlagSaver` object stores the state of flags in the scope where the `FlagSaver` is defined, allowing modification of those flags within that scope and automatic restoration of the flags to their previous state upon leaving the scope&period;

== Synopsis

Declared in `&lt;absl&sol;flags&sol;reflection&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
class FlagSaver;
----

== Description

A `FlagSaver` can be used within tests to temporarily change the test environment and restore the test case to its previous state&period;

Example&colon;

void MyFunc() &lcub; absl&colon;&colon;FlagSaver fs&semi; &period;&period;&period; absl&colon;&colon;SetFlag(&amp;FLAGS&lowbar;myFlag, otherValue)&semi; &period;&period;&period; &rcub; &sol;&sol; scope of FlagSaver left, flags return to previous state

This class is thread&hyphen;safe&period;

== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:absl/FlagSaver/2constructor-04.adoc[`FlagSaver`]         [.small]#[constructor]#
| Constructors
| xref:absl/FlagSaver/2destructor.adoc[`&#126;FlagSaver`] [.small]#[destructor]#
| Restores all flags to the state saved at construction&period;
| xref:absl/FlagSaver/operator_assign.adoc[`operator&equals;`]  [.small]#[deleted]#
| Not assignable&period;
|===



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