aboutsummaryrefslogtreecommitdiff
path: root/libcxx/include/set
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx/include/set')
-rw-r--r--libcxx/include/set98
1 files changed, 60 insertions, 38 deletions
diff --git a/libcxx/include/set b/libcxx/include/set
index d58455bfe219..21ec8435dd84 100644
--- a/libcxx/include/set
+++ b/libcxx/include/set
@@ -154,10 +154,14 @@ 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
+
+ bool contains(const key_type& x) const; // C++20
+ template<class K> bool contains(const K& x) const; // C++20
+
iterator lower_bound(const key_type& k);
const_iterator lower_bound(const key_type& k) const;
template<typename K>
@@ -355,10 +359,14 @@ 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
+
+ bool contains(const key_type& x) const; // C++20
+ template<class K> bool contains(const K& x) const; // C++20
+
iterator lower_bound(const key_type& k);
const_iterator lower_bound(const key_type& k) const;
template<typename K>
@@ -426,9 +434,15 @@ erase_if(multiset<Key, Compare, Allocator>& c, Predicate pred); // C++20
*/
#include <__config>
-#include <__tree>
+#include <__debug>
+#include <__functional/is_transparent.h>
#include <__node_handle>
+#include <__tree>
+#include <__utility/forward.h>
+#include <compare>
#include <functional>
+#include <initializer_list>
+#include <iterator> // __libcpp_erase_if_container
#include <version>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -450,7 +464,7 @@ public:
typedef key_type value_type;
typedef _Compare key_compare;
typedef key_compare value_compare;
- typedef typename __identity<_Allocator>::type allocator_type;
+ typedef __identity_t<_Allocator> allocator_type;
typedef value_type& reference;
typedef const value_type& const_reference;
@@ -546,7 +560,7 @@ public:
set(set&& __s)
_NOEXCEPT_(is_nothrow_move_constructible<__base>::value)
: __tree_(_VSTD::move(__s.__tree_)) {}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
explicit set(const allocator_type& __a)
@@ -597,7 +611,7 @@ public:
__tree_ = _VSTD::move(__s.__tree_);
return *this;
}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
~set() {
@@ -652,7 +666,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
iterator emplace_hint(const_iterator __p, _Args&&... __args)
{return __tree_.__emplace_hint_unique(__p, _VSTD::forward<_Args>(__args)...);}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
pair<iterator,bool> insert(const value_type& __v)
@@ -681,7 +695,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
void insert(initializer_list<value_type> __il)
{insert(__il.begin(), __il.end());}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
iterator erase(const_iterator __p) {return __tree_.erase(__p);}
@@ -795,6 +809,10 @@ public:
#if _LIBCPP_STD_VER > 17
_LIBCPP_INLINE_VISIBILITY
bool contains(const key_type& __k) const {return find(__k) != end();}
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type
+ contains(const _K2& __k) const { return find(__k) != end(); }
#endif // _LIBCPP_STD_VER > 17
_LIBCPP_INLINE_VISIBILITY
@@ -852,12 +870,12 @@ public:
#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
template<class _InputIterator,
- class _Compare = less<typename iterator_traits<_InputIterator>::value_type>,
- class _Allocator = allocator<typename iterator_traits<_InputIterator>::value_type>,
+ class _Compare = less<__iter_value_type<_InputIterator>>,
+ class _Allocator = allocator<__iter_value_type<_InputIterator>>,
class = _EnableIf<__is_allocator<_Allocator>::value, void>,
class = _EnableIf<!__is_allocator<_Compare>::value, void>>
set(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator())
- -> set<typename iterator_traits<_InputIterator>::value_type, _Compare, _Allocator>;
+ -> set<__iter_value_type<_InputIterator>, _Compare, _Allocator>;
template<class _Key, class _Compare = less<_Key>,
class _Allocator = allocator<_Key>,
@@ -869,8 +887,8 @@ set(initializer_list<_Key>, _Compare = _Compare(), _Allocator = _Allocator())
template<class _InputIterator, class _Allocator,
class = _EnableIf<__is_allocator<_Allocator>::value, void>>
set(_InputIterator, _InputIterator, _Allocator)
- -> set<typename iterator_traits<_InputIterator>::value_type,
- less<typename iterator_traits<_InputIterator>::value_type>, _Allocator>;
+ -> set<__iter_value_type<_InputIterator>,
+ less<__iter_value_type<_InputIterator>>, _Allocator>;
template<class _Key, class _Allocator,
class = _EnableIf<__is_allocator<_Allocator>::value, void>>
@@ -892,7 +910,7 @@ set<_Key, _Compare, _Allocator>::set(set&& __s, const allocator_type& __a)
}
}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
template <class _Key, class _Compare, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
@@ -964,7 +982,7 @@ template <class _Key, class _Compare, class _Allocator, class _Predicate>
inline _LIBCPP_INLINE_VISIBILITY
typename set<_Key, _Compare, _Allocator>::size_type
erase_if(set<_Key, _Compare, _Allocator>& __c, _Predicate __pred) {
- return __libcpp_erase_if_container(__c, __pred);
+ return _VSTD::__libcpp_erase_if_container(__c, __pred);
}
#endif
@@ -974,11 +992,11 @@ class _LIBCPP_TEMPLATE_VIS multiset
{
public:
// types:
- typedef _Key key_type;
+ typedef _Key key_type;
typedef key_type value_type;
- typedef _Compare key_compare;
+ typedef _Compare key_compare;
typedef key_compare value_compare;
- typedef typename __identity<_Allocator>::type allocator_type;
+ typedef __identity_t<_Allocator> allocator_type;
typedef value_type& reference;
typedef const value_type& const_reference;
@@ -1077,7 +1095,7 @@ public:
: __tree_(_VSTD::move(__s.__tree_)) {}
multiset(multiset&& __s, const allocator_type& __a);
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
explicit multiset(const allocator_type& __a)
: __tree_(__a) {}
@@ -1124,7 +1142,7 @@ public:
__tree_ = _VSTD::move(__s.__tree_);
return *this;
}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
~multiset() {
@@ -1179,7 +1197,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
iterator emplace_hint(const_iterator __p, _Args&&... __args)
{return __tree_.__emplace_hint_multi(__p, _VSTD::forward<_Args>(__args)...);}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
iterator insert(const value_type& __v)
@@ -1208,7 +1226,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
void insert(initializer_list<value_type> __il)
{insert(__il.begin(), __il.end());}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
iterator erase(const_iterator __p) {return __tree_.erase(__p);}
@@ -1301,11 +1319,11 @@ public:
#if _LIBCPP_STD_VER > 11
template <typename _K2>
_LIBCPP_INLINE_VISIBILITY
- typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,iterator>::type
+ typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type
find(const _K2& __k) {return __tree_.find(__k);}
template <typename _K2>
_LIBCPP_INLINE_VISIBILITY
- typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,const_iterator>::type
+ typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
find(const _K2& __k) const {return __tree_.find(__k);}
#endif
@@ -1322,6 +1340,10 @@ public:
#if _LIBCPP_STD_VER > 17
_LIBCPP_INLINE_VISIBILITY
bool contains(const key_type& __k) const {return find(__k) != end();}
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type
+ contains(const _K2& __k) const { return find(__k) != end(); }
#endif // _LIBCPP_STD_VER > 17
_LIBCPP_INLINE_VISIBILITY
@@ -1333,12 +1355,12 @@ public:
#if _LIBCPP_STD_VER > 11
template <typename _K2>
_LIBCPP_INLINE_VISIBILITY
- typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,iterator>::type
+ typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type
lower_bound(const _K2& __k) {return __tree_.lower_bound(__k);}
template <typename _K2>
_LIBCPP_INLINE_VISIBILITY
- typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,const_iterator>::type
+ typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);}
#endif
@@ -1351,11 +1373,11 @@ public:
#if _LIBCPP_STD_VER > 11
template <typename _K2>
_LIBCPP_INLINE_VISIBILITY
- typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,iterator>::type
+ typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type
upper_bound(const _K2& __k) {return __tree_.upper_bound(__k);}
template <typename _K2>
_LIBCPP_INLINE_VISIBILITY
- typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,const_iterator>::type
+ typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);}
#endif
@@ -1368,23 +1390,23 @@ public:
#if _LIBCPP_STD_VER > 11
template <typename _K2>
_LIBCPP_INLINE_VISIBILITY
- typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,pair<iterator,iterator>>::type
+ typename enable_if<__is_transparent<_Compare, _K2>::value,pair<iterator,iterator>>::type
equal_range(const _K2& __k) {return __tree_.__equal_range_multi(__k);}
template <typename _K2>
_LIBCPP_INLINE_VISIBILITY
- typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,pair<const_iterator,const_iterator>>::type
+ typename enable_if<__is_transparent<_Compare, _K2>::value,pair<const_iterator,const_iterator>>::type
equal_range(const _K2& __k) const {return __tree_.__equal_range_multi(__k);}
#endif
};
#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
template<class _InputIterator,
- class _Compare = less<typename iterator_traits<_InputIterator>::value_type>,
- class _Allocator = allocator<typename iterator_traits<_InputIterator>::value_type>,
+ class _Compare = less<__iter_value_type<_InputIterator>>,
+ class _Allocator = allocator<__iter_value_type<_InputIterator>>,
class = _EnableIf<__is_allocator<_Allocator>::value, void>,
class = _EnableIf<!__is_allocator<_Compare>::value, void>>
multiset(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator())
- -> multiset<typename iterator_traits<_InputIterator>::value_type, _Compare, _Allocator>;
+ -> multiset<__iter_value_type<_InputIterator>, _Compare, _Allocator>;
template<class _Key, class _Compare = less<_Key>,
class _Allocator = allocator<_Key>,
@@ -1396,8 +1418,8 @@ multiset(initializer_list<_Key>, _Compare = _Compare(), _Allocator = _Allocator(
template<class _InputIterator, class _Allocator,
class = _EnableIf<__is_allocator<_Allocator>::value, void>>
multiset(_InputIterator, _InputIterator, _Allocator)
- -> multiset<typename iterator_traits<_InputIterator>::value_type,
- less<typename iterator_traits<_InputIterator>::value_type>, _Allocator>;
+ -> multiset<__iter_value_type<_InputIterator>,
+ less<__iter_value_type<_InputIterator>>, _Allocator>;
template<class _Key, class _Allocator,
class = _EnableIf<__is_allocator<_Allocator>::value, void>>
@@ -1419,7 +1441,7 @@ multiset<_Key, _Compare, _Allocator>::multiset(multiset&& __s, const allocator_t
}
}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
template <class _Key, class _Compare, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
@@ -1490,10 +1512,10 @@ template <class _Key, class _Compare, class _Allocator, class _Predicate>
inline _LIBCPP_INLINE_VISIBILITY
typename multiset<_Key, _Compare, _Allocator>::size_type
erase_if(multiset<_Key, _Compare, _Allocator>& __c, _Predicate __pred) {
- return __libcpp_erase_if_container(__c, __pred);
+ return _VSTD::__libcpp_erase_if_container(__c, __pred);
}
#endif
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_SET
+#endif // _LIBCPP_SET