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>);
74 static_assert(is_nothrow_swappable_v<_KeyContainer>);
76 using _Derived = __conditional_t<_Multi,
77 flat_multiset<_Key, _Compare, _KeyContainer>,
78 flat_set<_Key, _Compare, _KeyContainer>>;
79 using __sorted_t = __conditional_t<_Multi, sorted_equivalent_t, sorted_unique_t>;
82 using key_type = _Key;
83 using value_type = _Key;
84 using key_compare = _Compare;
85 using value_compare = _Compare;
86 using reference = value_type&;
87 using const_reference =
const value_type&;
88 using size_type =
typename _KeyContainer::size_type;
89 using difference_type =
typename _KeyContainer::difference_type;
90 using iterator =
typename _KeyContainer::const_iterator;
91 using const_iterator =
typename _KeyContainer::const_iterator;
92 using reverse_iterator = std::reverse_iterator<iterator>;
93 using const_reverse_iterator = std::reverse_iterator<const_iterator>;
94 using container_type = _KeyContainer;
97 using __emplace_result_t = __conditional_t<_Multi, iterator, pair<iterator, bool>>;
101 container_type* _M_cont;
104 _ClearGuard(container_type& __cont)
118 { _M_cont =
nullptr; }
123 _M_make_clear_guard()
124 {
return _ClearGuard{this->_M_cont}; }
129 _Flat_set_impl() : _Flat_set_impl(key_compare()) { }
133 _Flat_set_impl(
const key_compare& __comp)
134 : _M_cont(), _M_comp(__comp)
138 _Flat_set_impl(container_type __cont,
const key_compare& __comp = key_compare())
139 : _M_cont(std::move(__cont)), _M_comp(__comp)
143 _Flat_set_impl(__sorted_t,
144 container_type __cont,
const key_compare& __comp = key_compare())
145 : _M_cont(std::move(__cont)), _M_comp(__comp)
146 { _GLIBCXX_DEBUG_ASSERT(ranges::is_sorted(_M_cont, _M_comp)); }
148 template<__has_input_iter_cat _InputIterator>
150 _Flat_set_impl(_InputIterator __first, _InputIterator __last,
151 const key_compare& __comp = key_compare())
152 : _M_cont(), _M_comp(__comp)
153 { insert(__first, __last); }
155 template<__has_input_iter_cat _InputIterator>
157 _Flat_set_impl(__sorted_t __s,
158 _InputIterator __first, _InputIterator __last,
159 const key_compare& __comp = key_compare())
160 : _M_cont(), _M_comp(__comp)
161 { insert(__s, __first, __last); }
163 template<__detail::__container_compatible_range<value_type> _Rg>
165 _Flat_set_impl(from_range_t, _Rg&& __rg)
166 : _Flat_set_impl(from_range, std::
forward<_Rg>(__rg), key_compare())
169 template<__detail::__container_compatible_range<value_type> _Rg>
171 _Flat_set_impl(from_range_t, _Rg&& __rg,
const key_compare& __comp)
172 : _Flat_set_impl(__comp)
176 _Flat_set_impl(initializer_list<value_type> __il,
177 const key_compare& __comp = key_compare())
178 : _Flat_set_impl(__il.begin(), __il.end(), __comp)
182 _Flat_set_impl(__sorted_t __s,
183 initializer_list<value_type> __il,
184 const key_compare& __comp = key_compare())
185 : _Flat_set_impl(__s, __il.begin(), __il.end(), __comp)
190 template<__allocator_for<container_type> _Alloc>
193 _Flat_set_impl(
const _Alloc& __a)
194 : _Flat_set_impl(key_compare(), __a)
197 template<__allocator_for<container_type> _Alloc>
199 _Flat_set_impl(
const key_compare& __comp,
const _Alloc& __a)
200 : _M_cont(std::make_obj_using_allocator<container_type>(__a)),
204 template<__allocator_for<container_type> _Alloc>
206 _Flat_set_impl(
const container_type& __cont,
const _Alloc& __a)
207 : _Flat_set_impl(__cont, key_compare(), __a)
210 template<__allocator_for<container_type> _Alloc>
212 _Flat_set_impl(
const container_type& __cont,
const key_compare& __comp,
214 : _M_cont(std::make_obj_using_allocator<container_type>(__a, __cont)),
218 template<__allocator_for<container_type> _Alloc>
220 _Flat_set_impl(__sorted_t __s,
const container_type& __cont,
const _Alloc& __a)
221 : _Flat_set_impl(__s, __cont, key_compare(), __a)
224 template<__allocator_for<container_type> _Alloc>
226 _Flat_set_impl(__sorted_t,
const container_type& __cont,
const key_compare& __comp,
228 : _M_cont(std::make_obj_using_allocator<container_type>(__a, __cont)),
230 { _GLIBCXX_DEBUG_ASSERT(ranges::is_sorted(_M_cont, _M_comp)); }
232 template<__allocator_for<container_type> _Alloc>
234 _Flat_set_impl(
const _Derived& __x,
const _Alloc& __a)
235 : _M_cont(std::make_obj_using_allocator<container_type>(__a, __x._M_cont)),
239 template<__allocator_for<container_type> _Alloc>
241 _Flat_set_impl(_Derived&& __x,
const _Alloc& __a)
242 : _M_cont(std::make_obj_using_allocator<container_type>(__a, std::move(__x._M_cont))),
246 template<__has_input_iter_cat _InputIterator, __allocator_for<container_type> _Alloc>
248 _Flat_set_impl(_InputIterator __first, _InputIterator __last,
250 : _Flat_set_impl(std::move(__first), std::move(__last), key_compare(), __a)
253 template<__has_input_iter_cat _InputIterator, __allocator_for<container_type> _Alloc>
255 _Flat_set_impl(_InputIterator __first, _InputIterator __last,
256 const key_compare& __comp,
258 : _Flat_set_impl(__comp, __a)
259 { insert(__first, __last); }
261 template<__has_input_iter_cat _InputIterator, __allocator_for<container_type> _Alloc>
263 _Flat_set_impl(__sorted_t __s,
264 _InputIterator __first, _InputIterator __last,
266 : _Flat_set_impl(__s, std::move(__first), std::move(__last), key_compare(), __a)
269 template<__has_input_iter_cat _InputIterator, __allocator_for<container_type> _Alloc>
271 _Flat_set_impl(__sorted_t __s,
272 _InputIterator __first, _InputIterator __last,
273 const key_compare& __comp,
275 : _Flat_set_impl(__comp, __a)
276 { insert(__s, __first, __last); }
278 template<__detail::__container_compatible_range<value_type> _Rg,
279 __allocator_for<container_type> _Alloc>
281 _Flat_set_impl(from_range_t, _Rg&& __rg,
283 : _Flat_set_impl(from_range, std::
forward<_Rg>(__rg), key_compare(), __a)
286 template<__detail::__container_compatible_range<value_type> _Rg,
287 __allocator_for<container_type> _Alloc>
289 _Flat_set_impl(from_range_t, _Rg&& __rg,
290 const key_compare& __comp,
292 : _Flat_set_impl(__comp, __a)
295 template<__allocator_for<container_type> _Alloc>
297 _Flat_set_impl(initializer_list<value_type> __il,
299 : _Flat_set_impl(__il, key_compare(), __a)
302 template<__allocator_for<container_type> _Alloc>
304 _Flat_set_impl(initializer_list<value_type> __il,
305 const key_compare& __comp,
307 : _Flat_set_impl(__il.begin(), __il.end(), __comp, __a)
310 template<__allocator_for<container_type> _Alloc>
312 _Flat_set_impl(__sorted_t __s,
313 initializer_list<value_type> __il,
315 : _Flat_set_impl(__s, __il.begin(), __il.end(), key_compare(), __a)
318 template<__allocator_for<container_type> _Alloc>
320 _Flat_set_impl(__sorted_t __s,
321 initializer_list<value_type> __il,
322 const key_compare& __comp,
324 : _Flat_set_impl(__s, __il.begin(), __il.end(), __comp, __a)
329 operator=(initializer_list<value_type> __il)
331 auto __guard = _M_make_clear_guard();
334 __guard._M_disable();
335 return static_cast<_Derived&
>(*this);
341 begin() const noexcept
342 {
return _M_cont.begin(); }
347 {
return _M_cont.end(); }
350 const_reverse_iterator
351 rbegin() const noexcept
352 {
return const_reverse_iterator(end()); }
355 const_reverse_iterator
356 rend() const noexcept
357 {
return const_reverse_iterator(begin()); }
361 cbegin() const noexcept
366 cend() const noexcept
370 const_reverse_iterator
371 crbegin() const noexcept
375 const_reverse_iterator
376 crend() const noexcept
383 empty() const noexcept
384 {
return _M_cont.empty(); }
388 size() const noexcept
389 {
return _M_cont.size(); }
393 max_size() const noexcept
394 {
return _M_cont.max_size(); }
397 template<
typename _Arg,
typename... _Args>
400 _M_try_emplace(optional<const_iterator> __hint, _Arg&& __arg, _Args&&... __args)
403 auto&& __k = [&] ->
decltype(
auto) {
404 if constexpr (
sizeof...(_Args) == 0
405 && same_as<remove_cvref_t<_Arg>, value_type>)
411 typename container_type::iterator __it;
412 int __r = -1, __s = -1;
413 if (__hint.has_value()
414 && (__hint == cbegin()
415 || (__r = !_M_comp(__k, (*__hint)[-1])))
417 || (__s = !_M_comp((*__hint)[0], __k))))
419 __it = _M_cont.begin() + (*__hint - begin());
420 if constexpr (!_Multi)
421 if (__r == 1 && !_M_comp(__it[-1], __k))
422 return {__it - 1,
false};
426 auto __first = _M_cont.begin();
427 auto __last = _M_cont.end();
429 __first += *__hint - _M_cont.begin();
431 __last = __first + (*__hint - _M_cont.begin());
432 if constexpr (_Multi)
436 __it = std::lower_bound(__first, __last, __k, _M_comp);
441 __k, std::not_fn(_M_comp)).base();
444 __it = std::lower_bound(__first, __last, __k, _M_comp);
447 if constexpr (!_Multi)
448 if (__it != _M_cont.end() && !_M_comp(__k, __it[0]))
449 return {__it,
false};
451 auto __guard = _M_make_clear_guard();
452 __it = _M_cont.insert(__it,
std::forward<
decltype(__k)>(__k));
453 __guard._M_disable();
457 template<
typename... _Args>
460 _M_try_emplace(optional<const_iterator> __hint)
461 {
return _M_try_emplace(__hint, value_type()); }
463 template<
typename... _Args>
464 requires is_constructible_v<value_type, _Args...>
467 emplace(_Args&&... __args)
470 if constexpr (_Multi)
476 template<
typename... _Args>
479 emplace_hint(const_iterator __position, _Args&&... __args)
484 insert(
const value_type& __x)
485 {
return emplace(__x); }
489 insert(value_type&& __x)
494 insert(const_iterator __position,
const value_type& __x)
495 {
return emplace_hint(__position, __x); }
499 insert(const_iterator __position, value_type&& __x)
500 {
return emplace_hint(__position,
std::move(__x)); }
502 template<
typename _Arg>
503 requires is_constructible_v<value_type, _Arg>
509 template<
typename _Arg>
510 requires is_constructible_v<value_type, _Arg>
513 insert(const_iterator __position, _Arg&& __x)
516 template<__has_input_iter_cat _InputIterator>
519 insert(_InputIterator __first, _InputIterator __last)
521 auto __guard = _M_make_clear_guard();
522 auto __it = _M_cont.insert(_M_cont.end(), __first, __last);
523 std::sort(__it, _M_cont.end(), _M_comp);
524 std::inplace_merge(_M_cont.begin(), __it, _M_cont.end(), _M_comp);
525 if constexpr (!_Multi)
527 __guard._M_disable();
530 template<__has_input_iter_cat _InputIterator>
533 insert(__sorted_t, _InputIterator __first, _InputIterator __last)
535 auto __guard = _M_make_clear_guard();
536 auto __it = _M_cont.insert(_M_cont.end(), __first, __last);
537 std::inplace_merge(_M_cont.begin(), __it, _M_cont.end(), _M_comp);
538 if constexpr (!_Multi)
540 __guard._M_disable();
543 template<__detail::__container_compatible_range<value_type> _Rg>
546 insert_range(_Rg&& __rg)
548 auto __guard = _M_make_clear_guard();
549 typename container_type::iterator __it;
550 if constexpr (
requires { _M_cont.insert_range(_M_cont.end(), __rg); })
551 __it = _M_cont.insert_range(_M_cont.end(), __rg);
552 else if constexpr (ranges::common_range<_Rg>
553 && __has_input_iter_cat<ranges::iterator_t<_Rg>>)
554 __it = _M_cont.insert(_M_cont.end(), ranges::begin(__rg), ranges::end(__rg));
557 size_type __n = size();
558 auto __first = ranges::begin(__rg);
559 auto __last = ranges::end(__rg);
560 for (; __first != __last; ++__first)
561 _M_cont.emplace_back(*__first);
562 __it = _M_cont.begin() + __n;
564 std::sort(__it, _M_cont.end(), _M_comp);
565 std::inplace_merge(_M_cont.begin(), __it, _M_cont.end(), _M_comp);
566 if constexpr (!_Multi)
568 __guard._M_disable();
573 insert(initializer_list<value_type> __il)
574 { insert(__il.begin(), __il.end()); }
578 insert(__sorted_t __s, initializer_list<value_type> __il)
579 { insert(__s, __il.begin(), __il.end()); }
585 auto __guard = _M_make_clear_guard();
591 replace(container_type&& __cont)
593 _GLIBCXX_DEBUG_ASSERT(ranges::is_sorted(__cont, _M_comp));
594 auto __guard = _M_make_clear_guard();
596 __guard._M_disable();
601 erase(const_iterator __position)
602 {
return _M_cont.erase(__position); }
606 erase(
const key_type& __x)
607 {
return erase<const key_type&>(__x); }
609 template<
typename _Key2>
610 requires same_as<remove_cvref_t<_Key2>, _Key>
611 || (__transparent_comparator<_Compare>
612 && !is_convertible_v<_Key2, iterator>
613 && !is_convertible_v<_Key2, const_iterator>)
619 auto __n = __last - __first;
620 erase(__first, __last);
626 erase(const_iterator __first, const_iterator __last)
627 {
return _M_cont.erase(__first, __last); }
631 swap(_Derived& __x)
noexcept
634 swap(_M_cont, __x._M_cont);
635 swap(_M_comp, __x._M_comp);
660 find(
const key_type& __x)
661 {
return find<key_type>(__x); }
666 find(
const key_type& __x)
const
667 {
return find<key_type>(__x); }
669 template<
typename _Key2>
670 requires same_as<_Key2, _Key> || __transparent_comparator<_Compare>
674 find(
const _Key2& __x)
676 auto __it = lower_bound(__x);
677 if (__it != end() && !_M_comp(__x, *__it))
683 template<
typename _Key2>
684 requires same_as<_Key2, _Key> || __transparent_comparator<_Compare>
688 find(
const _Key2& __x)
const
690 auto __it = lower_bound(__x);
691 if (__it != cend() && !_M_comp(__x, *__it))
700 count(
const key_type& __x)
const
701 {
return count<key_type>(__x); }
703 template<
typename _Key2>
704 requires same_as<_Key2, _Key> || __transparent_comparator<_Compare>
708 count(
const _Key2& __x)
const
710 if constexpr (!_Multi)
711 return contains<_Key2>(__x);
714 auto [__first, __last] = equal_range(__x);
715 return __last - __first;
722 contains(
const key_type& __x)
const
723 {
return contains<key_type>(__x); }
725 template<
typename _Key2>
726 requires same_as<_Key2, _Key> || __transparent_comparator<_Compare>
730 contains(
const _Key2& __x)
const
731 {
return find(__x) != cend(); }
736 lower_bound(
const key_type& __x)
737 {
return lower_bound<key_type>(__x); }
742 lower_bound(
const key_type& __x)
const
743 {
return lower_bound<key_type>(__x); }
745 template<
typename _Key2>
746 requires same_as<_Key2, _Key> || __transparent_comparator<_Compare>
750 lower_bound(
const _Key2& __x)
751 {
return std::lower_bound(begin(), end(), __x, _M_comp); }
753 template<
typename _Key2>
754 requires same_as<_Key2, _Key> || __transparent_comparator<_Compare>
758 lower_bound(
const _Key2& __x)
const
759 {
return std::lower_bound(begin(), end(), __x, _M_comp); }
764 upper_bound(
const key_type& __x)
765 {
return upper_bound<key_type>(__x); }
770 upper_bound(
const key_type& __x)
const
771 {
return upper_bound<key_type>(__x); }
773 template<
typename _Key2>
774 requires same_as<_Key2, _Key> || __transparent_comparator<_Compare>
778 upper_bound(
const _Key2& __x)
779 {
return std::upper_bound(begin(), end(), __x, _M_comp); }
781 template<
typename _Key2>
782 requires same_as<_Key2, _Key> || __transparent_comparator<_Compare>
786 upper_bound(
const _Key2& __x)
const
787 {
return std::upper_bound(begin(), end(), __x, _M_comp); }
791 pair<iterator, iterator>
792 equal_range(
const key_type& __x)
793 {
return equal_range<key_type>(__x); }
797 pair<const_iterator, const_iterator>
798 equal_range(
const key_type& __x)
const
799 {
return equal_range<key_type>(__x); }
801 template<
typename _Key2>
802 requires same_as<_Key2, _Key> || __transparent_comparator<_Compare>
805 pair<iterator, iterator>
806 equal_range(
const _Key2& __x)
807 {
return std::equal_range(begin(), end(), __x, _M_comp); }
809 template<
typename _Key2>
810 requires same_as<_Key2, _Key> || __transparent_comparator<_Compare>
813 pair<const_iterator, const_iterator>
814 equal_range(
const _Key2& __x)
const
815 {
return std::equal_range(begin(), end(), __x, _M_comp); }
818 friend _GLIBCXX26_CONSTEXPR
bool
819 operator==(
const _Derived& __x,
const _Derived& __y)
820 {
return std::equal(__x.begin(), __x.end(), __y.begin(), __y.end()); }
822 template<
typename _Up = value_type>
824 friend _GLIBCXX26_CONSTEXPR __detail::__synth3way_t<_Up>
825 operator<=>(
const _Derived& __x,
const _Derived& __y)
828 __y.begin(), __y.end(),
829 __detail::__synth3way);
832 friend _GLIBCXX26_CONSTEXPR
void
833 swap(_Derived& __x, _Derived& __y)
noexcept
834 {
return __x.swap(__y); }
836 template<
typename _Predicate>
839 _M_erase_if(_Predicate __pred)
841 auto __guard = _M_make_clear_guard();
842 auto __first = _M_cont.begin();
843 auto __last = _M_cont.end();
844 __first = std::remove_if(__first, __last, __pred);
845 auto __n = __last - __first;
846 erase(__first, __last);
847 __guard._M_disable();
852 container_type _M_cont;
853 [[no_unique_address]] _Compare _M_comp;
859 std::sort(_M_cont.begin(), _M_cont.end(), _M_comp);
860 if constexpr (!_Multi)
866 _M_unique()
requires (!_Multi)
871 __key_equiv(key_compare __c) : _M_comp(__c) { }
875 operator()(const_reference __x, const_reference __y)
const
876 {
return !_M_comp(__x, __y) && !_M_comp(__y, __x); }
878 [[no_unique_address]] key_compare _M_comp;
881 auto __first = _M_cont.begin();
882 auto __last = _M_cont.end();
883 __first = std::unique(__first, __last, __key_equiv(_M_comp));
884 _M_cont.erase(__first, __last);
892 template<
typename _Key,
typename _Compare = less<_Key>,
893 typename _KeyContainer = vector<_Key>>
895 :
private _Flat_set_impl<_Key, _Compare, _KeyContainer, false>
897 using _Impl = _Flat_set_impl<_Key, _Compare, _KeyContainer, false>;
902 using typename _Impl::key_type;
903 using typename _Impl::value_type;
904 using typename _Impl::key_compare;
905 using typename _Impl::reference;
906 using typename _Impl::const_reference;
907 using typename _Impl::size_type;
908 using typename _Impl::difference_type;
909 using typename _Impl::iterator;
910 using typename _Impl::const_iterator;
911 using typename _Impl::reverse_iterator;
912 using typename _Impl::const_reverse_iterator;
913 using typename _Impl::container_type;
914 using typename _Impl::value_compare;
927 using _Impl::crbegin;
933 using _Impl::max_size;
936 using _Impl::emplace;
937 using _Impl::emplace_hint;
939 using _Impl::insert_range;
940 using _Impl::extract;
941 using _Impl::replace;
947 using _Impl::key_comp;
948 using _Impl::value_comp;
953 using _Impl::contains;
954 using _Impl::lower_bound;
955 using _Impl::upper_bound;
956 using _Impl::equal_range;
958 using _Impl::_M_erase_if;
961 template<
typename _KeyContainer,
963 flat_set(_KeyContainer, _Compare = _Compare())
964 -> flat_set<typename _KeyContainer::value_type, _Compare, _KeyContainer>;
966 template<
typename _KeyContainer, __allocator_for<_KeyContainer> _Alloc>
967 flat_set(_KeyContainer, _Alloc)
968 -> flat_set<
typename _KeyContainer::value_type,
971 template<
typename _KeyContainer, __not_allocator_like _Compare,
972 __allocator_for<_KeyContainer> _Alloc>
973 flat_set(_KeyContainer, _Compare, _Alloc)
974 -> flat_set<typename _KeyContainer::value_type, _Compare, _KeyContainer>;
976 template<
typename _KeyContainer,
978 flat_set(sorted_unique_t, _KeyContainer, _Compare = _Compare())
979 -> flat_set<typename _KeyContainer::value_type, _Compare, _KeyContainer>;
981 template<
typename _KeyContainer, __allocator_for<_KeyContainer> _Alloc>
982 flat_set(sorted_unique_t, _KeyContainer, _Alloc)
983 -> flat_set<
typename _KeyContainer::value_type,
986 template<
typename _KeyContainer, __not_allocator_like _Compare,
987 __allocator_for<_KeyContainer> _Alloc>
988 flat_set(sorted_unique_t, _KeyContainer, _Compare, _Alloc)
989 -> flat_set<typename _KeyContainer::value_type, _Compare, _KeyContainer>;
991 template<__has_input_iter_cat _InputIterator,
993 flat_set(_InputIterator, _InputIterator, _Compare = _Compare())
994 -> flat_set<__iter_key_t<_InputIterator>, __iter_val_t<_InputIterator>, _Compare>;
996 template<__has_input_iter_cat _InputIterator,
998 flat_set(sorted_unique_t, _InputIterator, _InputIterator, _Compare = _Compare())
999 -> flat_set<__iter_key_t<_InputIterator>, __iter_val_t<_InputIterator>, _Compare>;
1004 flat_set(from_range_t, _Rg&&, _Compare = _Compare(), _Alloc = _Alloc())
1005 -> flat_set<ranges::range_value_t<_Rg>, _Compare,
1007 __alloc_rebind<_Alloc, ranges::range_value_t<_Rg>>>>;
1009 template<ranges::input_range _Rg, __allocator_like _Alloc>
1010 flat_set(from_range_t, _Rg&&, _Alloc)
1013 __alloc_rebind<_Alloc, ranges::range_value_t<_Rg>>>>;
1015 template<
typename _Key, __not_allocator_like _Compare = less<_Key>>
1017 -> flat_set<_Key, _Compare>;
1019 template<
typename _Key, __not_allocator_like _Compare = less<_Key>>
1021 -> flat_set<_Key, _Compare>;
1023 template<
typename _Key,
typename _Compare,
1024 typename _KeyContainer,
typename _Alloc>
1025 struct uses_allocator<flat_set<_Key, _Compare, _KeyContainer>, _Alloc>
1026 : bool_constant<uses_allocator_v<_KeyContainer, _Alloc>>
1029 template<
typename _Key,
typename _Compare,
typename _KeyContainer,
1030 typename _Predicate>
1031 _GLIBCXX26_CONSTEXPR
1032 typename flat_set<_Key, _Compare, _KeyContainer>::size_type
1033 erase_if(flat_set<_Key, _Compare, _KeyContainer>& __c, _Predicate __pred)
1034 {
return __c._M_erase_if(
std::move(__pred)); }
1040 template<
typename _Key,
typename _Compare = less<_Key>,
1041 typename _KeyContainer = vector<_Key>>
1043 :
private _Flat_set_impl<_Key, _Compare, _KeyContainer, true>
1045 using _Impl = _Flat_set_impl<_Key, _Compare, _KeyContainer, true>;
1050 using typename _Impl::key_type;
1051 using typename _Impl::value_type;
1052 using typename _Impl::key_compare;
1053 using typename _Impl::reference;
1054 using typename _Impl::const_reference;
1055 using typename _Impl::size_type;
1056 using typename _Impl::difference_type;
1057 using typename _Impl::iterator;
1058 using typename _Impl::const_iterator;
1059 using typename _Impl::reverse_iterator;
1060 using typename _Impl::const_reverse_iterator;
1061 using typename _Impl::container_type;
1062 using typename _Impl::value_compare;
1070 using _Impl::rbegin;
1073 using _Impl::cbegin;
1075 using _Impl::crbegin;
1081 using _Impl::max_size;
1084 using _Impl::emplace;
1085 using _Impl::emplace_hint;
1086 using _Impl::insert;
1087 using _Impl::insert_range;
1088 using _Impl::extract;
1089 using _Impl::replace;
1095 using _Impl::key_comp;
1096 using _Impl::value_comp;
1101 using _Impl::contains;
1102 using _Impl::lower_bound;
1103 using _Impl::upper_bound;
1104 using _Impl::equal_range;
1106 using _Impl::_M_erase_if;
1109 template<
typename _KeyContainer,
1111 flat_multiset(_KeyContainer, _Compare = _Compare())
1112 -> flat_multiset<typename _KeyContainer::value_type, _Compare, _KeyContainer>;
1114 template<
typename _KeyContainer, __allocator_for<_KeyContainer> _Alloc>
1115 flat_multiset(_KeyContainer, _Alloc)
1116 -> flat_multiset<
typename _KeyContainer::value_type,
1119 template<
typename _KeyContainer, __not_allocator_like _Compare,
1120 __allocator_for<_KeyContainer> _Alloc>
1121 flat_multiset(_KeyContainer, _Compare, _Alloc)
1122 -> flat_multiset<typename _KeyContainer::value_type, _Compare, _KeyContainer>;
1124 template<
typename _KeyContainer,
1126 flat_multiset(sorted_equivalent_t, _KeyContainer, _Compare = _Compare())
1127 -> flat_multiset<typename _KeyContainer::value_type, _Compare, _KeyContainer>;
1129 template<
typename _KeyContainer, __allocator_for<_KeyContainer> _Alloc>
1130 flat_multiset(sorted_equivalent_t, _KeyContainer, _Alloc)
1131 -> flat_multiset<
typename _KeyContainer::value_type,
1134 template<
typename _KeyContainer, __not_allocator_like _Compare,
1135 __allocator_for<_KeyContainer> _Alloc>
1136 flat_multiset(sorted_equivalent_t, _KeyContainer, _Compare, _Alloc)
1137 -> flat_multiset<typename _KeyContainer::value_type, _Compare, _KeyContainer>;
1139 template<__has_input_iter_cat _InputIterator,
1141 flat_multiset(_InputIterator, _InputIterator, _Compare = _Compare())
1142 -> flat_multiset<__iter_key_t<_InputIterator>, __iter_val_t<_InputIterator>, _Compare>;
1144 template<__has_input_iter_cat _InputIterator,
1146 flat_multiset(sorted_equivalent_t, _InputIterator, _InputIterator, _Compare = _Compare())
1147 -> flat_multiset<__iter_key_t<_InputIterator>, __iter_val_t<_InputIterator>, _Compare>;
1152 flat_multiset(from_range_t, _Rg&&, _Compare = _Compare(), _Alloc = _Alloc())
1153 -> flat_multiset<ranges::range_value_t<_Rg>, _Compare,
1155 __alloc_rebind<_Alloc, ranges::range_value_t<_Rg>>>>;
1157 template<ranges::input_range _Rg, __allocator_like _Alloc>
1158 flat_multiset(from_range_t, _Rg&&, _Alloc)
1161 __alloc_rebind<_Alloc, ranges::range_value_t<_Rg>>>>;
1163 template<
typename _Key, __not_allocator_like _Compare = less<_Key>>
1165 -> flat_multiset<_Key, _Compare>;
1167 template<
typename _Key, __not_allocator_like _Compare = less<_Key>>
1169 -> flat_multiset<_Key, _Compare>;
1171 template<
typename _Key,
typename _Compare,
1172 typename _KeyContainer,
typename _Alloc>
1173 struct uses_allocator<flat_multiset<_Key, _Compare, _KeyContainer>, _Alloc>
1174 : bool_constant<uses_allocator_v<_KeyContainer, _Alloc>>
1177 template<
typename _Key,
typename _Compare,
typename _KeyContainer,
1178 typename _Predicate>
1179 _GLIBCXX26_CONSTEXPR
1180 typename flat_multiset<_Key, _Compare, _KeyContainer>::size_type
1181 erase_if(flat_multiset<_Key, _Compare, _KeyContainer>& __c, _Predicate __pred)
1182 {
return __c._M_erase_if(
std::move(__pred)); }
1184_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.