summaryrefslogtreecommitdiffstats
path: root/libcxx/include/unordered_map
diff options
context:
space:
mode:
authorZoe Carver <z.zoelec2@gmail.com>2019-07-16 03:21:01 +0000
committerZoe Carver <z.zoelec2@gmail.com>2019-07-16 03:21:01 +0000
commita17b1aed6ab205515adc31d19e953635e563e5c4 (patch)
tree68656c7cb5e185ff398101318e83548e81a72c40 /libcxx/include/unordered_map
parente7e8789a632f3dcd029b0f78230e61773bdb3586 (diff)
downloadbcm5719-llvm-a17b1aed6ab205515adc31d19e953635e563e5c4.tar.gz
bcm5719-llvm-a17b1aed6ab205515adc31d19e953635e563e5c4.zip
Add contains method to associative containers. This patch implements P0458R2, adding contains to map, multimap, unordered_map, unordered_multimap, set, multiset, unordered_set, and unordered_multiset.
llvm-svn: 366170
Diffstat (limited to 'libcxx/include/unordered_map')
-rw-r--r--libcxx/include/unordered_map10
1 files changed, 10 insertions, 0 deletions
diff --git a/libcxx/include/unordered_map b/libcxx/include/unordered_map
index 63aecc8bc0e..ad17f776c93 100644
--- a/libcxx/include/unordered_map
+++ b/libcxx/include/unordered_map
@@ -174,6 +174,7 @@ public:
iterator find(const key_type& k);
const_iterator find(const key_type& k) const;
size_type count(const key_type& k) const;
+ bool contains(const key_type& k) const; // C++20
pair<iterator, iterator> equal_range(const key_type& k);
pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
@@ -355,6 +356,7 @@ public:
iterator find(const key_type& k);
const_iterator find(const key_type& k) const;
size_type count(const key_type& k) const;
+ bool contains(const key_type& k) const; // C++20
pair<iterator, iterator> equal_range(const key_type& k);
pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
@@ -1278,6 +1280,10 @@ public:
const_iterator find(const key_type& __k) const {return __table_.find(__k);}
_LIBCPP_INLINE_VISIBILITY
size_type count(const key_type& __k) const {return __table_.__count_unique(__k);}
+ #if _LIBCPP_STD_VER > 17
+ _LIBCPP_INLINE_VISIBILITY
+ bool contains(const key_type& __k) const {return find(__k) != end();}
+ #endif // _LIBCPP_STD_VER > 17
_LIBCPP_INLINE_VISIBILITY
pair<iterator, iterator> equal_range(const key_type& __k)
{return __table_.__equal_range_unique(__k);}
@@ -2049,6 +2055,10 @@ public:
const_iterator find(const key_type& __k) const {return __table_.find(__k);}
_LIBCPP_INLINE_VISIBILITY
size_type count(const key_type& __k) const {return __table_.__count_multi(__k);}
+ #if _LIBCPP_STD_VER > 17
+ _LIBCPP_INLINE_VISIBILITY
+ bool contains(const key_type& __k) const {return find(__k) != end();}
+ #endif // _LIBCPP_STD_VER > 17
_LIBCPP_INLINE_VISIBILITY
pair<iterator, iterator> equal_range(const key_type& __k)
{return __table_.__equal_range_multi(__k);}
OpenPOWER on IntegriCloud