60#if __cplusplus >= 201103L
63#if __glibcxx_containers_ranges
67namespace std _GLIBCXX_VISIBILITY(default)
69_GLIBCXX_BEGIN_NAMESPACE_VERSION
70_GLIBCXX_BEGIN_NAMESPACE_CONTAINER
72 template<
typename _Key,
typename _Compare,
typename _Alloc>
97 template<
typename _Key,
typename _Compare = std::less<_Key>,
98 typename _Alloc = std::allocator<_Key> >
101#ifdef _GLIBCXX_CONCEPT_CHECKS
103 typedef typename _Alloc::value_type _Alloc_value_type;
104# if __cplusplus < 201103L
105 __glibcxx_class_requires(_Key, _SGIAssignableConcept)
107 __glibcxx_class_requires4(_Compare,
bool, _Key, _Key,
108 _BinaryFunctionConcept)
109 __glibcxx_class_requires2(_Key, _Alloc_value_type, _SameTypeConcept)
112#if __cplusplus >= 201103L
114 "std::set must have a non-const, non-volatile value_type");
115# if __cplusplus > 201703L || defined __STRICT_ANSI__
117 "std::set must have the same value_type as its allocator");
134 rebind<_Key>::other _Key_alloc_type;
136 typedef _Rb_tree<key_type, value_type, _Identity<value_type>,
145 typedef typename _Alloc_traits::pointer
pointer;
152 typedef typename _Rep_type::const_iterator
iterator;
160#ifdef __glibcxx_node_extract
161 using node_type =
typename _Rep_type::node_type;
162 using insert_return_type =
typename _Rep_type::insert_return_type;
169#if __cplusplus < 201103L
181 set(
const _Compare& __comp,
183 : _M_t(__comp, _Key_alloc_type(__a)) { }
195 template<
typename _InputIterator>
196 set(_InputIterator __first, _InputIterator __last)
198 { _M_t._M_insert_range_unique(__first, __last); }
212 template<
typename _InputIterator>
213 set(_InputIterator __first, _InputIterator __last,
214 const _Compare& __comp,
216 : _M_t(__comp, _Key_alloc_type(__a))
217 { _M_t._M_insert_range_unique(__first, __last); }
224#if __cplusplus < 201103L
249 const _Compare& __comp = _Compare(),
251 : _M_t(__comp, _Key_alloc_type(__a))
252 { _M_t._M_insert_range_unique(__l.begin(), __l.end()); }
257 : _M_t(_Key_alloc_type(__a)) { }
260 set(
const set& __x,
const __type_identity_t<allocator_type>& __a)
261 : _M_t(__x._M_t, _Key_alloc_type(__a)) { }
264 set(
set&& __x,
const __type_identity_t<allocator_type>& __a)
266 && _Alloc_traits::_S_always_equal())
267 : _M_t(
std::
move(__x._M_t), _Key_alloc_type(__a)) { }
271 : _M_t(_Key_alloc_type(__a))
272 { _M_t._M_insert_range_unique(__l.begin(), __l.end()); }
275 template<
typename _InputIterator>
276 set(_InputIterator __first, _InputIterator __last,
278 : _M_t(_Key_alloc_type(__a))
279 { _M_t._M_insert_range_unique(__first, __last); }
281#if __glibcxx_containers_ranges
286 template<__detail::__container_compatible_range<_Key> _Rg>
287 set(from_range_t, _Rg&& __rg,
288 const _Compare& __comp,
289 const _Alloc& __a = _Alloc())
290 : _M_t(__comp, _Key_alloc_type(__a))
294 template<__detail::__container_compatible_range<_Key> _Rg>
295 set(from_range_t, _Rg&& __rg,
const _Alloc& __a = _Alloc())
296 : _M_t(_Key_alloc_type(__a))
313#if __cplusplus < 201103L
342 _M_t._M_assign_unique(__l.begin(), __l.end());
352 {
return _M_t.key_comp(); }
356 {
return _M_t.key_comp(); }
369 {
return _M_t.begin(); }
377 end() const _GLIBCXX_NOEXCEPT
378 {
return _M_t.end(); }
387 {
return _M_t.rbegin(); }
396 {
return _M_t.rend(); }
398#if __cplusplus >= 201103L
406 {
return _M_t.begin(); }
415 {
return _M_t.end(); }
424 {
return _M_t.rbegin(); }
433 {
return _M_t.rend(); }
437 _GLIBCXX_NODISCARD
bool
439 {
return _M_t.empty(); }
444 {
return _M_t.size(); }
449 {
return _M_t.max_size(); }
466 _GLIBCXX_NOEXCEPT_IF(__is_nothrow_swappable<_Compare>::value)
467 { _M_t.swap(__x._M_t); }
470#if __cplusplus >= 201103L
484 template<
typename... _Args>
510 template<
typename... _Args>
514 return _M_t._M_emplace_hint_unique(__pos,
536 _M_t._M_insert_unique(__x);
540#if __cplusplus >= 201103L
571 {
return _M_t._M_insert_unique_(__position, __x); }
573#if __cplusplus >= 201103L
576 {
return _M_t._M_insert_unique_(__position,
std::move(__x)); }
588 template<
typename _InputIterator>
590 insert(_InputIterator __first, _InputIterator __last)
591 { _M_t._M_insert_range_unique(__first, __last); }
593#if __cplusplus >= 201103L
603 { this->
insert(__l.begin(), __l.end()); }
606#if __glibcxx_containers_ranges
613 template<__detail::__container_compatible_range<_Key> _Rg>
615 insert_range(_Rg&& __rg)
617 auto __first = ranges::begin(__rg);
618 const auto __last = ranges::end(__rg);
619 using _Rv = remove_cvref_t<ranges::range_reference_t<_Rg>>;
620 for (; __first != __last; ++__first)
621 if constexpr (is_same_v<_Rv, _Key>)
622 _M_t._M_insert_unique(*__first);
624 _M_t._M_emplace_unique(*__first);
628#ifdef __glibcxx_node_extract
631 extract(const_iterator __pos)
633 __glibcxx_assert(__pos !=
end());
634 return _M_t.extract(__pos);
640 {
return _M_t.extract(__x); }
645 {
return _M_t._M_reinsert_node_unique(
std::move(__nh)); }
650 {
return _M_t._M_reinsert_node_hint_unique(__hint,
std::move(__nh)); }
652 template<
typename,
typename>
653 friend struct std::_Rb_tree_merge_helper;
655 template<
typename _Compare1>
659 using _Merge_helper = _Rb_tree_merge_helper<set, _Compare1>;
660 _M_t._M_merge_unique(_Merge_helper::_S_get_tree(__source));
663 template<
typename _Compare1>
668 template<
typename _Compare1>
670 merge(multiset<_Key, _Compare1, _Alloc>& __source)
672 using _Merge_helper = _Rb_tree_merge_helper<set, _Compare1>;
673 _M_t._M_merge_unique(_Merge_helper::_S_get_tree(__source));
676 template<
typename _Compare1>
678 merge(multiset<_Key, _Compare1, _Alloc>&& __source)
682#if __cplusplus >= 201103L
698 _GLIBCXX_ABI_TAG_CXX11
701 {
return _M_t.erase(__position); }
715 { _M_t.erase(__position); }
731 {
return _M_t._M_erase_unique(__x); }
733#if __cplusplus >= 201103L
750 _GLIBCXX_ABI_TAG_CXX11
753 {
return _M_t.erase(__first, __last); }
769 { _M_t.erase(__first, __last); }
795 {
return _M_t.find(__x) == _M_t.end() ? 0 : 1; }
797#if __cplusplus > 201103L
798 template<
typename _Kt>
801 ->
decltype(_M_t._M_count_tr(__x))
802 {
return _M_t._M_count_tr(__x); }
806#if __cplusplus > 201703L
815 {
return _M_t.find(__x) != _M_t.end(); }
817 template<
typename _Kt>
820 ->
decltype(_M_t._M_find_tr(__x),
void(),
true)
821 {
return _M_t._M_find_tr(__x) != _M_t.end(); }
841 {
return _M_t.find(__x); }
845 {
return _M_t.find(__x); }
847#if __cplusplus > 201103L
848 template<
typename _Kt>
851 ->
decltype(
iterator{_M_t._M_find_tr(__x)})
852 {
return iterator{_M_t._M_find_tr(__x)}; }
854 template<
typename _Kt>
858 {
return const_iterator{_M_t._M_find_tr(__x)}; }
876 {
return _M_t.lower_bound(__x); }
880 {
return _M_t.lower_bound(__x); }
882#if __cplusplus > 201103L
883 template<
typename _Kt>
886 ->
decltype(
iterator(_M_t._M_lower_bound_tr(__x)))
887 {
return iterator(_M_t._M_lower_bound_tr(__x)); }
889 template<
typename _Kt>
906 {
return _M_t.upper_bound(__x); }
910 {
return _M_t.upper_bound(__x); }
912#if __cplusplus > 201103L
913 template<
typename _Kt>
916 ->
decltype(
iterator(_M_t._M_upper_bound_tr(__x)))
917 {
return iterator(_M_t._M_upper_bound_tr(__x)); }
919 template<
typename _Kt>
945 {
return _M_t.equal_range(__x); }
949 {
return _M_t.equal_range(__x); }
951#if __cplusplus > 201103L
952 template<
typename _Kt>
958 template<
typename _Kt>
966 template<
typename _K1,
typename _C1,
typename _A1>
970#if __cpp_lib_three_way_comparison
971 template<
typename _K1,
typename _C1,
typename _A1>
972 friend __detail::__synth3way_t<_K1>
975 template<
typename _K1,
typename _C1,
typename _A1>
981#if __cpp_deduction_guides >= 201606
983 template<
typename _InputIterator,
985 less<typename iterator_traits<_InputIterator>::value_type>,
986 typename _Allocator =
987 allocator<typename iterator_traits<_InputIterator>::value_type>,
988 typename = _RequireInputIter<_InputIterator>,
989 typename = _RequireNotAllocator<_Compare>,
990 typename = _RequireAllocator<_Allocator>>
991 set(_InputIterator, _InputIterator,
992 _Compare = _Compare(), _Allocator = _Allocator())
993 -> set<typename iterator_traits<_InputIterator>::value_type,
994 _Compare, _Allocator>;
996 template<
typename _Key,
typename _Compare = less<_Key>,
997 typename _Allocator = allocator<_Key>,
998 typename = _RequireNotAllocator<_Compare>,
999 typename = _RequireAllocator<_Allocator>>
1000 set(initializer_list<_Key>,
1001 _Compare = _Compare(), _Allocator = _Allocator())
1002 -> set<_Key, _Compare, _Allocator>;
1004 template<
typename _InputIterator,
typename _Allocator,
1005 typename = _RequireInputIter<_InputIterator>,
1006 typename = _RequireAllocator<_Allocator>>
1007 set(_InputIterator, _InputIterator, _Allocator)
1008 -> set<typename iterator_traits<_InputIterator>::value_type,
1009 less<typename iterator_traits<_InputIterator>::value_type>,
1012 template<
typename _Key,
typename _Allocator,
1013 typename = _RequireAllocator<_Allocator>>
1014 set(initializer_list<_Key>, _Allocator)
1015 -> set<_Key, less<_Key>, _Allocator>;
1017#if __glibcxx_containers_ranges
1018 template<ranges::input_range _Rg,
1019 __not_allocator_like _Compare = less<ranges::range_value_t<_Rg>>,
1021 set(from_range_t, _Rg&&, _Compare = _Compare(), _Alloc = _Alloc())
1022 -> set<ranges::range_value_t<_Rg>, _Compare, _Alloc>;
1024 template<ranges::input_range _Rg, __allocator_like _Alloc>
1025 set(from_range_t, _Rg&&, _Alloc)
1026 -> set<ranges::range_value_t<_Rg>, less<ranges::range_value_t<_Rg>>, _Alloc>;
1040 template<
typename _Key,
typename _Compare,
typename _Alloc>
1044 {
return __x._M_t == __y._M_t; }
1046#if __cpp_lib_three_way_comparison
1061 template<
typename _Key,
typename _Compare,
typename _Alloc>
1062 inline __detail::__synth3way_t<_Key>
1063 operator<=>(
const set<_Key, _Compare, _Alloc>& __x,
1064 const set<_Key, _Compare, _Alloc>& __y)
1065 {
return __x._M_t <=> __y._M_t; }
1078 template<
typename _Key,
typename _Compare,
typename _Alloc>
1082 {
return __x._M_t < __y._M_t; }
1085 template<
typename _Key,
typename _Compare,
typename _Alloc>
1089 {
return !(__x == __y); }
1092 template<
typename _Key,
typename _Compare,
typename _Alloc>
1096 {
return __y < __x; }
1099 template<
typename _Key,
typename _Compare,
typename _Alloc>
1103 {
return !(__y < __x); }
1106 template<
typename _Key,
typename _Compare,
typename _Alloc>
1110 {
return !(__x < __y); }
1114 template<
typename _Key,
typename _Compare,
typename _Alloc>
1117 _GLIBCXX_NOEXCEPT_IF(
noexcept(__x.swap(__y)))
1120_GLIBCXX_END_NAMESPACE_CONTAINER
1122#if __cplusplus > 201402L
1124 template<
typename _Val,
typename _Cmp1,
typename _Alloc,
typename _Cmp2>
1126 _Rb_tree_merge_helper<_GLIBCXX_STD_C::set<_Val, _Cmp1, _Alloc>, _Cmp2>
1129 friend class _GLIBCXX_STD_C::set<_Val, _Cmp1, _Alloc>;
1132 _S_get_tree(_GLIBCXX_STD_C::set<_Val, _Cmp2, _Alloc>& __set)
1133 {
return __set._M_t; }
1136 _S_get_tree(_GLIBCXX_STD_C::multiset<_Val, _Cmp2, _Alloc>& __set)
1137 {
return __set._M_t; }
1141_GLIBCXX_END_NAMESPACE_VERSION
pair(_T1, _T2) -> pair< _T1, _T2 >
Two pairs are equal iff their members are equal.
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
constexpr _Tp && forward(typename std::remove_reference< _Tp >::type &__t) noexcept
Forward an lvalue.
ISO C++ entities toplevel namespace is std.
is_nothrow_copy_constructible
The standard allocator, as per C++03 [20.4.1].
Struct holding two objects of arbitrary type.
_T1 first
The first member.
_T2 second
The second member.
A standard container made up of unique keys, which can be retrieved in logarithmic time.
set(set &&__x, const __type_identity_t< allocator_type > &__a) noexcept(is_nothrow_copy_constructible< _Compare >::value &&_Alloc_traits::_S_always_equal())
Allocator-extended move constructor.
bool contains(const key_type &__x) const
Finds whether an element with the given key exists.
set(_InputIterator __first, _InputIterator __last, const _Compare &__comp, const allocator_type &__a=allocator_type())
Builds a set from a range.
size_type count(const key_type &__x) const
Finds the number of elements.
_Rep_type::difference_type difference_type
set & operator=(initializer_list< value_type > __l)
Set list assignment operator.
_GLIBCXX_ABI_TAG_CXX11 iterator erase(const_iterator __position)
Erases an element from a set.
set(set &&)=default
Set move constructor
void swap(set &__x) noexcept(/*conditional */)
Swaps data with another set.
value_compare value_comp() const
Returns the comparison object with which the set was constructed.
iterator cbegin() const noexcept
polymorphic_allocator< _Key > allocator_type
_Rep_type::const_iterator const_iterator
_Alloc_traits::const_pointer const_pointer
auto contains(const _Kt &__x) const -> decltype(_M_t._M_find_tr(__x), void(), true)
Finds whether an element with the given key exists.
std::pair< const_iterator, const_iterator > equal_range(const key_type &__x) const
Finds a subsequence matching given key.
auto lower_bound(const _Kt &__x) -> decltype(iterator(_M_t._M_lower_bound_tr(__x)))
Finds the beginning of a subsequence matching given key.
const_iterator upper_bound(const key_type &__x) const
Finds the end of a subsequence matching given key.
void insert(initializer_list< value_type > __l)
Attempts to insert a list of elements into the set.
set(_InputIterator __first, _InputIterator __last)
Builds a set from a range.
iterator cend() const noexcept
auto count(const _Kt &__x) const -> decltype(_M_t._M_count_tr(__x))
Finds the number of elements.
iterator end() const noexcept
size_type max_size() const noexcept
Returns the maximum size of the set.
auto upper_bound(const _Kt &__x) const -> decltype(const_iterator(_M_t._M_upper_bound_tr(__x)))
Finds the end of a subsequence matching given key.
std::pair< iterator, bool > insert(const value_type &__x)
Attempts to insert an element into the set.
std::pair< iterator, iterator > equal_range(const key_type &__x)
Finds a subsequence matching given key.
auto find(const _Kt &__x) -> decltype(iterator{_M_t._M_find_tr(__x)})
Tries to locate an element in a set.
_Alloc_traits::const_reference const_reference
auto find(const _Kt &__x) const -> decltype(const_iterator{_M_t._M_find_tr(__x)})
Tries to locate an element in a set.
set()=default
Default constructor creates no elements.
auto lower_bound(const _Kt &__x) const -> decltype(const_iterator(_M_t._M_lower_bound_tr(__x)))
Finds the beginning of a subsequence matching given key.
set(const allocator_type &__a)
Allocator-extended default constructor.
std::pair< iterator, bool > emplace(_Args &&... __args)
Attempts to build and insert an element into the set.
key_compare key_comp() const
Returns the comparison object with which the set was constructed.
reverse_iterator rbegin() const noexcept
_Alloc_traits::reference reference
void insert(_InputIterator __first, _InputIterator __last)
A template function that attempts to insert a range of elements.
_GLIBCXX_ABI_TAG_CXX11 iterator erase(const_iterator __first, const_iterator __last)
Erases a [__first,__last) range of elements from a set.
reverse_iterator crbegin() const noexcept
auto equal_range(const _Kt &__x) -> decltype(pair< iterator, iterator >(_M_t._M_equal_range_tr(__x)))
Finds a subsequence matching given key.
auto equal_range(const _Kt &__x) const -> decltype(pair< iterator, iterator >(_M_t._M_equal_range_tr(__x)))
Finds a subsequence matching given key.
set(initializer_list< value_type > __l, const allocator_type &__a)
Allocator-extended initialier-list constructor.
_Alloc_traits::pointer pointer
size_type size() const noexcept
Returns the size of the set.
_Rep_type::const_reverse_iterator const_reverse_iterator
_Rep_type::const_iterator iterator
_Rep_type::const_reverse_iterator reverse_iterator
reverse_iterator crend() const noexcept
iterator insert(const_iterator __position, const value_type &__x)
Attempts to insert an element into the set.
const_iterator lower_bound(const key_type &__x) const
Finds the beginning of a subsequence matching given key.
set(_InputIterator __first, _InputIterator __last, const allocator_type &__a)
Allocator-extended range constructor.
set(const set &__x, const __type_identity_t< allocator_type > &__a)
Allocator-extended copy constructor.
set(initializer_list< value_type > __l, const _Compare &__comp=_Compare(), const allocator_type &__a=allocator_type())
Builds a set from an initializer_list.
allocator_type get_allocator() const noexcept
Returns the allocator object with which the set was constructed.
_Rep_type::size_type size_type
set(const set &)=default
Set copy constructor.
iterator upper_bound(const key_type &__x)
Finds the end of a subsequence matching given key.
iterator lower_bound(const key_type &__x)
Finds the beginning of a subsequence matching given key.
auto upper_bound(const _Kt &__x) -> decltype(iterator(_M_t._M_upper_bound_tr(__x)))
Finds the end of a subsequence matching given key.
iterator emplace_hint(const_iterator __pos, _Args &&... __args)
Attempts to insert an element into the set.
set & operator=(const set &)=default
Set assignment operator.
iterator begin() const noexcept
set(const _Compare &__comp, const allocator_type &__a=allocator_type())
Creates a set with no elements.
iterator find(const key_type &__x)
Tries to locate an element in a set.
set & operator=(set &&)=default
Move assignment operator.
bool empty() const noexcept
Returns true if the set is empty.
size_type erase(const key_type &__x)
Erases elements according to the provided key.
const_iterator find(const key_type &__x) const
Tries to locate an element in a set.
reverse_iterator rend() const noexcept
A standard container made up of elements, which can be retrieved in logarithmic time.
Uniform interface to C++98 and C++11 allocators.