From f2c9c663db28a8a898c1fc8c8e06ab9b93eb5610 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Wed, 9 Sep 2020 19:13:17 -0700 Subject: Export of internal Abseil changes -- cfb567ed02096320663d882d2c0c2fb7db7af1e4 by Derek Mauro : Upgrade to GCC 10.2.0, Bazel 3.5.0, and CMake 3.18.2 PiperOrigin-RevId: 330847323 -- 5dcb9ce14d92315163079366a91c43cbd5184ea4 by Evan Brown : Optimize equal_range() by avoiding the call to upper_bound() when possible. We need to support heterogeneous comparators that have different behavior when comparing key_type to non-key_type. See the new test. Also update the comment for `key_compare_to_adapter`. PiperOrigin-RevId: 330794444 -- 744405dbda5513527d74094a5c3b9db1e0927693 by Gennadiy Rozental : Introduce trampoline for friend access to avoid friending routines and classes from different namespace. PiperOrigin-RevId: 330773156 -- a195d1226576f8a7bb5671f3e42d1021b827fad9 by Abseil Team : Fix an incorrect version number test for std::variant availability in tvOs. PiperOrigin-RevId: 330759480 -- 58b02eb9159a577953676d9928cb26b30068b847 by Derek Mauro : Use c++20 instead of c++2a now that it is supported by GCC PiperOrigin-RevId: 330559797 GitOrigin-RevId: cfb567ed02096320663d882d2c0c2fb7db7af1e4 Change-Id: I0e0d68409c95da42f5609920155ba5694ade8df0 --- absl/flags/internal/flag.h | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) (limited to 'absl/flags/internal') 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 + template friend class FlagRegistrar; - -#if !defined(_MSC_VER) || defined(__clang__) - template - friend U absl::GetFlag(const flags_internal::Flag& flag); - template - friend void absl::SetFlag(flags_internal::Flag* flag, const U& v); - template - friend void absl::SetFlag(flags_internal::Flag* flag, const V& v); -#else - template - 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 - friend const CommandLineFlag& absl::GetFlagReflectionHandle( - const absl::Flag& f); - // Access to the reflection. const CommandLineFlag& Reflect() const { return impl_; } @@ -683,6 +668,25 @@ class Flag { FlagValue value_; }; +/////////////////////////////////////////////////////////////////////////////// +// Trampoline for friend access + +class FlagImplPeer { + public: + template + static T InvokeGet(const FlagType& flag) { + return flag.Get(); + } + template + static void InvokeSet(FlagType& flag, const T& v) { + flag.Set(v); + } + template + static const CommandLineFlag& InvokeReflect(const FlagType& f) { + return f.Reflect(); + } +}; + /////////////////////////////////////////////////////////////////////////////// // Implementation of Flag value specific operations routine. template -- cgit v1.2.3