[#absl-GetFlag] = xref:absl.adoc[absl]::GetFlag :relfileprefix: ../ :mrdocs: Returns the value (of type `T`) of an `absl::Flag<T>` instance, by value. Do not construct an `absl::Flag<T>` directly and call `absl::GetFlag()`; instead, refer to flag's constructed variable name (e.g. `FLAGS_name`). Because this function returns by value and not by reference, it is thread‐safe, but note that the operation may be expensive; as a result, avoid `absl::GetFlag()` within any tight loops. == Synopsis Declared in `<absl/flags/flag.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<typename T> [[nodiscard]] T GetFlag(xref:absl/Flag.adoc[absl::Flag<T>] const& flag); ---- == Description Example: // FLAGS_count is a Flag of type `int` int my_count = absl::GetFlag(FLAGS_count); // FLAGS_firstname is a Flag of type `std::string` std::string first_name = absl::GetFlag(FLAGS_firstname); == Return Value The current value of `flag`. [NOTE] ==== The return value https://en.cppreference.com/cpp/language/attributes/nodiscard[should not be discarded^]. ==== == Parameters [cols="1,4"] |=== | Name| Description | *flag* | The flag whose value to retrieve. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#