[#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. == Synopsis Declared in `<absl/flags/reflection.h>` [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. Example: void MyFunc() { absl::FlagSaver fs; ... absl::SetFlag(&FLAGS_myFlag, otherValue); ... } // scope of FlagSaver left, flags return to previous state This class is thread‐safe. == Member Functions [cols="1,4"] |=== | Name| Description | xref:absl/FlagSaver/2constructor-04.adoc[`FlagSaver`] [.small]#[constructor]# | Constructors | xref:absl/FlagSaver/2destructor.adoc[`~FlagSaver`] [.small]#[destructor]# | Restores all flags to the state saved at construction. | xref:absl/FlagSaver/operator_assign.adoc[`operator=`] [.small]#[deleted]# | Not assignable. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#