diff options
| author | Zoe Carver <z.zoelec2@gmail.com> | 2019-07-16 03:21:01 +0000 |
|---|---|---|
| committer | Zoe Carver <z.zoelec2@gmail.com> | 2019-07-16 03:21:01 +0000 |
| commit | a17b1aed6ab205515adc31d19e953635e563e5c4 (patch) | |
| tree | 68656c7cb5e185ff398101318e83548e81a72c40 /libcxx/include/set | |
| parent | e7e8789a632f3dcd029b0f78230e61773bdb3586 (diff) | |
| download | bcm5719-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/set')
| -rw-r--r-- | libcxx/include/set | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/libcxx/include/set b/libcxx/include/set index 79e8f29f0b9..70ab4d37add 100644 --- a/libcxx/include/set +++ b/libcxx/include/set @@ -155,9 +155,9 @@ public: template<typename K> const_iterator find(const K& x) const; // C++14 template<typename K> - size_type count(const K& x) const; // C++14 - + size_type count(const K& x) const; // C++14 size_type count(const key_type& k) const; + bool contains(const key_type& x) const; // C++20 iterator lower_bound(const key_type& k); const_iterator lower_bound(const key_type& k) const; template<typename K> @@ -354,8 +354,10 @@ public: iterator find(const K& x); template<typename K> const_iterator find(const K& x) const; // C++14 - + template<typename K> + size_type count(const K& x) const; // C++14 size_type count(const key_type& k) const; + bool contains(const key_type& x) const; // C++20 iterator lower_bound(const key_type& k); const_iterator lower_bound(const key_type& k) const; template<typename K> @@ -787,6 +789,12 @@ public: typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type count(const _K2& __k) const {return __tree_.__count_multi(__k);} #endif + +#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 iterator lower_bound(const key_type& __k) {return __tree_.lower_bound(__k);} @@ -1307,6 +1315,11 @@ public: count(const _K2& __k) const {return __tree_.__count_multi(__k);} #endif +#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 iterator lower_bound(const key_type& __k) {return __tree_.lower_bound(__k);} |

