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.
Declared in <absl/flags/flag.h>
template<typename T>
[[nodiscard]]
T
GetFlag(absl::Flag<T> const& flag);
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);
| Name | Description |
|---|---|
| flag | The flag whose value to retrieve. |