diff options
Diffstat (limited to 'third_party/abseil_cpp/absl/flags/flag.h')
-rw-r--r-- | third_party/abseil_cpp/absl/flags/flag.h | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/third_party/abseil_cpp/absl/flags/flag.h b/third_party/abseil_cpp/absl/flags/flag.h index 90dc2894df54..a9cb2b7994d1 100644 --- a/third_party/abseil_cpp/absl/flags/flag.h +++ b/third_party/abseil_cpp/absl/flags/flag.h @@ -144,11 +144,17 @@ class Flag { inline bool IsOfType() const { return GetImpl().template IsOfType<U>(); } - T Get() const { return GetImpl().Get(); } - void Set(const T& v) { GetImpl().Set(v); } + T Get() const { + return flags_internal::FlagImplPeer::InvokeGet<T>(GetImpl()); + } + void Set(const T& v) { + flags_internal::FlagImplPeer::InvokeSet(GetImpl(), v); + } void InvokeCallback() { GetImpl().InvokeCallback(); } - const CommandLineFlag& Reflect() const { return GetImpl().Reflect(); } + const CommandLineFlag& Reflect() const { + return flags_internal::FlagImplPeer::InvokeReflect(GetImpl()); + } // The data members are logically private, but they need to be public for // this to be an aggregate type. @@ -180,7 +186,7 @@ class Flag { // std::string first_name = absl::GetFlag(FLAGS_firstname); template <typename T> ABSL_MUST_USE_RESULT T GetFlag(const absl::Flag<T>& flag) { - return flag.Get(); + return flags_internal::FlagImplPeer::InvokeGet<T>(flag); } // SetFlag() @@ -192,7 +198,7 @@ ABSL_MUST_USE_RESULT T GetFlag(const absl::Flag<T>& flag) { // but especially within performance-critical code. template <typename T> void SetFlag(absl::Flag<T>* flag, const T& v) { - flag->Set(v); + flags_internal::FlagImplPeer::InvokeSet(*flag, v); } // Overload of `SetFlag()` to allow callers to pass in a value that is @@ -201,7 +207,7 @@ void SetFlag(absl::Flag<T>* flag, const T& v) { template <typename T, typename V> void SetFlag(absl::Flag<T>* flag, const V& v) { T value(v); - flag->Set(value); + flags_internal::FlagImplPeer::InvokeSet(*flag, value); } // GetFlagReflectionHandle() @@ -216,7 +222,7 @@ void SetFlag(absl::Flag<T>* flag, const V& v) { template <typename T> const CommandLineFlag& GetFlagReflectionHandle(const absl::Flag<T>& f) { - return f.Reflect(); + return flags_internal::FlagImplPeer::InvokeReflect(f); } ABSL_NAMESPACE_END @@ -379,11 +385,12 @@ ABSL_NAMESPACE_END // // `default_value` is only used as a double check on the type. `explanation` is // unused. -// TODO(rogeeff): Return an anonymous struct instead of bool, and place it into -// the unnamed namespace. -#define ABSL_RETIRED_FLAG(type, flagname, default_value, explanation) \ - ABSL_ATTRIBUTE_UNUSED static const bool ignored_##flagname = \ - ([] { return type(default_value); }, \ - absl::flags_internal::RetiredFlag<type>(#flagname)) +// TODO(rogeeff): replace RETIRED_FLAGS with FLAGS once forward declarations of +// retired flags are cleaned up. +#define ABSL_RETIRED_FLAG(type, name, default_value, explanation) \ + static absl::flags_internal::RetiredFlag<type> RETIRED_FLAGS_##name; \ + ABSL_ATTRIBUTE_UNUSED static const auto RETIRED_FLAGS_REG_##name = \ + (RETIRED_FLAGS_##name.Retire(#name), \ + ::absl::flags_internal::FlagRegistrarEmpty{}) #endif // ABSL_FLAGS_FLAG_H_ |