60#if __cplusplus >= 201103L
63#if __glibcxx_containers_ranges
68namespace std _GLIBCXX_VISIBILITY(default)
70_GLIBCXX_BEGIN_NAMESPACE_VERSION
71_GLIBCXX_BEGIN_NAMESPACE_CONTAINER
73 template<
typename _Key,
typename _Compare,
typename _Alloc>
98 template<
typename _Key,
typename _Compare = std::less<_Key>,
99 typename _Alloc = std::allocator<_Key> >
102#ifdef _GLIBCXX_CONCEPT_CHECKS
104 typedef typename _Alloc::value_type _Alloc_value_type;
105# if __cplusplus < 201103L
106 __glibcxx_class_requires(_Key, _SGIAssignableConcept)
108 __glibcxx_class_requires4(_Compare,
bool, _Key, _Key,
109 _BinaryFunctionConcept)
110 __glibcxx_class_requires2(_Key, _Alloc_value_type, _SameTypeConcept)
113#if __cplusplus >= 201103L
115 "std::set must have a non-const, non-volatile value_type");
116# if __cplusplus > 201703L || defined __STRICT_ANSI__
118 "std::set must have the same value_type as its allocator");
135 rebind<_Key>::other _Key_alloc_type;
137 typedef _Rb_tree<key_type, value_type, _Identity<value_type>,
146 typedef typename _Alloc_traits::pointer
pointer;
153 typedef typename _Rep_type::const_iterator
iterator;
161#ifdef __glibcxx_node_extract
162 using node_type =
typename _Rep_type::node_type;
163 using insert_return_type =
typename _Rep_type::insert_return_type;
170#if __cplusplus < 201103L
182 set(
const _Compare& __comp,
184 : _M_t(__comp, _Key_alloc_type(__a)) { }
196 template<
typename _InputIterator>
197 set(_InputIterator __first, _InputIterator __last)
199 { _M_t._M_insert_range_unique(__first, __last); }
213 template<
typename _InputIterator>
214 set(_InputIterator __first, _InputIterator __last,
215 const _Compare& __comp,
217 : _M_t(__comp, _Key_alloc_type(__a))
218 { _M_t._M_insert_range_unique(__first, __last); }
225#if __cplusplus < 201103L
250 const _Compare& __comp = _Compare(),
252 : _M_t(__comp, _Key_alloc_type(__a))
253 { _M_t._M_insert_range_unique(__l.begin(), __l.end()); }
258 : _M_t(_Key_alloc_type(__a)) { }
261 set(
const set& __x,
const __type_identity_t<allocator_type>& __a)
262 : _M_t(__x._M_t, _Key_alloc_type(__a)) { }
265 set(
set&& __x,
const __type_identity_t<allocator_type>& __a)
267 && _Alloc_traits::_S_always_equal())
268 : _M_t(
std::
move(__x._M_t), _Key_alloc_type(__a)) { }
272 : _M_t(_Key_alloc_type(__a))
273 { _M_t._M_insert_range_unique(__l.begin(), __l.end()); }
276 template<
typename _InputIterator>
277 set(_InputIterator __first, _InputIterator __last,
279 : _M_t(_Key_alloc_type(__a))
280 { _M_t._M_insert_range_unique(__first, __last); }
282#if __glibcxx_containers_ranges
287 template<__detail::__container_compatible_range<_Key> _Rg>
288 set(from_range_t, _Rg&& __rg,
289 const _Compare& __comp,
290 const _Alloc& __a = _Alloc())
291 : _M_t(__comp, _Key_alloc_type(__a))
295 template<__detail::__container_compatible_range<_Key> _Rg>
296 set(from_range_t, _Rg&& __rg,
const _Alloc& __a = _Alloc())
297 : _M_t(_Key_alloc_type(__a))
314#if __cplusplus < 201103L
343 _M_t._M_assign_unique(__l.begin(), __l.end());
353 {
return _M_t.key_comp(); }
357 {
return _M_t.key_comp(); }
370 {
return _M_t.begin(); }
378 end() const _GLIBCXX_NOEXCEPT
379 {
return _M_t.end(); }
388 {
return _M_t.rbegin(); }
397 {
return _M_t.rend(); }
399#if __cplusplus >= 201103L
407 {
return _M_t.begin(); }
416 {
return _M_t.end(); }
425 {
return _M_t.rbegin(); }
434 {
return _M_t.rend(); }
438 _GLIBCXX_NODISCARD
bool
440 {
return _M_t.empty(); }
445 {
return _M_t.size(); }
450 {
return _M_t.max_size(); }
467 _GLIBCXX_NOEXCEPT_IF(__is_nothrow_swappable<_Compare>::value)
468 { _M_t.swap(__x._M_t); }
471#if __cplusplus >= 201103L
485 template<
typename... _Args>
511 template<
typename... _Args>
515 return _M_t._M_emplace_hint_unique(__pos,
537 _M_t._M_insert_unique(__x);
541#if __cplusplus >= 201103L
572 {
return _M_t._M_insert_unique_(__position, __x); }
574#if __cplusplus >= 201103L
577 {
return _M_t._M_insert_unique_(__position,
std::move(__x)); }
589 template<
typename _InputIterator>
591 insert(_InputIterator __first, _InputIterator __last)
592 { _M_t._M_insert_range_unique(__first, __last); }
594#if __cplusplus >= 201103L
604 { this->
insert(__l.begin(), __l.end()); }
607#if __glibcxx_containers_ranges
614 template<__detail::__container_compatible_range<_Key> _Rg>
616 insert_range(_Rg&& __rg)
618 auto __first = ranges::begin(__rg);
619 const auto __last = ranges::end(__rg);
620 using _Rv = remove_cvref_t<ranges::range_reference_t<_Rg>>;
621 for (; __first != __last; ++__first)
622 if constexpr (is_same_v<_Rv, _Key>)
623 _M_t._M_insert_unique(*__first);
625 _M_t._M_emplace_unique(*__first);
629#ifdef __glibcxx_node_extract
632 extract(const_iterator __pos)
634 __glibcxx_assert(__pos !=
end());
635 return _M_t.extract(__pos);
641 {
return _M_t.extract(__x); }
643#ifdef __glibcxx_associative_heterogeneous_erasure
644 template <__heterogeneous_tree_key<set> _Kt>
647 {
return _M_t._M_extract_tr(__key); }
653 {
return _M_t._M_reinsert_node_unique(
std::move(__nh)); }
658 {
return _M_t._M_reinsert_node_hint_unique(__hint,
std::move(__nh)); }
660 template<
typename,
typename>
661 friend struct std::_Rb_tree_merge_helper;
663 template<
typename _Compare1>
667 using _Merge_helper = _Rb_tree_merge_helper<set, _Compare1>;
668 _M_t._M_merge_unique(_Merge_helper::_S_get_tree(__source));
671 template<
typename _Compare1>
676 template<
typename _Compare1>
678 merge(multiset<_Key, _Compare1, _Alloc>& __source)
680 using _Merge_helper = _Rb_tree_merge_helper<set, _Compare1>;
681 _M_t._M_merge_unique(_Merge_helper::_S_get_tree(__source));
684 template<
typename _Compare1>
686 merge(multiset<_Key, _Compare1, _Alloc>&& __source)
690#if __cplusplus >= 201103L
706 _GLIBCXX_ABI_TAG_CXX11
709 {
return _M_t.erase(__position); }
723 { _M_t.erase(__position); }
739 {
return _M_t._M_erase_unique(__x); }
741#ifdef __glibcxx_associative_heterogeneous_erasure
745 template <__heterogeneous_tree_key<set> _Kt>
748 {
return _M_t._M_erase_tr(__key); }
751#if __cplusplus >= 201103L
768 _GLIBCXX_ABI_TAG_CXX11
771 {
return _M_t.erase(__first, __last); }
787 { _M_t.erase(__first, __last); }
813 {
return _M_t.find(__x) == _M_t.end() ? 0 : 1; }
815#ifdef __glibcxx_generic_associative_lookup
816 template<
typename _Kt>
818 count(
const _Kt& __x)
const
819 ->
decltype(_M_t._M_count_tr(__x))
820 {
return _M_t._M_count_tr(__x); }
824#if __cplusplus > 201703L
833 {
return _M_t.find(__x) != _M_t.end(); }
835 template<
typename _Kt>
838 ->
decltype(_M_t._M_find_tr(__x),
void(),
true)
839 {
return _M_t._M_find_tr(__x) != _M_t.end(); }
859 {
return _M_t.find(__x); }
863 {
return _M_t.find(__x); }
865#ifdef __glibcxx_generic_associative_lookup
866 template<
typename _Kt>
869 ->
decltype(
iterator{_M_t._M_find_tr(__x)})
870 {
return iterator{_M_t._M_find_tr(__x)}; }
872 template<
typename _Kt>
874 find(
const _Kt& __x)
const
894 {
return _M_t.lower_bound(__x); }
898 {
return _M_t.lower_bound(__x); }
900#ifdef __glibcxx_generic_associative_lookup
901 template<
typename _Kt>
904 ->
decltype(
iterator(_M_t._M_lower_bound_tr(__x)))
905 {
return iterator(_M_t._M_lower_bound_tr(__x)); }
907 template<
typename _Kt>
924 {
return _M_t.upper_bound(__x); }
928 {
return _M_t.upper_bound(__x); }
930#ifdef __glibcxx_generic_associative_lookup
931 template<
typename _Kt>
934 ->
decltype(
iterator(_M_t._M_upper_bound_tr(__x)))
935 {
return iterator(_M_t._M_upper_bound_tr(__x)); }
937 template<
typename _Kt>
963 {
return _M_t.equal_range(__x); }
967 {
return _M_t.equal_range(__x); }
969#ifdef __glibcxx_generic_associative_lookup
970 template<
typename _Kt>
976 template<
typename _Kt>
984 template<
typename _K1,
typename _C1,
typename _A1>
988#if __cpp_lib_three_way_comparison
989 template<
typename _K1,
typename _C1,
typename _A1>
990 friend __detail::__synth3way_t<_K1>
993 template<
typename _K1,
typename _C1,
typename _A1>
999#if __cpp_deduction_guides >= 201606
1001 template<
typename _InputIterator,
1004 typename _Allocator =
1006 typename = _RequireInputIter<_InputIterator>,
1007 typename = _RequireNotAllocator<_Compare>,
1008 typename = _RequireAllocator<_Allocator>>
1009 set(_InputIterator, _InputIterator,
1010 _Compare = _Compare(), _Allocator = _Allocator())
1012 _Compare, _Allocator>;
1014 template<
typename _Key,
typename _Compare = less<_Key>,
1015 typename _Allocator = allocator<_Key>,
1016 typename = _RequireNotAllocator<_Compare>,
1017 typename = _RequireAllocator<_Allocator>>
1019 _Compare = _Compare(), _Allocator = _Allocator())
1022 template<
typename _InputIterator,
typename _Allocator,
1023 typename = _RequireInputIter<_InputIterator>,
1024 typename = _RequireAllocator<_Allocator>>
1025 set(_InputIterator, _InputIterator, _Allocator)
1030 template<
typename _Key,
typename _Allocator,
1031 typename = _RequireAllocator<_Allocator>>
1035#if __glibcxx_containers_ranges
1038 __allocator_like _Alloc = std::allocator<ranges::range_value_t<_Rg>>>
1039 set(from_range_t, _Rg&&, _Compare = _Compare(), _Alloc = _Alloc())
1042 template<ranges::input_range _Rg, __allocator_like _Alloc>
1043 set(from_range_t, _Rg&&, _Alloc)
1058 template<
typename _Key,
typename _Compare,
typename _Alloc>
1062 {
return __x._M_t == __y._M_t; }
1064#if __cpp_lib_three_way_comparison
1079 template<
typename _Key,
typename _Compare,
typename _Alloc>
1080 inline __detail::__synth3way_t<_Key>
1081 operator<=>(
const set<_Key, _Compare, _Alloc>& __x,
1082 const set<_Key, _Compare, _Alloc>& __y)
1083 {
return __x._M_t <=> __y._M_t; }
1096 template<
typename _Key,
typename _Compare,
typename _Alloc>
1100 {
return __x._M_t < __y._M_t; }
1103 template<
typename _Key,
typename _Compare,
typename _Alloc>
1107 {
return !(__x == __y); }
1110 template<
typename _Key,
typename _Compare,
typename _Alloc>
1114 {
return __y < __x; }
1117 template<
typename _Key,
typename _Compare,
typename _Alloc>
1121 {
return !(__y < __x); }
1124 template<
typename _Key,
typename _Compare,
typename _Alloc>
1128 {
return !(__x < __y); }
1132 template<
typename _Key,
typename _Compare,
typename _Alloc>
1135 _GLIBCXX_NOEXCEPT_IF(
noexcept(__x.swap(__y)))
1138_GLIBCXX_END_NAMESPACE_CONTAINER
1140#ifdef __glibcxx_node_extract
1142 template<
typename _Val,
typename _Cmp1,
typename _Alloc,
typename _Cmp2>
1144 _Rb_tree_merge_helper<_GLIBCXX_STD_C::set<_Val, _Cmp1, _Alloc>, _Cmp2>
1147 friend class _GLIBCXX_STD_C::set<_Val, _Cmp1, _Alloc>;
1150 _S_get_tree(_GLIBCXX_STD_C::set<_Val, _Cmp2, _Alloc>& __set)
1151 {
return __set._M_t; }
1154 _S_get_tree(_GLIBCXX_STD_C::multiset<_Val, _Cmp2, _Alloc>& __set)
1155 {
return __set._M_t; }
1159_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].
One of the comparison functors.
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.
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
iterator end() const noexcept
size_type max_size() const noexcept
Returns the maximum size of the set.
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.
_Alloc_traits::const_reference const_reference
set()=default
Default constructor creates no elements.
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
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.
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.
A range for which ranges::begin returns an input iterator.