29#ifndef _GLIBCXX_FLAT_SET
30#define _GLIBCXX_FLAT_SET 1
33#pragma GCC system_header
36#define __glibcxx_want_constexpr_flat_set
37#define __glibcxx_want_flat_set
40#ifdef __cpp_lib_flat_set
58namespace std _GLIBCXX_VISIBILITY(default)
60_GLIBCXX_BEGIN_NAMESPACE_VERSION
62 template<
typename _Key,
typename _Compare,
63 typename _KeyContainer>
66 template<
typename _Key,
typename _Compare,
67 typename _KeyContainer>
70 template<
typename _Key,
typename _Compare,
typename _KeyContainer,
bool _Multi>
73 static_assert(is_same_v<_Key, typename _KeyContainer::value_type>);
75 using _Derived = __conditional_t<_Multi,
76 flat_multiset<_Key, _Compare, _KeyContainer>,
77 flat_set<_Key, _Compare, _KeyContainer>>;
78 using __sorted_t = __conditional_t<_Multi, sorted_equivalent_t, sorted_unique_t>;
81 using key_type = _Key;
82 using value_type = _Key;
83 using key_compare = _Compare;
84 using value_compare = _Compare;
85 using reference = value_type&;
86 using const_reference =
const value_type&;
87 using size_type =
typename _KeyContainer::size_type;
88 using difference_type =
typename _KeyContainer::difference_type;
89 using iterator =
typename _KeyContainer::const_iterator;
90 using const_iterator =
typename _KeyContainer::const_iterator;
91 using reverse_iterator = std::reverse_iterator<iterator>;
92 using const_reverse_iterator = std::reverse_iterator<const_iterator>;
93 using container_type = _KeyContainer;
96 using __emplace_result_t = __conditional_t<_Multi, iterator, pair<iterator, bool>>;
100 container_type* _M_cont;
103 _ClearGuard(container_type& __cont)
117 { _M_cont =
nullptr; }
122 _M_make_clear_guard()
123 {
return _ClearGuard{this->_M_cont}; }
128 _Flat_set_impl() : _Flat_set_impl(key_compare()) { }
132 _Flat_set_impl(
const key_compare& __comp)
133 : _M_cont(), _M_comp(__comp)
137 _Flat_set_impl(container_type __cont,
const key_compare& __comp = key_compare())
138 : _M_cont(std::move(__cont)), _M_comp(__comp)
142 _Flat_set_impl(__sorted_t,
143 container_type __cont,
const key_compare& __comp = key_compare())
144 : _M_cont(std::move(__cont)), _M_comp(__comp)
145 { _GLIBCXX_DEBUG_ASSERT(ranges::is_sorted(_M_cont, _M_comp)); }
147 template<__has_input_iter_cat _InputIterator>
149 _Flat_set_impl(_InputIterator __first, _InputIterator __last,
150 const key_compare& __comp = key_compare())
151 : _M_cont(), _M_comp(__comp)
152 { insert(__first, __last); }
154 template<__has_input_iter_cat _InputIterator>
156 _Flat_set_impl(__sorted_t __s,
157 _InputIterator __first, _InputIterator __last,
158 const key_compare& __comp = key_compare())
159 : _M_cont(), _M_comp(__comp)
160 { insert(__s, __first, __last); }
162 template<__detail::__container_compatible_range<value_type> _Rg>
164 _Flat_set_impl(from_range_t, _Rg&& __rg)
165 : _Flat_set_impl(from_range, std::
forward<_Rg>(__rg), key_compare())
168 template<__detail::__container_compatible_range<value_type> _Rg>
170 _Flat_set_impl(from_range_t, _Rg&& __rg,
const key_compare& __comp)
171 : _Flat_set_impl(__comp)
175 _Flat_set_impl(initializer_list<value_type> __il,
176 const key_compare& __comp = key_compare())
177 : _Flat_set_impl(__il.begin(), __il.end(), __comp)
181 _Flat_set_impl(__sorted_t __s,
182 initializer_list<value_type> __il,
183 const key_compare& __comp = key_compare())
184 : _Flat_set_impl(__s, __il.begin(), __il.end(), __comp)
189 template<__allocator_for<container_type> _Alloc>
192 _Flat_set_impl(
const _Alloc& __a)
193 : _Flat_set_impl(key_compare(), __a)
196 template<__allocator_for<container_type> _Alloc>
198 _Flat_set_impl(
const key_compare& __comp,
const _Alloc& __a)
199 : _M_cont(std::make_obj_using_allocator<container_type>(__a)),
203 template<__allocator_for<container_type> _Alloc>
205 _Flat_set_impl(
const container_type& __cont,
const _Alloc& __a)
206 : _Flat_set_impl(__cont, key_compare(), __a)
209 template<__allocator_for<container_type> _Alloc>
211 _Flat_set_impl(
const container_type& __cont,
const key_compare& __comp,
213 : _M_cont(std::make_obj_using_allocator<container_type>(__a, __cont)),
217 template<__allocator_for<container_type> _Alloc>
219 _Flat_set_impl(__sorted_t __s,
const container_type& __cont,
const _Alloc& __a)
220 : _Flat_set_impl(__s, __cont, key_compare(), __a)
223 template<__allocator_for<container_type> _Alloc>
225 _Flat_set_impl(__sorted_t,
const container_type& __cont,
const key_compare& __comp,
227 : _M_cont(std::make_obj_using_allocator<container_type>(__a, __cont)),
229 { _GLIBCXX_DEBUG_ASSERT(ranges::is_sorted(_M_cont, _M_comp)); }
231 template<__allocator_for<container_type> _Alloc>
233 _Flat_set_impl(
const _Derived& __x,
const _Alloc& __a)
234 : _M_cont(std::make_obj_using_allocator<container_type>(__a, __x._M_cont)),
238 template<__allocator_for<container_type> _Alloc>
240 _Flat_set_impl(_Derived&& __x,
const _Alloc& __a)
241 : _M_cont(std::make_obj_using_allocator<container_type>(__a, std::move(__x._M_cont))),
245 template<__has_input_iter_cat _InputIterator, __allocator_for<container_type> _Alloc>
247 _Flat_set_impl(_InputIterator __first, _InputIterator __last,
249 : _Flat_set_impl(std::move(__first), std::move(__last), key_compare(), __a)
252 template<__has_input_iter_cat _InputIterator, __allocator_for<container_type> _Alloc>
254 _Flat_set_impl(_InputIterator __first, _InputIterator __last,
255 const key_compare& __comp,
257 : _Flat_set_impl(__comp, __a)
258 { insert(__first, __last); }
260 template<__has_input_iter_cat _InputIterator, __allocator_for<container_type> _Alloc>
262 _Flat_set_impl(__sorted_t __s,
263 _InputIterator __first, _InputIterator __last,
265 : _Flat_set_impl(__s, std::move(__first), std::move(__last), key_compare(), __a)
268 template<__has_input_iter_cat _InputIterator, __allocator_for<container_type> _Alloc>
270 _Flat_set_impl(__sorted_t __s,
271 _InputIterator __first, _InputIterator __last,
272 const key_compare& __comp,
274 : _Flat_set_impl(__comp, __a)
275 { insert(__s, __first, __last); }
277 template<__detail::__container_compatible_range<value_type> _Rg,
278 __allocator_for<container_type> _Alloc>
280 _Flat_set_impl(from_range_t, _Rg&& __rg,
282 : _Flat_set_impl(from_range, std::
forward<_Rg>(__rg), key_compare(), __a)
285 template<__detail::__container_compatible_range<value_type> _Rg,
286 __allocator_for<container_type> _Alloc>
288 _Flat_set_impl(from_range_t, _Rg&& __rg,
289 const key_compare& __comp,
291 : _Flat_set_impl(__comp, __a)
294 template<__allocator_for<container_type> _Alloc>
296 _Flat_set_impl(initializer_list<value_type> __il,
298 : _Flat_set_impl(__il, key_compare(), __a)
301 template<__allocator_for<container_type> _Alloc>
303 _Flat_set_impl(initializer_list<value_type> __il,
304 const key_compare& __comp,
306 : _Flat_set_impl(__il.begin(), __il.end(), __comp, __a)
309 template<__allocator_for<container_type> _Alloc>
311 _Flat_set_impl(__sorted_t __s,
312 initializer_list<value_type> __il,
314 : _Flat_set_impl(__s, __il.begin(), __il.end(), key_compare(), __a)
317 template<__allocator_for<container_type> _Alloc>
319 _Flat_set_impl(__sorted_t __s,
320 initializer_list<value_type> __il,
321 const key_compare& __comp,
323 : _Flat_set_impl(__s, __il.begin(), __il.end(), __comp, __a)
326 _Flat_set_impl(
const _Flat_set_impl&) =
default;
327 _Flat_set_impl& operator=(
const _Flat_set_impl&) =
default;
330 _Flat_set_impl(_Flat_set_impl&& __other)
331 noexcept(is_nothrow_move_constructible_v<container_type>
332 && is_nothrow_move_constructible_v<key_compare>)
336 : _M_cont(std::move(__other._M_cont)), _M_comp(std::move(__other._M_comp))
345 operator=(_Flat_set_impl&& __other)
346 noexcept(is_nothrow_move_assignable_v<container_type>
347 && is_nothrow_move_assignable_v<key_compare>)
349 auto __guard = _M_make_clear_guard();
350 auto __guard_other = _ClearGuard{__other._M_cont};
353 __guard._M_disable();
360 operator=(initializer_list<value_type> __il)
362 auto __guard = _M_make_clear_guard();
365 __guard._M_disable();
366 return static_cast<_Derived&
>(*this);
372 begin() const noexcept
373 {
return _M_cont.begin(); }
378 {
return _M_cont.end(); }
381 const_reverse_iterator
382 rbegin() const noexcept
383 {
return const_reverse_iterator(end()); }
386 const_reverse_iterator
387 rend() const noexcept
388 {
return const_reverse_iterator(begin()); }
392 cbegin() const noexcept
397 cend() const noexcept
401 const_reverse_iterator
402 crbegin() const noexcept
406 const_reverse_iterator
407 crend() const noexcept
414 empty() const noexcept
415 {
return _M_cont.empty(); }
419 size() const noexcept
420 {
return _M_cont.size(); }
424 max_size() const noexcept
425 {
return _M_cont.max_size(); }
428 template<
typename _Arg,
typename... _Args>
431 _M_try_emplace(optional<const_iterator> __hint, _Arg&& __arg, _Args&&... __args)
434 auto&& __k = [&] ->
decltype(
auto) {
435 if constexpr (
sizeof...(_Args) == 0
436 && same_as<remove_cvref_t<_Arg>, value_type>)
442 typename container_type::iterator __it;
443 int __r = -1, __s = -1;
444 if (__hint.has_value()
445 && (__hint == cbegin()
446 || (__r = !_M_comp(__k, (*__hint)[-1])))
448 || (__s = !_M_comp((*__hint)[0], __k))))
450 __it = _M_cont.begin() + (*__hint - begin());
451 if constexpr (!_Multi)
452 if (__r == 1 && !_M_comp(__it[-1], __k))
453 return {__it - 1,
false};
457 auto __first = _M_cont.begin();
458 auto __last = _M_cont.end();
460 __first += *__hint - _M_cont.begin();
462 __last = __first + (*__hint - _M_cont.begin());
463 if constexpr (_Multi)
467 __it = std::lower_bound(__first, __last, __k, _M_comp);
472 __k, std::not_fn(_M_comp)).base();
475 __it = std::lower_bound(__first, __last, __k, _M_comp);
478 if constexpr (!_Multi)
479 if (__it != _M_cont.end() && !_M_comp(__k, __it[0]))
480 return {__it,
false};
482 auto __guard = _M_make_clear_guard();
483 __it = _M_cont.insert(__it,
std::forward<
decltype(__k)>(__k));
484 __guard._M_disable();
490 _M_try_emplace(optional<const_iterator> __hint)
491 {
return _M_try_emplace(__hint, value_type()); }
493 template<
typename... _Args>
494 requires is_constructible_v<value_type, _Args...>
497 emplace(_Args&&... __args)
500 if constexpr (_Multi)
506 template<
typename... _Args>
509 emplace_hint(const_iterator __position, _Args&&... __args)
514 insert(
const value_type& __x)
515 {
return emplace(__x); }
519 insert(value_type&& __x)
524 insert(const_iterator __position,
const value_type& __x)
525 {
return emplace_hint(__position, __x); }
529 insert(const_iterator __position, value_type&& __x)
530 {
return emplace_hint(__position,
std::move(__x)); }
532 template<
typename _Arg>
533 requires is_constructible_v<value_type, _Arg>
539 template<
typename _Arg>
540 requires is_constructible_v<value_type, _Arg>
543 insert(const_iterator __position, _Arg&& __x)
546 template<__has_input_iter_cat _InputIterator>
549 insert(_InputIterator __first, _InputIterator __last)
551 auto __guard = _M_make_clear_guard();
552 auto __it = _M_cont.insert(_M_cont.end(), __first, __last);
553 std::sort(__it, _M_cont.end(), _M_comp);
554 std::inplace_merge(_M_cont.begin(), __it, _M_cont.end(), _M_comp);
555 if constexpr (!_Multi)
557 __guard._M_disable();
560 template<__has_input_iter_cat _InputIterator>
563 insert(__sorted_t, _InputIterator __first, _InputIterator __last)
565 auto __guard = _M_make_clear_guard();
566 auto __it = _M_cont.insert(_M_cont.end(), __first, __last);
567 std::inplace_merge(_M_cont.begin(), __it, _M_cont.end(), _M_comp);
568 if constexpr (!_Multi)
570 __guard._M_disable();
573 template<
typename _Rg>
576 _M_insert_range(_Rg&& __rg,
bool __is_sorted =
false)
578 auto __guard = _M_make_clear_guard();
579 typename container_type::iterator __it;
580 if constexpr (
requires { _M_cont.insert_range(_M_cont.end(), __rg); })
581 __it = _M_cont.insert_range(_M_cont.end(), __rg);
582 else if constexpr (ranges::common_range<_Rg>
583 && __has_input_iter_cat<ranges::iterator_t<_Rg>>)
584 __it = _M_cont.insert(_M_cont.end(), ranges::begin(__rg), ranges::end(__rg));
587 size_type __n = size();
588 auto __first = ranges::begin(__rg);
589 auto __last = ranges::end(__rg);
590 for (; __first != __last; ++__first)
591 _M_cont.emplace_back(*__first);
592 __it = _M_cont.begin() + __n;
595 _GLIBCXX_DEBUG_ASSERT(ranges::is_sorted(__it, _M_cont.end(), _M_comp));
597 std::sort(__it, _M_cont.end(), _M_comp);
598 std::inplace_merge(_M_cont.begin(), __it, _M_cont.end(), _M_comp);
599 if constexpr (!_Multi)
601 __guard._M_disable();
604 template<__detail::__container_compatible_range<value_type> _Rg>
607 insert_range(_Rg&& __rg)
610 template<__detail::__container_compatible_range<value_type> _Rg>
613 insert_range(__sorted_t, _Rg&& __rg)
618 insert(initializer_list<value_type> __il)
619 { insert(__il.begin(), __il.end()); }
623 insert(__sorted_t __s, initializer_list<value_type> __il)
624 { insert(__s, __il.begin(), __il.end()); }
630 auto __guard = _M_make_clear_guard();
636 replace(container_type&& __cont)
638 _GLIBCXX_DEBUG_ASSERT(ranges::is_sorted(__cont, _M_comp));
639 auto __guard = _M_make_clear_guard();
641 __guard._M_disable();
646 erase(const_iterator __position)
647 {
return _M_cont.erase(__position); }
651 erase(
const key_type& __x)
652 {
return erase<const key_type&>(__x); }
654 template<
typename _Key2>
655 requires same_as<remove_cvref_t<_Key2>, _Key>
656 || (__transparent_comparator<_Compare>
657 && !is_convertible_v<_Key2, iterator>
658 && !is_convertible_v<_Key2, const_iterator>)
664 auto __n = __last - __first;
665 erase(__first, __last);
671 erase(const_iterator __first, const_iterator __last)
672 {
return _M_cont.erase(__first, __last); }
677 noexcept(is_nothrow_swappable_v<container_type>
678 && is_nothrow_swappable_v<key_compare>)
680 auto __guard = _M_make_clear_guard();
681 auto __guard_y = _ClearGuard{__y._M_cont};
682 ranges::swap(_M_cont, __y._M_cont);
683 ranges::swap(_M_comp, __y._M_comp);
684 __guard._M_disable();
685 __guard_y._M_disable();
710 find(
const key_type& __x)
711 {
return find<key_type>(__x); }
716 find(
const key_type& __x)
const
717 {
return find<key_type>(__x); }
719 template<
typename _Key2>
720 requires same_as<_Key2, _Key> || __transparent_comparator<_Compare>
724 find(
const _Key2& __x)
726 auto __it = lower_bound(__x);
727 if (__it != end() && !_M_comp(__x, *__it))
733 template<
typename _Key2>
734 requires same_as<_Key2, _Key> || __transparent_comparator<_Compare>
738 find(
const _Key2& __x)
const
740 auto __it = lower_bound(__x);
741 if (__it != cend() && !_M_comp(__x, *__it))
750 count(
const key_type& __x)
const
751 {
return count<key_type>(__x); }
753 template<
typename _Key2>
754 requires same_as<_Key2, _Key> || __transparent_comparator<_Compare>
758 count(
const _Key2& __x)
const
760 if constexpr (!_Multi)
761 return contains<_Key2>(__x);
764 auto [__first, __last] = equal_range(__x);
765 return __last - __first;
772 contains(
const key_type& __x)
const
773 {
return contains<key_type>(__x); }
775 template<
typename _Key2>
776 requires same_as<_Key2, _Key> || __transparent_comparator<_Compare>
780 contains(
const _Key2& __x)
const
781 {
return find(__x) != cend(); }
786 lower_bound(
const key_type& __x)
787 {
return lower_bound<key_type>(__x); }
792 lower_bound(
const key_type& __x)
const
793 {
return lower_bound<key_type>(__x); }
795 template<
typename _Key2>
796 requires same_as<_Key2, _Key> || __transparent_comparator<_Compare>
800 lower_bound(
const _Key2& __x)
801 {
return std::lower_bound(begin(), end(), __x, _M_comp); }
803 template<
typename _Key2>
804 requires same_as<_Key2, _Key> || __transparent_comparator<_Compare>
808 lower_bound(
const _Key2& __x)
const
809 {
return std::lower_bound(begin(), end(), __x, _M_comp); }
814 upper_bound(
const key_type& __x)
815 {
return upper_bound<key_type>(__x); }
820 upper_bound(
const key_type& __x)
const
821 {
return upper_bound<key_type>(__x); }
823 template<
typename _Key2>
824 requires same_as<_Key2, _Key> || __transparent_comparator<_Compare>
828 upper_bound(
const _Key2& __x)
829 {
return std::upper_bound(begin(), end(), __x, _M_comp); }
831 template<
typename _Key2>
832 requires same_as<_Key2, _Key> || __transparent_comparator<_Compare>
836 upper_bound(
const _Key2& __x)
const
837 {
return std::upper_bound(begin(), end(), __x, _M_comp); }
841 pair<iterator, iterator>
842 equal_range(
const key_type& __x)
843 {
return equal_range<key_type>(__x); }
847 pair<const_iterator, const_iterator>
848 equal_range(
const key_type& __x)
const
849 {
return equal_range<key_type>(__x); }
851 template<
typename _Key2>
852 requires same_as<_Key2, _Key> || __transparent_comparator<_Compare>
855 pair<iterator, iterator>
856 equal_range(
const _Key2& __x)
857 {
return std::equal_range(begin(), end(), __x, _M_comp); }
859 template<
typename _Key2>
860 requires same_as<_Key2, _Key> || __transparent_comparator<_Compare>
863 pair<const_iterator, const_iterator>
864 equal_range(
const _Key2& __x)
const
865 {
return std::equal_range(begin(), end(), __x, _M_comp); }
868 friend _GLIBCXX26_CONSTEXPR
bool
869 operator==(
const _Derived& __x,
const _Derived& __y)
870 {
return std::equal(__x.begin(), __x.end(), __y.begin(), __y.end()); }
872 template<
typename _Up = value_type>
874 friend _GLIBCXX26_CONSTEXPR __detail::__synth3way_t<_Up>
875 operator<=>(
const _Derived& __x,
const _Derived& __y)
878 __y.begin(), __y.end(),
879 __detail::__synth3way);
882 friend _GLIBCXX26_CONSTEXPR
void
883 swap(_Derived& __x, _Derived& __y)
noexcept(
noexcept(__x.swap(__y)))
884 {
return __x.swap(__y); }
886 template<
typename _Predicate>
889 _M_erase_if(_Predicate __pred)
891 auto __guard = _M_make_clear_guard();
892 auto __first = _M_cont.begin();
893 auto __last = _M_cont.end();
894 __first = std::remove_if(__first, __last, __pred);
895 auto __n = __last - __first;
896 erase(__first, __last);
897 __guard._M_disable();
902 container_type _M_cont;
903 [[no_unique_address]] _Compare _M_comp;
909 std::sort(_M_cont.begin(), _M_cont.end(), _M_comp);
910 if constexpr (!_Multi)
916 _M_unique()
requires (!_Multi)
921 __key_equiv(key_compare __c) : _M_comp(__c) { }
925 operator()(const_reference __x, const_reference __y)
const
926 {
return !_M_comp(__x, __y) && !_M_comp(__y, __x); }
928 [[no_unique_address]] key_compare _M_comp;
931 auto __first = _M_cont.begin();
932 auto __last = _M_cont.end();
933 __first = std::unique(__first, __last, __key_equiv(_M_comp));
934 _M_cont.erase(__first, __last);
942 template<
typename _Key,
typename _Compare = less<_Key>,
943 typename _KeyContainer = vector<_Key>>
945 :
private _Flat_set_impl<_Key, _Compare, _KeyContainer, false>
947 using _Impl = _Flat_set_impl<_Key, _Compare, _KeyContainer, false>;
952 using typename _Impl::key_type;
953 using typename _Impl::value_type;
954 using typename _Impl::key_compare;
955 using typename _Impl::reference;
956 using typename _Impl::const_reference;
957 using typename _Impl::size_type;
958 using typename _Impl::difference_type;
959 using typename _Impl::iterator;
960 using typename _Impl::const_iterator;
961 using typename _Impl::reverse_iterator;
962 using typename _Impl::const_reverse_iterator;
963 using typename _Impl::container_type;
964 using typename _Impl::value_compare;
972 using _Impl::operator=;
982 using _Impl::crbegin;
988 using _Impl::max_size;
991 using _Impl::emplace;
992 using _Impl::emplace_hint;
994 using _Impl::insert_range;
995 using _Impl::extract;
996 using _Impl::replace;
1002 using _Impl::key_comp;
1003 using _Impl::value_comp;
1008 using _Impl::contains;
1009 using _Impl::lower_bound;
1010 using _Impl::upper_bound;
1011 using _Impl::equal_range;
1013 using _Impl::_M_erase_if;
1016 template<
typename _KeyContainer,
1018 flat_set(_KeyContainer, _Compare = _Compare())
1019 -> flat_set<typename _KeyContainer::value_type, _Compare, _KeyContainer>;
1021 template<
typename _KeyContainer, __allocator_for<_KeyContainer> _Alloc>
1022 flat_set(_KeyContainer, _Alloc)
1023 -> flat_set<
typename _KeyContainer::value_type,
1026 template<
typename _KeyContainer, __not_allocator_like _Compare,
1027 __allocator_for<_KeyContainer> _Alloc>
1028 flat_set(_KeyContainer, _Compare, _Alloc)
1029 -> flat_set<typename _KeyContainer::value_type, _Compare, _KeyContainer>;
1031 template<
typename _KeyContainer,
1033 flat_set(sorted_unique_t, _KeyContainer, _Compare = _Compare())
1034 -> flat_set<typename _KeyContainer::value_type, _Compare, _KeyContainer>;
1036 template<
typename _KeyContainer, __allocator_for<_KeyContainer> _Alloc>
1037 flat_set(sorted_unique_t, _KeyContainer, _Alloc)
1038 -> flat_set<
typename _KeyContainer::value_type,
1041 template<
typename _KeyContainer, __not_allocator_like _Compare,
1042 __allocator_for<_KeyContainer> _Alloc>
1043 flat_set(sorted_unique_t, _KeyContainer, _Compare, _Alloc)
1044 -> flat_set<typename _KeyContainer::value_type, _Compare, _KeyContainer>;
1046 template<__has_input_iter_cat _InputIterator,
1048 flat_set(_InputIterator, _InputIterator, _Compare = _Compare())
1049 -> flat_set<__iter_key_t<_InputIterator>, __iter_val_t<_InputIterator>, _Compare>;
1051 template<__has_input_iter_cat _InputIterator,
1053 flat_set(sorted_unique_t, _InputIterator, _InputIterator, _Compare = _Compare())
1054 -> flat_set<__iter_key_t<_InputIterator>, __iter_val_t<_InputIterator>, _Compare>;
1059 flat_set(from_range_t, _Rg&&, _Compare = _Compare(), _Alloc = _Alloc())
1060 -> flat_set<ranges::range_value_t<_Rg>, _Compare,
1062 __alloc_rebind<_Alloc, ranges::range_value_t<_Rg>>>>;
1064 template<ranges::input_range _Rg, __allocator_like _Alloc>
1065 flat_set(from_range_t, _Rg&&, _Alloc)
1068 __alloc_rebind<_Alloc, ranges::range_value_t<_Rg>>>>;
1070 template<
typename _Key, __not_allocator_like _Compare = less<_Key>>
1072 -> flat_set<_Key, _Compare>;
1074 template<
typename _Key, __not_allocator_like _Compare = less<_Key>>
1076 -> flat_set<_Key, _Compare>;
1078 template<
typename _Key,
typename _Compare,
1079 typename _KeyContainer,
typename _Alloc>
1080 struct uses_allocator<flat_set<_Key, _Compare, _KeyContainer>, _Alloc>
1081 : bool_constant<uses_allocator_v<_KeyContainer, _Alloc>>
1084 template<
typename _Key,
typename _Compare,
typename _KeyContainer,
1085 typename _Predicate>
1086 _GLIBCXX26_CONSTEXPR
1087 typename flat_set<_Key, _Compare, _KeyContainer>::size_type
1088 erase_if(flat_set<_Key, _Compare, _KeyContainer>& __c, _Predicate __pred)
1089 {
return __c._M_erase_if(
std::move(__pred)); }
1095 template<
typename _Key,
typename _Compare = less<_Key>,
1096 typename _KeyContainer = vector<_Key>>
1098 :
private _Flat_set_impl<_Key, _Compare, _KeyContainer, true>
1100 using _Impl = _Flat_set_impl<_Key, _Compare, _KeyContainer, true>;
1105 using typename _Impl::key_type;
1106 using typename _Impl::value_type;
1107 using typename _Impl::key_compare;
1108 using typename _Impl::reference;
1109 using typename _Impl::const_reference;
1110 using typename _Impl::size_type;
1111 using typename _Impl::difference_type;
1112 using typename _Impl::iterator;
1113 using typename _Impl::const_iterator;
1114 using typename _Impl::reverse_iterator;
1115 using typename _Impl::const_reverse_iterator;
1116 using typename _Impl::container_type;
1117 using typename _Impl::value_compare;
1125 using _Impl::operator=;
1130 using _Impl::rbegin;
1133 using _Impl::cbegin;
1135 using _Impl::crbegin;
1141 using _Impl::max_size;
1144 using _Impl::emplace;
1145 using _Impl::emplace_hint;
1146 using _Impl::insert;
1147 using _Impl::insert_range;
1148 using _Impl::extract;
1149 using _Impl::replace;
1155 using _Impl::key_comp;
1156 using _Impl::value_comp;
1161 using _Impl::contains;
1162 using _Impl::lower_bound;
1163 using _Impl::upper_bound;
1164 using _Impl::equal_range;
1166 using _Impl::_M_erase_if;
1169 template<
typename _KeyContainer,
1171 flat_multiset(_KeyContainer, _Compare = _Compare())
1172 -> flat_multiset<typename _KeyContainer::value_type, _Compare, _KeyContainer>;
1174 template<
typename _KeyContainer, __allocator_for<_KeyContainer> _Alloc>
1175 flat_multiset(_KeyContainer, _Alloc)
1176 -> flat_multiset<
typename _KeyContainer::value_type,
1179 template<
typename _KeyContainer, __not_allocator_like _Compare,
1180 __allocator_for<_KeyContainer> _Alloc>
1181 flat_multiset(_KeyContainer, _Compare, _Alloc)
1182 -> flat_multiset<typename _KeyContainer::value_type, _Compare, _KeyContainer>;
1184 template<
typename _KeyContainer,
1186 flat_multiset(sorted_equivalent_t, _KeyContainer, _Compare = _Compare())
1187 -> flat_multiset<typename _KeyContainer::value_type, _Compare, _KeyContainer>;
1189 template<
typename _KeyContainer, __allocator_for<_KeyContainer> _Alloc>
1190 flat_multiset(sorted_equivalent_t, _KeyContainer, _Alloc)
1191 -> flat_multiset<
typename _KeyContainer::value_type,
1194 template<
typename _KeyContainer, __not_allocator_like _Compare,
1195 __allocator_for<_KeyContainer> _Alloc>
1196 flat_multiset(sorted_equivalent_t, _KeyContainer, _Compare, _Alloc)
1197 -> flat_multiset<typename _KeyContainer::value_type, _Compare, _KeyContainer>;
1199 template<__has_input_iter_cat _InputIterator,
1201 flat_multiset(_InputIterator, _InputIterator, _Compare = _Compare())
1202 -> flat_multiset<__iter_key_t<_InputIterator>, __iter_val_t<_InputIterator>, _Compare>;
1204 template<__has_input_iter_cat _InputIterator,
1206 flat_multiset(sorted_equivalent_t, _InputIterator, _InputIterator, _Compare = _Compare())
1207 -> flat_multiset<__iter_key_t<_InputIterator>, __iter_val_t<_InputIterator>, _Compare>;
1212 flat_multiset(from_range_t, _Rg&&, _Compare = _Compare(), _Alloc = _Alloc())
1213 -> flat_multiset<ranges::range_value_t<_Rg>, _Compare,
1215 __alloc_rebind<_Alloc, ranges::range_value_t<_Rg>>>>;
1217 template<ranges::input_range _Rg, __allocator_like _Alloc>
1218 flat_multiset(from_range_t, _Rg&&, _Alloc)
1221 __alloc_rebind<_Alloc, ranges::range_value_t<_Rg>>>>;
1223 template<
typename _Key, __not_allocator_like _Compare = less<_Key>>
1225 -> flat_multiset<_Key, _Compare>;
1227 template<
typename _Key, __not_allocator_like _Compare = less<_Key>>
1229 -> flat_multiset<_Key, _Compare>;
1231 template<
typename _Key,
typename _Compare,
1232 typename _KeyContainer,
typename _Alloc>
1233 struct uses_allocator<flat_multiset<_Key, _Compare, _KeyContainer>, _Alloc>
1234 : bool_constant<uses_allocator_v<_KeyContainer, _Alloc>>
1237 template<
typename _Key,
typename _Compare,
typename _KeyContainer,
1238 typename _Predicate>
1239 _GLIBCXX26_CONSTEXPR
1240 typename flat_multiset<_Key, _Compare, _KeyContainer>::size_type
1241 erase_if(flat_multiset<_Key, _Compare, _KeyContainer>& __c, _Predicate __pred)
1242 {
return __c._M_erase_if(
std::move(__pred)); }
1244_GLIBCXX_END_NAMESPACE_VERSION
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
constexpr _Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
constexpr _Tp && forward(typename std::remove_reference< _Tp >::type &__t) noexcept
Forward an lvalue.
constexpr auto lexicographical_compare_three_way(_InputIter1 __first1, _InputIter1 __last1, _InputIter2 __first2, _InputIter2 __last2, _Comp __comp) -> decltype(__comp(*__first1, *__first2))
Performs dictionary comparison on ranges.
constexpr reverse_iterator< _Iterator > make_reverse_iterator(_Iterator __i)
Generator function for reverse_iterator.
ISO C++ entities toplevel namespace is std.
The standard allocator, as per C++03 [20.4.1].
Declare uses_allocator so it can be specialized in <queue> etc.
One of the comparison functors.
A standard container which offers fixed time access to individual elements in any order.
A range for which ranges::begin returns an input iterator.