60#if __cplusplus >= 201103L
64namespace 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
99# if __cplusplus < 201103L
100 __glibcxx_class_requires(
_Key, _SGIAssignableConcept)
102 __glibcxx_class_requires4(_Compare,
bool,
_Key,
_Key,
103 _BinaryFunctionConcept)
107#if __cplusplus >= 201103L
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;
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>
193 { _M_t._M_insert_range_unique(__first, __last); }
207 template<
typename _InputIterator>
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)) { }
256 : _M_t(__x._M_t, _Key_alloc_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>
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(); }
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(); }
443 { _M_t.swap(__x._M_t); }
446#if __cplusplus >= 201103L
460 template<
typename...
_Args>
486 template<
typename...
_Args>
490 return _M_t._M_emplace_hint_unique(
__pos,
512 _M_t._M_insert_unique(__x);
516#if __cplusplus >= 201103L
547 {
return _M_t._M_insert_unique_(
__position, __x); }
549#if __cplusplus >= 201103L
564 template<
typename _InputIterator>
567 { _M_t._M_insert_range_unique(__first, __last); }
569#if __cplusplus >= 201103L
579 { this->
insert(__l.begin(),
__l.end()); }
582#if __cplusplus > 201402L
588 return _M_t.extract(
__pos);
594 {
return _M_t.extract(__x); }
606 template<
typename,
typename>
607 friend struct std::_Rb_tree_merge_helper;
609 template<
typename _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
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>
773 contains(
const _Kt& __x)
const
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())
947 -> set<typename iterator_traits<_InputIterator>::value_type,
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)
962 -> set<typename iterator_traits<_InputIterator>::value_type,
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>;
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); }
1057 template<
typename _Key,
typename _Compare,
typename _Alloc>
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
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
void swap(any &__x, any &__y) noexcept
Exchange the states of two any objects.
ISO C++ entities toplevel namespace is std.
is_nothrow_copy_constructible
A standard container made up of unique keys, which can be retrieved in logarithmic time.
set(const set &__x, const allocator_type &__a)
Allocator-extended copy constructor.
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
Iterator-related typedefs.
node_type extract(const_iterator __pos)
Extract a node.
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.
_Compare value_compare
Public typedefs.
value_compare value_comp() const
Returns the comparison object with which the set was constructed.
iterator cbegin() const noexcept
_Alloc allocator_type
Public typedefs.
_Rep_type::const_iterator const_iterator
Iterator-related typedefs.
_Alloc_traits::const_pointer const_pointer
Iterator-related typedefs.
_Key value_type
Public typedefs.
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
set(set &&__x, const allocator_type &__a) noexcept(is_nothrow_copy_constructible< _Compare >::value &&_Alloc_traits::_S_always_equal())
Allocator-extended move constructor.
auto count(const _Kt &__x) const -> decltype(_M_t._M_count_tr(__x))
Finds the number of elements.
insert_return_type insert(node_type &&__nh)
Re-insert an extracted node.
iterator insert(const_iterator __hint, node_type &&__nh)
Re-insert an extracted node.
iterator end() const noexcept
_Compare key_compare
Public typedefs.
size_type max_size() const noexcept
Returns the maximum size of the set.
_Key key_type
Public typedefs.
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
Iterator-related typedefs.
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
Iterator-related typedefs.
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 upper_bound(const _Kt &__x) const -> decltype(iterator(_M_t._M_upper_bound_tr(__x)))
Finds the end of a subsequence matching given key.
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
Iterator-related typedefs.
size_type size() const noexcept
Returns the size of the set.
_Rep_type::const_reverse_iterator const_reverse_iterator
Iterator-related typedefs.
_Rep_type::const_iterator iterator
Iterator-related typedefs.
_Rep_type::const_reverse_iterator reverse_iterator
Iterator-related typedefs.
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(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
Iterator-related typedefs.
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
node_type extract(const key_type &__x)
Extract a node.
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
Uniform interface to C++98 and C++11 allocators.