summaryrefslogtreecommitdiffstats
path: root/libcxx/include/unordered_set
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_set
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_set')
-rw-r--r--libcxx/include/unordered_set10
1 files changed, 10 insertions, 0 deletions
diff --git a/libcxx/include/unordered_set b/libcxx/include/unordered_set
index 4a9f0309327..68f777a4ea3 100644
--- a/libcxx/include/unordered_set
+++ b/libcxx/include/unordered_set
@@ -146,6 +146,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;
@@ -310,6 +311,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;
@@ -677,6 +679,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);}
@@ -1304,6 +1310,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