diff options
Diffstat (limited to 'absl/flags/internal/flag.h')
-rw-r--r-- | absl/flags/internal/flag.h | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/absl/flags/internal/flag.h b/absl/flags/internal/flag.h index 89e43ad7..370d8a02 100644 --- a/absl/flags/internal/flag.h +++ b/absl/flags/internal/flag.h @@ -632,20 +632,9 @@ class Flag { std::string CurrentValue() const { return impl_.CurrentValue(); } private: - template <typename U, bool do_register> + template <typename, bool> friend class FlagRegistrar; - -#if !defined(_MSC_VER) || defined(__clang__) - template <typename U> - friend U absl::GetFlag(const flags_internal::Flag<U>& flag); - template <typename U> - friend void absl::SetFlag(flags_internal::Flag<U>* flag, const U& v); - template <typename U, typename V> - friend void absl::SetFlag(flags_internal::Flag<U>* flag, const V& v); -#else - template <typename U> - friend class absl::Flag; -#endif + friend class FlagImplPeer; T Get() const { // See implementation notes in CommandLineFlag::Get(). @@ -668,10 +657,6 @@ class Flag { impl_.Write(&v); } - template <typename U> - friend const CommandLineFlag& absl::GetFlagReflectionHandle( - const absl::Flag<U>& f); - // Access to the reflection. const CommandLineFlag& Reflect() const { return impl_; } @@ -684,6 +669,25 @@ class Flag { }; /////////////////////////////////////////////////////////////////////////////// +// Trampoline for friend access + +class FlagImplPeer { + public: + template <typename T, typename FlagType> + static T InvokeGet(const FlagType& flag) { + return flag.Get(); + } + template <typename FlagType, typename T> + static void InvokeSet(FlagType& flag, const T& v) { + flag.Set(v); + } + template <typename FlagType> + static const CommandLineFlag& InvokeReflect(const FlagType& f) { + return f.Reflect(); + } +}; + +/////////////////////////////////////////////////////////////////////////////// // Implementation of Flag value specific operations routine. template <typename T> void* FlagOps(FlagOp op, const void* v1, void* v2, void* v3) { |