]> granicus.if.org Git - icu/commitdiff
ICU-20973 Manually resolve C++20 reversed argument order ambiguity.
authorFredrik Roubert <roubert@google.com>
Wed, 4 Aug 2021 14:25:34 +0000 (16:25 +0200)
committerFredrik Roubert <fredrik@roubert.name>
Mon, 16 Aug 2021 22:35:00 +0000 (00:35 +0200)
icu4c/source/common/unifiedcache.h
icu4c/source/i18n/unicode/tmutfmt.h

index 0b32426ebf40f6b2c9479dd13f07c463252b3d00..6c88c08762a45b834c4649ce429e112dd3b7b610 100644 (file)
@@ -13,6 +13,8 @@
 #ifndef __UNIFIED_CACHE_H__
 #define __UNIFIED_CACHE_H__
 
+#include <type_traits>
+
 #include "utypeinfo.h"  // for 'typeid' to work
 
 #include "unicode/uobject.h"
@@ -158,6 +160,17 @@ class LocaleCacheKey : public CacheKey<T> {
                static_cast<const LocaleCacheKey<T> *>(&other);
        return fLoc == fOther->fLoc;
    }
+
+#if defined(__cpp_impl_three_way_comparison) && \
+       __cpp_impl_three_way_comparison >= 201711
+    // Manually resolve C++20 reversed argument order ambiguity.
+    template <typename U,
+              typename = typename std::enable_if_t<!std::is_same_v<T, U>>>
+    inline bool operator==(const LocaleCacheKey<U>& other) const {
+        return operator==(static_cast<const CacheKeyBase&>(other));
+    }
+#endif
+
    virtual CacheKeyBase *clone() const {
        return new LocaleCacheKey<T>(*this);
    }
index b1be87c30d4ded55fa7c7c11c4683de83a0a8a44..a3b0c53bd22ed2f4f54c32c0fd3f4d1bd51cd2fd 100644 (file)
@@ -143,6 +143,14 @@ public:
      */
     bool operator!=(const Format& other) const;
 
+#if defined(__cpp_impl_three_way_comparison) && \
+       __cpp_impl_three_way_comparison >= 201711
+    // Manually resolve C++20 reversed argument order ambiguity.
+    inline bool operator!=(const TimeUnitFormat& other) const {
+        return operator!=(static_cast<const Format&>(other));
+    }
+#endif
+
     /**
      * Set the locale used for formatting or parsing.
      * @param locale  the locale to be set