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>
94 template<
typename _Key,
typename _Compare = std::less<_Key>,
95 typename _Alloc = std::allocator<_Key> >
98 #ifdef _GLIBCXX_CONCEPT_CHECKS
100 typedef typename _Alloc::value_type _Alloc_value_type;
101 # if __cplusplus < 201103L
102 __glibcxx_class_requires(_Key, _SGIAssignableConcept)
104 __glibcxx_class_requires4(_Compare,
bool, _Key, _Key,
105 _BinaryFunctionConcept)
106 __glibcxx_class_requires2(_Key, _Alloc_value_type, _SameTypeConcept)
109 #if __cplusplus >= 201103L
110 static_assert(is_same<
typename remove_cv<_Key>::type, _Key>::value,
111 "std::set must have a non-const, non-volatile value_type");
112 # if __cplusplus > 201703L || defined __STRICT_ANSI__
114 "std::set must have the same value_type as its allocator");
131 rebind<_Key>::other _Key_alloc_type;
133 typedef _Rb_tree<key_type, value_type, _Identity<value_type>,
142 typedef typename _Alloc_traits::pointer
pointer;
149 typedef typename _Rep_type::const_iterator
iterator;
157 #if __cplusplus > 201402L
166 #if __cplusplus < 201103L
178 set(
const _Compare& __comp,
180 : _M_t(__comp, _Key_alloc_type(__a)) { }
192 template<
typename _InputIterator>
193 set(_InputIterator __first, _InputIterator __last)
195 { _M_t._M_insert_range_unique(__first, __last); }
209 template<
typename _InputIterator>
210 set(_InputIterator __first, _InputIterator __last,
211 const _Compare& __comp,
213 : _M_t(__comp, _Key_alloc_type(__a))
214 { _M_t._M_insert_range_unique(__first, __last); }
221 #if __cplusplus < 201103L
225 set(
const set&) =
default;
246 const _Compare& __comp = _Compare(),
248 : _M_t(__comp, _Key_alloc_type(__a))
249 { _M_t._M_insert_range_unique(__l.begin(), __l.end()); }
254 : _M_t(_Key_alloc_type(__a)) { }
257 set(
const set& __x,
const __type_identity_t<allocator_type>& __a)
258 : _M_t(__x._M_t, _Key_alloc_type(__a)) { }
261 set(
set&& __x,
const __type_identity_t<allocator_type>& __a)
263 && _Alloc_traits::_S_always_equal())
264 : _M_t(
std::
move(__x._M_t), _Key_alloc_type(__a)) { }
268 : _M_t(_Key_alloc_type(__a))
269 { _M_t._M_insert_range_unique(__l.begin(), __l.end()); }
272 template<
typename _InputIterator>
273 set(_InputIterator __first, _InputIterator __last,
275 : _M_t(_Key_alloc_type(__a))
276 { _M_t._M_insert_range_unique(__first, __last); }
291 #if __cplusplus < 201103L
320 _M_t._M_assign_unique(__l.begin(), __l.end());
330 {
return _M_t.key_comp(); }
334 {
return _M_t.key_comp(); }
347 {
return _M_t.begin(); }
355 end() const _GLIBCXX_NOEXCEPT
356 {
return _M_t.end(); }
365 {
return _M_t.rbegin(); }
374 {
return _M_t.rend(); }
376 #if __cplusplus >= 201103L
384 {
return _M_t.begin(); }
393 {
return _M_t.end(); }
402 {
return _M_t.rbegin(); }
411 {
return _M_t.rend(); }
415 _GLIBCXX_NODISCARD
bool
417 {
return _M_t.empty(); }
422 {
return _M_t.size(); }
427 {
return _M_t.max_size(); }
444 _GLIBCXX_NOEXCEPT_IF(__is_nothrow_swappable<_Compare>::value)
445 { _M_t.swap(__x._M_t); }
448 #if __cplusplus >= 201103L
462 template<
typename... _Args>
465 {
return _M_t._M_emplace_unique(std::forward<_Args>(__args)...); }
488 template<
typename... _Args>
492 return _M_t._M_emplace_hint_unique(__pos,
493 std::forward<_Args>(__args)...);
514 _M_t._M_insert_unique(__x);
518 #if __cplusplus >= 201103L
549 {
return _M_t._M_insert_unique_(__position, __x); }
551 #if __cplusplus >= 201103L
554 {
return _M_t._M_insert_unique_(__position,
std::move(__x)); }
566 template<
typename _InputIterator>
568 insert(_InputIterator __first, _InputIterator __last)
569 { _M_t._M_insert_range_unique(__first, __last); }
571 #if __cplusplus >= 201103L
581 { this->
insert(__l.begin(), __l.end()); }
584 #if __cplusplus > 201402L
589 __glibcxx_assert(__pos !=
end());
590 return _M_t.extract(__pos);
596 {
return _M_t.extract(__x); }
601 {
return _M_t._M_reinsert_node_unique(
std::move(__nh)); }
606 {
return _M_t._M_reinsert_node_hint_unique(__hint,
std::move(__nh)); }
608 template<
typename,
typename>
609 friend struct std::_Rb_tree_merge_helper;
611 template<
typename _Compare1>
615 using _Merge_helper = _Rb_tree_merge_helper<set, _Compare1>;
616 _M_t._M_merge_unique(_Merge_helper::_S_get_tree(__source));
619 template<
typename _Compare1>
621 merge(set<_Key, _Compare1, _Alloc>&& __source)
624 template<
typename _Compare1>
626 merge(multiset<_Key, _Compare1, _Alloc>& __source)
628 using _Merge_helper = _Rb_tree_merge_helper<set, _Compare1>;
629 _M_t._M_merge_unique(_Merge_helper::_S_get_tree(__source));
632 template<
typename _Compare1>
634 merge(multiset<_Key, _Compare1, _Alloc>&& __source)
638 #if __cplusplus >= 201103L
654 _GLIBCXX_ABI_TAG_CXX11
657 {
return _M_t.erase(__position); }
671 { _M_t.erase(__position); }
687 {
return _M_t.erase(__x); }
689 #if __cplusplus >= 201103L
706 _GLIBCXX_ABI_TAG_CXX11
709 {
return _M_t.erase(__first, __last); }
725 { _M_t.erase(__first, __last); }
751 {
return _M_t.find(__x) == _M_t.end() ? 0 : 1; }
753 #if __cplusplus > 201103L
754 template<
typename _Kt>
757 -> decltype(_M_t._M_count_tr(__x))
758 {
return _M_t._M_count_tr(__x); }
762 #if __cplusplus > 201703L
771 {
return _M_t.find(__x) != _M_t.end(); }
773 template<
typename _Kt>
776 -> decltype(_M_t._M_find_tr(__x),
void(),
true)
777 {
return _M_t._M_find_tr(__x) != _M_t.end(); }
797 {
return _M_t.find(__x); }
801 {
return _M_t.find(__x); }
803 #if __cplusplus > 201103L
804 template<
typename _Kt>
807 -> decltype(
iterator{_M_t._M_find_tr(__x)})
808 {
return iterator{_M_t._M_find_tr(__x)}; }
810 template<
typename _Kt>
832 {
return _M_t.lower_bound(__x); }
836 {
return _M_t.lower_bound(__x); }
838 #if __cplusplus > 201103L
839 template<
typename _Kt>
842 -> decltype(
iterator(_M_t._M_lower_bound_tr(__x)))
843 {
return iterator(_M_t._M_lower_bound_tr(__x)); }
845 template<
typename _Kt>
862 {
return _M_t.upper_bound(__x); }
866 {
return _M_t.upper_bound(__x); }
868 #if __cplusplus > 201103L
869 template<
typename _Kt>
872 -> decltype(
iterator(_M_t._M_upper_bound_tr(__x)))
873 {
return iterator(_M_t._M_upper_bound_tr(__x)); }
875 template<
typename _Kt>
878 -> decltype(
iterator(_M_t._M_upper_bound_tr(__x)))
901 {
return _M_t.equal_range(__x); }
905 {
return _M_t.equal_range(__x); }
907 #if __cplusplus > 201103L
908 template<
typename _Kt>
914 template<
typename _Kt>
922 template<
typename _K1,
typename _C1,
typename _A1>
926 #if __cpp_lib_three_way_comparison
927 template<
typename _K1,
typename _C1,
typename _A1>
928 friend __detail::__synth3way_t<_K1>
931 template<
typename _K1,
typename _C1,
typename _A1>
937 #if __cpp_deduction_guides >= 201606
939 template<
typename _InputIterator,
941 less<typename iterator_traits<_InputIterator>::value_type>,
942 typename _Allocator =
943 allocator<typename iterator_traits<_InputIterator>::value_type>,
944 typename = _RequireInputIter<_InputIterator>,
945 typename = _RequireNotAllocator<_Compare>,
946 typename = _RequireAllocator<_Allocator>>
947 set(_InputIterator, _InputIterator,
948 _Compare = _Compare(), _Allocator = _Allocator())
950 _Compare, _Allocator>;
952 template<
typename _Key,
typename _Compare = less<_Key>,
953 typename _Allocator = allocator<_Key>,
954 typename = _RequireNotAllocator<_Compare>,
955 typename = _RequireAllocator<_Allocator>>
956 set(initializer_list<_Key>,
957 _Compare = _Compare(), _Allocator = _Allocator())
958 -> set<_Key, _Compare, _Allocator>;
960 template<
typename _InputIterator,
typename _Allocator,
961 typename = _RequireInputIter<_InputIterator>,
962 typename = _RequireAllocator<_Allocator>>
963 set(_InputIterator, _InputIterator, _Allocator)
965 less<typename iterator_traits<_InputIterator>::value_type>,
968 template<
typename _Key,
typename _Allocator,
969 typename = _RequireAllocator<_Allocator>>
970 set(initializer_list<_Key>, _Allocator)
971 -> set<_Key, less<_Key>, _Allocator>;
973 #endif // deduction guides
985 template<
typename _Key,
typename _Compare,
typename _Alloc>
989 {
return __x._M_t == __y._M_t; }
991 #if __cpp_lib_three_way_comparison
1006 template<
typename _Key,
typename _Compare,
typename _Alloc>
1007 inline __detail::__synth3way_t<_Key>
1008 operator<=>(
const set<_Key, _Compare, _Alloc>& __x,
1009 const set<_Key, _Compare, _Alloc>& __y)
1010 {
return __x._M_t <=> __y._M_t; }
1023 template<
typename _Key,
typename _Compare,
typename _Alloc>
1027 {
return __x._M_t < __y._M_t; }
1030 template<
typename _Key,
typename _Compare,
typename _Alloc>
1034 {
return !(__x == __y); }
1037 template<
typename _Key,
typename _Compare,
typename _Alloc>
1041 {
return __y < __x; }
1044 template<
typename _Key,
typename _Compare,
typename _Alloc>
1048 {
return !(__y < __x); }
1051 template<
typename _Key,
typename _Compare,
typename _Alloc>
1055 {
return !(__x < __y); }
1056 #endif // three-way comparison
1059 template<
typename _Key,
typename _Compare,
typename _Alloc>
1062 _GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y)))
1065 _GLIBCXX_END_NAMESPACE_CONTAINER
1067 #if __cplusplus > 201402L
1069 template<
typename _Val,
typename _Cmp1,
typename _Alloc,
typename _Cmp2>
1071 _Rb_tree_merge_helper<_GLIBCXX_STD_C::set<_Val, _Cmp1, _Alloc>, _Cmp2>
1074 friend class _GLIBCXX_STD_C::set<_Val, _Cmp1, _Alloc>;
1077 _S_get_tree(_GLIBCXX_STD_C::set<_Val, _Cmp2, _Alloc>& __set)
1078 {
return __set._M_t; }
1081 _S_get_tree(_GLIBCXX_STD_C::multiset<_Val, _Cmp2, _Alloc>& __set)
1082 {
return __set._M_t; }
1086 _GLIBCXX_END_NAMESPACE_VERSION