60 #if __cplusplus >= 201103L
64 namespace std _GLIBCXX_VISIBILITY(default)
66 _GLIBCXX_BEGIN_NAMESPACE_VERSION
67 _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
69 template<
typename _Key,
typename _Compare,
typename _Alloc>
92 template<
typename _Key,
typename _Compare = std::less<_Key>,
93 typename _Alloc = std::allocator<_Key> >
96 #ifdef _GLIBCXX_CONCEPT_CHECKS
98 typedef typename _Alloc::value_type _Alloc_value_type;
99 # if __cplusplus < 201103L
100 __glibcxx_class_requires(_Key, _SGIAssignableConcept)
102 __glibcxx_class_requires4(_Compare,
bool, _Key, _Key,
103 _BinaryFunctionConcept)
104 __glibcxx_class_requires2(_Key, _Alloc_value_type, _SameTypeConcept)
107 #if __cplusplus >= 201103L
108 static_assert(
is_same<
typename remove_cv<_Key>::type, _Key>::value,
109 "std::set must have a non-const, non-volatile value_type");
110 # if __cplusplus > 201703L || defined __STRICT_ANSI__
112 "std::set must have the same value_type as its allocator");
129 rebind<_Key>::other _Key_alloc_type;
131 typedef _Rb_tree<key_type, value_type, _Identity<value_type>,
140 typedef typename _Alloc_traits::pointer
pointer;
147 typedef typename _Rep_type::const_iterator
iterator;
155 #if __cplusplus > 201402L
164 #if __cplusplus < 201103L
176 set(
const _Compare& __comp,
178 : _M_t(__comp, _Key_alloc_type(__a)) { }
190 template<
typename _InputIterator>
191 set(_InputIterator __first, _InputIterator __last)
193 { _M_t._M_insert_range_unique(__first, __last); }
207 template<
typename _InputIterator>
208 set(_InputIterator __first, _InputIterator __last,
209 const _Compare& __comp,
211 : _M_t(__comp, _Key_alloc_type(__a))
212 { _M_t._M_insert_range_unique(__first, __last); }
219 #if __cplusplus < 201103L
244 const _Compare& __comp = _Compare(),
246 : _M_t(__comp, _Key_alloc_type(__a))
247 { _M_t._M_insert_range_unique(__l.begin(), __l.end()); }
252 : _M_t(_Key_alloc_type(__a)) { }
255 set(
const set& __x,
const __type_identity_t<allocator_type>& __a)
256 : _M_t(__x._M_t, _Key_alloc_type(__a)) { }
259 set(
set&& __x,
const __type_identity_t<allocator_type>& __a)
261 && _Alloc_traits::_S_always_equal())
262 : _M_t(
std::
move(__x._M_t), _Key_alloc_type(__a)) { }
266 : _M_t(_Key_alloc_type(__a))
267 { _M_t._M_insert_range_unique(__l.begin(), __l.end()); }
270 template<
typename _InputIterator>
271 set(_InputIterator __first, _InputIterator __last,
273 : _M_t(_Key_alloc_type(__a))
274 { _M_t._M_insert_range_unique(__first, __last); }
289 #if __cplusplus < 201103L
318 _M_t._M_assign_unique(__l.begin(), __l.end());
328 {
return _M_t.key_comp(); }
332 {
return _M_t.key_comp(); }
345 {
return _M_t.begin(); }
353 end() const _GLIBCXX_NOEXCEPT
354 {
return _M_t.end(); }
363 {
return _M_t.rbegin(); }
372 {
return _M_t.rend(); }
374 #if __cplusplus >= 201103L
382 {
return _M_t.begin(); }
391 {
return _M_t.end(); }
400 {
return _M_t.rbegin(); }
409 {
return _M_t.rend(); }
413 _GLIBCXX_NODISCARD
bool
415 {
return _M_t.empty(); }
420 {
return _M_t.size(); }
425 {
return _M_t.max_size(); }
442 _GLIBCXX_NOEXCEPT_IF(__is_nothrow_swappable<_Compare>::value)
443 { _M_t.swap(__x._M_t); }
446 #if __cplusplus >= 201103L
460 template<
typename... _Args>
463 {
return _M_t._M_emplace_unique(std::forward<_Args>(__args)...); }
486 template<
typename... _Args>
490 return _M_t._M_emplace_hint_unique(__pos,
491 std::forward<_Args>(__args)...);
512 _M_t._M_insert_unique(__x);
516 #if __cplusplus >= 201103L
547 {
return _M_t._M_insert_unique_(__position, __x); }
549 #if __cplusplus >= 201103L
552 {
return _M_t._M_insert_unique_(__position,
std::move(__x)); }
564 template<
typename _InputIterator>
566 insert(_InputIterator __first, _InputIterator __last)
567 { _M_t._M_insert_range_unique(__first, __last); }
569 #if __cplusplus >= 201103L
579 { this->
insert(__l.begin(), __l.end()); }
582 #if __cplusplus > 201402L
587 __glibcxx_assert(__pos !=
end());
588 return _M_t.extract(__pos);
594 {
return _M_t.extract(__x); }
599 {
return _M_t._M_reinsert_node_unique(
std::move(__nh)); }
604 {
return _M_t._M_reinsert_node_hint_unique(__hint,
std::move(__nh)); }
606 template<
typename,
typename>
607 friend struct std::_Rb_tree_merge_helper;
609 template<
typename _Compare1>
613 using _Merge_helper = _Rb_tree_merge_helper<set, _Compare1>;
614 _M_t._M_merge_unique(_Merge_helper::_S_get_tree(__source));
617 template<
typename _Compare1>
619 merge(set<_Key, _Compare1, _Alloc>&& __source)
622 template<
typename _Compare1>
624 merge(multiset<_Key, _Compare1, _Alloc>& __source)
626 using _Merge_helper = _Rb_tree_merge_helper<set, _Compare1>;
627 _M_t._M_merge_unique(_Merge_helper::_S_get_tree(__source));
630 template<
typename _Compare1>
632 merge(multiset<_Key, _Compare1, _Alloc>&& __source)
636 #if __cplusplus >= 201103L
652 _GLIBCXX_ABI_TAG_CXX11
655 {
return _M_t.erase(__position); }
669 { _M_t.erase(__position); }
685 {
return _M_t.erase(__x); }
687 #if __cplusplus >= 201103L
704 _GLIBCXX_ABI_TAG_CXX11
707 {
return _M_t.erase(__first, __last); }
723 { _M_t.erase(__first, __last); }
749 {
return _M_t.find(__x) == _M_t.end() ? 0 : 1; }
751 #if __cplusplus > 201103L
752 template<
typename _Kt>
755 -> decltype(_M_t._M_count_tr(__x))
756 {
return _M_t._M_count_tr(__x); }
760 #if __cplusplus > 201703L
769 {
return _M_t.find(__x) != _M_t.end(); }
771 template<
typename _Kt>
774 -> decltype(_M_t._M_find_tr(__x),
void(),
true)
775 {
return _M_t._M_find_tr(__x) != _M_t.end(); }
795 {
return _M_t.find(__x); }
799 {
return _M_t.find(__x); }
801 #if __cplusplus > 201103L
802 template<
typename _Kt>
805 -> decltype(
iterator{_M_t._M_find_tr(__x)})
806 {
return iterator{_M_t._M_find_tr(__x)}; }
808 template<
typename _Kt>
830 {
return _M_t.lower_bound(__x); }
834 {
return _M_t.lower_bound(__x); }
836 #if __cplusplus > 201103L
837 template<
typename _Kt>
840 -> decltype(
iterator(_M_t._M_lower_bound_tr(__x)))
841 {
return iterator(_M_t._M_lower_bound_tr(__x)); }
843 template<
typename _Kt>
860 {
return _M_t.upper_bound(__x); }
864 {
return _M_t.upper_bound(__x); }
866 #if __cplusplus > 201103L
867 template<
typename _Kt>
870 -> decltype(
iterator(_M_t._M_upper_bound_tr(__x)))
871 {
return iterator(_M_t._M_upper_bound_tr(__x)); }
873 template<
typename _Kt>
876 -> decltype(
iterator(_M_t._M_upper_bound_tr(__x)))
899 {
return _M_t.equal_range(__x); }
903 {
return _M_t.equal_range(__x); }
905 #if __cplusplus > 201103L
906 template<
typename _Kt>
912 template<
typename _Kt>
920 template<
typename _K1,
typename _C1,
typename _A1>
924 #if __cpp_lib_three_way_comparison
925 template<
typename _K1,
typename _C1,
typename _A1>
926 friend __detail::__synth3way_t<_K1>
929 template<
typename _K1,
typename _C1,
typename _A1>
935 #if __cpp_deduction_guides >= 201606
937 template<
typename _InputIterator,
939 less<typename iterator_traits<_InputIterator>::value_type>,
940 typename _Allocator =
941 allocator<typename iterator_traits<_InputIterator>::value_type>,
942 typename = _RequireInputIter<_InputIterator>,
943 typename = _RequireNotAllocator<_Compare>,
944 typename = _RequireAllocator<_Allocator>>
945 set(_InputIterator, _InputIterator,
946 _Compare = _Compare(), _Allocator = _Allocator())
948 _Compare, _Allocator>;
950 template<
typename _Key,
typename _Compare = less<_Key>,
951 typename _Allocator = allocator<_Key>,
952 typename = _RequireNotAllocator<_Compare>,
953 typename = _RequireAllocator<_Allocator>>
954 set(initializer_list<_Key>,
955 _Compare = _Compare(), _Allocator = _Allocator())
956 -> set<_Key, _Compare, _Allocator>;
958 template<
typename _InputIterator,
typename _Allocator,
959 typename = _RequireInputIter<_InputIterator>,
960 typename = _RequireAllocator<_Allocator>>
961 set(_InputIterator, _InputIterator, _Allocator)
963 less<typename iterator_traits<_InputIterator>::value_type>,
966 template<
typename _Key,
typename _Allocator,
967 typename = _RequireAllocator<_Allocator>>
968 set(initializer_list<_Key>, _Allocator)
969 -> set<_Key, less<_Key>, _Allocator>;
971 #endif // deduction guides
983 template<
typename _Key,
typename _Compare,
typename _Alloc>
987 {
return __x._M_t == __y._M_t; }
989 #if __cpp_lib_three_way_comparison
1004 template<
typename _Key,
typename _Compare,
typename _Alloc>
1005 inline __detail::__synth3way_t<_Key>
1006 operator<=>(
const set<_Key, _Compare, _Alloc>& __x,
1007 const set<_Key, _Compare, _Alloc>& __y)
1008 {
return __x._M_t <=> __y._M_t; }
1021 template<
typename _Key,
typename _Compare,
typename _Alloc>
1025 {
return __x._M_t < __y._M_t; }
1028 template<
typename _Key,
typename _Compare,
typename _Alloc>
1032 {
return !(__x == __y); }
1035 template<
typename _Key,
typename _Compare,
typename _Alloc>
1039 {
return __y < __x; }
1042 template<
typename _Key,
typename _Compare,
typename _Alloc>
1046 {
return !(__y < __x); }
1049 template<
typename _Key,
typename _Compare,
typename _Alloc>
1053 {
return !(__x < __y); }
1054 #endif // three-way comparison
1057 template<
typename _Key,
typename _Compare,
typename _Alloc>
1060 _GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y)))
1063 _GLIBCXX_END_NAMESPACE_CONTAINER
1065 #if __cplusplus > 201402L
1067 template<
typename _Val,
typename _Cmp1,
typename _Alloc,
typename _Cmp2>
1069 _Rb_tree_merge_helper<_GLIBCXX_STD_C::set<_Val, _Cmp1, _Alloc>, _Cmp2>
1072 friend class _GLIBCXX_STD_C::set<_Val, _Cmp1, _Alloc>;
1075 _S_get_tree(_GLIBCXX_STD_C::set<_Val, _Cmp2, _Alloc>& __set)
1076 {
return __set._M_t; }
1079 _S_get_tree(_GLIBCXX_STD_C::multiset<_Val, _Cmp2, _Alloc>& __set)
1080 {
return __set._M_t; }
1084 _GLIBCXX_END_NAMESPACE_VERSION