about summary refs log tree commit diff
path: root/absl/flags/flag.h
diff options
context:
space:
mode:
Diffstat (limited to 'absl/flags/flag.h')
-rw-r--r--absl/flags/flag.h33
1 files changed, 6 insertions, 27 deletions
diff --git a/absl/flags/flag.h b/absl/flags/flag.h
index bd61668ff4f1..fcfdd58cbf4a 100644
--- a/absl/flags/flag.h
+++ b/absl/flags/flag.h
@@ -186,15 +186,17 @@ class Flag {
 //
 //   // FLAGS_firstname is a Flag of type `std::string`
 //   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();
+}
+
 #ifndef NDEBUG
 // We want to validate the type mismatch between type definition and
 // declaration. The lock-free implementation does not allow us to do it,
 // so in debug builds we always use the slower implementation, which always
 // validates the type.
-template <typename T>
-ABSL_MUST_USE_RESULT T GetFlag(const absl::Flag<T>& flag) {
-  return flag.Get();
-}
+
 // We currently need an external linkage for built-in types because shared
 // libraries have different addresses of flags_internal::FlagOps<T> which
 // might cause log spam when checking the same flag type.
@@ -202,29 +204,6 @@ ABSL_MUST_USE_RESULT T GetFlag(const absl::Flag<T>& flag) {
   ABSL_MUST_USE_RESULT T GetFlag(const absl::Flag<T>& flag);
 ABSL_FLAGS_INTERNAL_BUILTIN_TYPES(ABSL_FLAGS_INTERNAL_BUILT_IN_EXPORT)
 #undef ABSL_FLAGS_INTERNAL_BUILT_IN_EXPORT
-#else
-template <typename T,
-          typename std::enable_if<
-              !flags_internal::IsAtomicFlagTypeTrait<T>::value, int>::type = 0>
-ABSL_MUST_USE_RESULT T GetFlag(const absl::Flag<T>& flag) {
-  return flag.Get();
-}
-// Overload for `GetFlag()` for types that support lock-free reads.
-template <typename T,
-          typename std::enable_if<
-              flags_internal::IsAtomicFlagTypeTrait<T>::value, int>::type = 0>
-ABSL_MUST_USE_RESULT T GetFlag(const absl::Flag<T>& flag) {
-  // T might not be default constructible.
-  union U {
-    T value;
-    U() {}
-  };
-  U result;
-  if (flag.AtomicGet(&result.value)) {
-    return result.value;
-  }
-  return flag.Get();
-}
 #endif
 
 // SetFlag()