Fix bug 20740 - std::set/std::map don't support heterogeneous lookup for count(). Thanks to Jim Porter for the bug report
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@216353 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/map b/include/map
index 5534e40..5c3969a 100644
--- a/include/map
+++ b/include/map
@@ -159,7 +159,7 @@
template<typename K>
const_iterator find(const K& x) const; // C++14
template<typename K>
- size_type count(const K& x) const;
+ size_type count(const K& x) const; // C++14
size_type count(const key_type& k) const;
iterator lower_bound(const key_type& k);
@@ -353,7 +353,7 @@
template<typename K>
const_iterator find(const K& x) const; // C++14
template<typename K>
- size_type count(const K& x) const;
+ size_type count(const K& x) const; // C++14
size_type count(const key_type& k) const;
iterator lower_bound(const key_type& k);
@@ -1104,6 +1104,12 @@
_LIBCPP_INLINE_VISIBILITY
size_type count(const key_type& __k) const
{return __tree_.__count_unique(__k);}
+#if _LIBCPP_STD_VER > 11
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type
+ count(const _K2& __k) {return __tree_.__count_unique(__k);}
+#endif
_LIBCPP_INLINE_VISIBILITY
iterator lower_bound(const key_type& __k)
{return __tree_.lower_bound(__k);}
@@ -1834,6 +1840,12 @@
_LIBCPP_INLINE_VISIBILITY
size_type count(const key_type& __k) const
{return __tree_.__count_multi(__k);}
+#if _LIBCPP_STD_VER > 11
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type
+ count(const _K2& __k) {return __tree_.__count_multi(__k);}
+#endif
_LIBCPP_INLINE_VISIBILITY
iterator lower_bound(const key_type& __k)
{return __tree_.lower_bound(__k);}
diff --git a/include/set b/include/set
index b9e776d..22d794d 100644
--- a/include/set
+++ b/include/set
@@ -663,6 +663,12 @@
_LIBCPP_INLINE_VISIBILITY
size_type count(const key_type& __k) const
{return __tree_.__count_unique(__k);}
+#if _LIBCPP_STD_VER > 11
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type
+ count(const _K2& __k) {return __tree_.__count_unique(__k);}
+#endif
_LIBCPP_INLINE_VISIBILITY
iterator lower_bound(const key_type& __k)
{return __tree_.lower_bound(__k);}
@@ -1066,6 +1072,12 @@
_LIBCPP_INLINE_VISIBILITY
size_type count(const key_type& __k) const
{return __tree_.__count_multi(__k);}
+#if _LIBCPP_STD_VER > 11
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type
+ count(const _K2& __k) {return __tree_.__count_multi(__k);}
+#endif
_LIBCPP_INLINE_VISIBILITY
iterator lower_bound(const key_type& __k)