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
59namespace std _GLIBCXX_VISIBILITY(default)
61_GLIBCXX_BEGIN_NAMESPACE_VERSION
63 template<
typename _Key,
typename _Compare,
64 typename _KeyContainer>
67 template<
typename _Key,
typename _Compare,
68 typename _KeyContainer>
71 template<
typename _Key,
typename _Compare,
typename _KeyContainer,
bool _Multi>
74 static_assert(is_same_v<_Key, typename _KeyContainer::value_type>);
75 static_assert(is_nothrow_swappable_v<_KeyContainer>);
77 using _Derived = __conditional_t<_Multi,
78 flat_multiset<_Key, _Compare, _KeyContainer>,
79 flat_set<_Key, _Compare, _KeyContainer>>;
80 using __sorted_t = __conditional_t<_Multi, sorted_equivalent_t, sorted_unique_t>;
83 using key_type = _Key;
84 using value_type = _Key;
85 using key_compare = _Compare;
86 using value_compare = _Compare;
87 using reference = value_type&;
88 using const_reference =
const value_type&;
89 using size_type =
typename _KeyContainer::size_type;
90 using difference_type =
typename _KeyContainer::difference_type;
91 using iterator =
typename _KeyContainer::const_iterator;
92 using const_iterator =
typename _KeyContainer::const_iterator;
93 using reverse_iterator = std::reverse_iterator<iterator>;
94 using const_reverse_iterator = std::reverse_iterator<const_iterator>;
95 using container_type = _KeyContainer;
98 using __emplace_result_t = __conditional_t<_Multi, iterator, pair<iterator, bool>>;
102 container_type* _M_cont;
105 _ClearGuard(container_type& __cont)
119 { _M_cont =
nullptr; }
124 _M_make_clear_guard()
125 {
return _ClearGuard{this->_M_cont}; }
130 _Flat_set_impl() : _Flat_set_impl(key_compare()) { }
134 _Flat_set_impl(
const key_compare& __comp)
135 : _M_cont(), _M_comp(__comp)
139 _Flat_set_impl(container_type __cont,
const key_compare& __comp = key_compare())
140 : _M_cont(std::move(__cont)), _M_comp(__comp)
144 _Flat_set_impl(__sorted_t,
145 container_type __cont,
const key_compare& __comp = key_compare())
146 : _M_cont(std::move(__cont)), _M_comp(__comp)
147 { _GLIBCXX_DEBUG_ASSERT(ranges::is_sorted(_M_cont, _M_comp)); }
149 template<__has_input_iter_cat _InputIterator>
151 _Flat_set_impl(_InputIterator __first, _InputIterator __last,
152 const key_compare& __comp = key_compare())
153 : _M_cont(), _M_comp(__comp)
154 { insert(__first, __last); }
156 template<__has_input_iter_cat _InputIterator>
158 _Flat_set_impl(__sorted_t __s,
159 _InputIterator __first, _InputIterator __last,
160 const key_compare& __comp = key_compare())
161 : _M_cont(), _M_comp(__comp)
162 { insert(__s, __first, __last); }
164 template<__detail::__container_compatible_range<value_type> _Rg>
166 _Flat_set_impl(from_range_t, _Rg&& __rg)
167 : _Flat_set_impl(from_range, std::
forward<_Rg>(__rg), key_compare())
170 template<__detail::__container_compatible_range<value_type> _Rg>
172 _Flat_set_impl(from_range_t, _Rg&& __rg,
const key_compare& __comp)
173 : _Flat_set_impl(__comp)
177 _Flat_set_impl(initializer_list<value_type> __il,
178 const key_compare& __comp = key_compare())
179 : _Flat_set_impl(__il.begin(), __il.end(), __comp)
183 _Flat_set_impl(__sorted_t __s,
184 initializer_list<value_type> __il,
185 const key_compare& __comp = key_compare())
186 : _Flat_set_impl(__s, __il.begin(), __il.end(), __comp)
191 template<__allocator_for<container_type> _Alloc>
194 _Flat_set_impl(
const _Alloc& __a)
195 : _Flat_set_impl(key_compare(), __a)
198 template<__allocator_for<container_type> _Alloc>
200 _Flat_set_impl(
const key_compare& __comp,
const _Alloc& __a)
201 : _M_cont(std::make_obj_using_allocator<container_type>(__a)),
205 template<__allocator_for<container_type> _Alloc>
207 _Flat_set_impl(
const container_type& __cont,
const _Alloc& __a)
208 : _Flat_set_impl(__cont, key_compare(), __a)
211 template<__allocator_for<container_type> _Alloc>
213 _Flat_set_impl(
const container_type& __cont,
const key_compare& __comp,
215 : _M_cont(std::make_obj_using_allocator<container_type>(__a, __cont)),
219 template<__allocator_for<container_type> _Alloc>
221 _Flat_set_impl(__sorted_t __s,
const container_type& __cont,
const _Alloc& __a)
222 : _Flat_set_impl(__s, __cont, key_compare(), __a)
225 template<__allocator_for<container_type> _Alloc>
227 _Flat_set_impl(__sorted_t,
const container_type& __cont,
const key_compare& __comp,
229 : _M_cont(std::make_obj_using_allocator<container_type>(__a, __cont)),
231 { _GLIBCXX_DEBUG_ASSERT(ranges::is_sorted(_M_cont, _M_comp)); }
233 template<__allocator_for<container_type> _Alloc>
235 _Flat_set_impl(
const _Derived& __x,
const _Alloc& __a)
236 : _M_cont(std::make_obj_using_allocator<container_type>(__a, __x._M_cont)),
240 template<__allocator_for<container_type> _Alloc>
242 _Flat_set_impl(_Derived&& __x,
const _Alloc& __a)
243 : _M_cont(std::make_obj_using_allocator<container_type>(__a, std::move(__x._M_cont))),
247 template<__has_input_iter_cat _InputIterator, __allocator_for<container_type> _Alloc>
249 _Flat_set_impl(_InputIterator __first, _InputIterator __last,
251 : _Flat_set_impl(std::move(__first), std::move(__last), key_compare(), __a)
254 template<__has_input_iter_cat _InputIterator, __allocator_for<container_type> _Alloc>
256 _Flat_set_impl(_InputIterator __first, _InputIterator __last,
257 const key_compare& __comp,
259 : _Flat_set_impl(__comp, __a)
260 { insert(__first, __last); }
262 template<__has_input_iter_cat _InputIterator, __allocator_for<container_type> _Alloc>
264 _Flat_set_impl(__sorted_t __s,
265 _InputIterator __first, _InputIterator __last,
267 : _Flat_set_impl(__s, std::move(__first), std::move(__last), key_compare(), __a)
270 template<__has_input_iter_cat _InputIterator, __allocator_for<container_type> _Alloc>
272 _Flat_set_impl(__sorted_t __s,
273 _InputIterator __first, _InputIterator __last,
274 const key_compare& __comp,
276 : _Flat_set_impl(__comp, __a)
277 { insert(__s, __first, __last); }
279 template<__detail::__container_compatible_range<value_type> _Rg,
280 __allocator_for<container_type> _Alloc>
282 _Flat_set_impl(from_range_t, _Rg&& __rg,
284 : _Flat_set_impl(from_range, std::
forward<_Rg>(__rg), key_compare(), __a)
287 template<__detail::__container_compatible_range<value_type> _Rg,
288 __allocator_for<container_type> _Alloc>
290 _Flat_set_impl(from_range_t, _Rg&& __rg,
291 const key_compare& __comp,
293 : _Flat_set_impl(__comp, __a)
296 template<__allocator_for<container_type> _Alloc>
298 _Flat_set_impl(initializer_list<value_type> __il,
300 : _Flat_set_impl(__il, key_compare(), __a)
303 template<__allocator_for<container_type> _Alloc>
305 _Flat_set_impl(initializer_list<value_type> __il,
306 const key_compare& __comp,
308 : _Flat_set_impl(__il.begin(), __il.end(), __comp, __a)
311 template<__allocator_for<container_type> _Alloc>
313 _Flat_set_impl(__sorted_t __s,
314 initializer_list<value_type> __il,
316 : _Flat_set_impl(__s, __il.begin(), __il.end(), key_compare(), __a)
319 template<__allocator_for<container_type> _Alloc>
321 _Flat_set_impl(__sorted_t __s,
322 initializer_list<value_type> __il,
323 const key_compare& __comp,
325 : _Flat_set_impl(__s, __il.begin(), __il.end(), __comp, __a)
330 operator=(initializer_list<value_type> __il)
332 auto __guard = _M_make_clear_guard();
335 __guard._M_disable();
336 return static_cast<_Derived&
>(*this);
342 begin() const noexcept
343 {
return _M_cont.begin(); }
348 {
return _M_cont.end(); }
351 const_reverse_iterator
352 rbegin() const noexcept
353 {
return const_reverse_iterator(end()); }
356 const_reverse_iterator
357 rend() const noexcept
358 {
return const_reverse_iterator(begin()); }
362 cbegin() const noexcept
367 cend() const noexcept
371 const_reverse_iterator
372 crbegin() const noexcept
376 const_reverse_iterator
377 crend() const noexcept
384 empty() const noexcept
385 {
return _M_cont.empty(); }
389 size() const noexcept
390 {
return _M_cont.size(); }
394 max_size() const noexcept
395 {
return _M_cont.max_size(); }
398 template<
typename _Arg,
typename... _Args>
401 _M_try_emplace(optional<const_iterator> __hint, _Arg&& __arg, _Args&&... __args)
404 auto&& __k = [&] ->
decltype(
auto) {
405 if constexpr (
sizeof...(_Args) == 0
406 && same_as<remove_cvref_t<_Arg>, value_type>)
412 typename container_type::iterator __it;
413 int __r = -1, __s = -1;
414 if (__hint.has_value()
415 && (__hint == cbegin()
416 || (__r = !_M_comp(__k, (*__hint)[-1])))
418 || (__s = !_M_comp((*__hint)[0], __k))))
420 __it = _M_cont.begin() + (*__hint - begin());
421 if constexpr (!_Multi)
422 if (__r == 1 && !_M_comp(__it[-1], __k))
423 return {__it - 1,
false};
427 auto __first = _M_cont.begin();
428 auto __last = _M_cont.end();
430 __first += *__hint - _M_cont.begin();
432 __last = __first + (*__hint - _M_cont.begin());
433 if constexpr (_Multi)
437 __it = std::lower_bound(__first, __last, __k, _M_comp);
442 __k, std::not_fn(_M_comp)).base();
445 __it = std::lower_bound(__first, __last, __k, _M_comp);
448 if constexpr (!_Multi)
449 if (__it != _M_cont.end() && !_M_comp(__k, __it[0]))
450 return {__it,
false};
452 auto __guard = _M_make_clear_guard();
453 __it = _M_cont.insert(__it,
std::forward<
decltype(__k)>(__k));
454 __guard._M_disable();
458 template<
typename... _Args>
461 _M_try_emplace(optional<const_iterator> __hint)
462 {
return _M_try_emplace(__hint, value_type()); }
464 template<
typename... _Args>
465 requires is_constructible_v<value_type, _Args...>
468 emplace(_Args&&... __args)
471 if constexpr (_Multi)
477 template<
typename... _Args>
480 emplace_hint(const_iterator __position, _Args&&... __args)
485 insert(
const value_type& __x)
486 {
return emplace(__x); }
490 insert(value_type&& __x)
495 insert(const_iterator __position,
const value_type& __x)
496 {
return emplace_hint(__position, __x); }
500 insert(const_iterator __position, value_type&& __x)
501 {
return emplace_hint(__position,
std::move(__x)); }
503 template<
typename _Arg>
504 requires is_constructible_v<value_type, _Arg>
510 template<
typename _Arg>
511 requires is_constructible_v<value_type, _Arg>
514 insert(const_iterator __position, _Arg&& __x)
517 template<__has_input_iter_cat _InputIterator>
520 insert(_InputIterator __first, _InputIterator __last)
522 auto __guard = _M_make_clear_guard();
523 auto __it = _M_cont.insert(_M_cont.end(), __first, __last);
524 std::sort(__it, _M_cont.end(), _M_comp);
525 std::inplace_merge(_M_cont.begin(), __it, _M_cont.end(), _M_comp);
526 if constexpr (!_Multi)
528 __guard._M_disable();
531 template<__has_input_iter_cat _InputIterator>
534 insert(__sorted_t, _InputIterator __first, _InputIterator __last)
536 auto __guard = _M_make_clear_guard();
537 auto __it = _M_cont.insert(_M_cont.end(), __first, __last);
538 std::inplace_merge(_M_cont.begin(), __it, _M_cont.end(), _M_comp);
539 if constexpr (!_Multi)
541 __guard._M_disable();
544 template<__detail::__container_compatible_range<value_type> _Rg>
547 insert_range(_Rg&& __rg)
549 auto __guard = _M_make_clear_guard();
550 typename container_type::iterator __it;
551 if constexpr (
requires { _M_cont.insert_range(_M_cont.end(), __rg); })
552 __it = _M_cont.insert_range(_M_cont.end(), __rg);
553 else if constexpr (ranges::common_range<_Rg>
554 && __has_input_iter_cat<ranges::iterator_t<_Rg>>)
555 __it = _M_cont.insert(_M_cont.end(), ranges::begin(__rg), ranges::end(__rg));
558 size_type __n = size();
559 auto __first = ranges::begin(__rg);
560 auto __last = ranges::end(__rg);
561 for (; __first != __last; ++__first)
562 _M_cont.emplace_back(*__first);
563 __it = _M_cont.begin() + __n;
565 std::sort(__it, _M_cont.end(), _M_comp);
566 std::inplace_merge(_M_cont.begin(), __it, _M_cont.end(), _M_comp);
567 if constexpr (!_Multi)
569 __guard._M_disable();
574 insert(initializer_list<value_type> __il)
575 { insert(__il.begin(), __il.end()); }
579 insert(__sorted_t __s, initializer_list<value_type> __il)
580 { insert(__s, __il.begin(), __il.end()); }
586 auto __guard = _M_make_clear_guard();
592 replace(container_type&& __cont)
594 _GLIBCXX_DEBUG_ASSERT(ranges::is_sorted(__cont, _M_comp));
595 auto __guard = _M_make_clear_guard();
597 __guard._M_disable();
602 erase(const_iterator __position)
603 {
return _M_cont.erase(__position); }
607 erase(
const key_type& __x)
608 {
return erase<const key_type&>(__x); }
610 template<
typename _Key2>
611 requires same_as<remove_cvref_t<_Key2>, _Key>
612 || (__transparent_comparator<_Compare>
613 && !is_convertible_v<_Key2, iterator>
614 && !is_convertible_v<_Key2, const_iterator>)
620 auto __n = __last - __first;
621 erase(__first, __last);
627 erase(const_iterator __first, const_iterator __last)
628 {
return _M_cont.erase(__first, __last); }
632 swap(_Derived& __x)
noexcept
635 swap(_M_cont, __x._M_cont);
636 swap(_M_comp, __x._M_comp);
661 find(
const key_type& __x)
662 {
return find<key_type>(__x); }
667 find(
const key_type& __x)
const
668 {
return find<key_type>(__x); }
670 template<
typename _Key2>
671 requires same_as<_Key2, _Key> || __transparent_comparator<_Compare>
675 find(
const _Key2& __x)
677 auto __it = lower_bound(__x);
678 if (__it != end() && !_M_comp(__x, *__it))
684 template<
typename _Key2>
685 requires same_as<_Key2, _Key> || __transparent_comparator<_Compare>
689 find(
const _Key2& __x)
const
691 auto __it = lower_bound(__x);
692 if (__it != cend() && !_M_comp(__x, *__it))
701 count(
const key_type& __x)
const
702 {
return count<key_type>(__x); }
704 template<
typename _Key2>
705 requires same_as<_Key2, _Key> || __transparent_comparator<_Compare>
709 count(
const _Key2& __x)
const
711 if constexpr (!_Multi)
712 return contains<_Key2>(__x);
715 auto [__first, __last] = equal_range(__x);
716 return __last - __first;
723 contains(
const key_type& __x)
const
724 {
return contains<key_type>(__x); }
726 template<
typename _Key2>
727 requires same_as<_Key2, _Key> || __transparent_comparator<_Compare>
731 contains(
const _Key2& __x)
const
732 {
return find(__x) != cend(); }
737 lower_bound(
const key_type& __x)
738 {
return lower_bound<key_type>(__x); }
743 lower_bound(
const key_type& __x)
const
744 {
return lower_bound<key_type>(__x); }
746 template<
typename _Key2>
747 requires same_as<_Key2, _Key> || __transparent_comparator<_Compare>
751 lower_bound(
const _Key2& __x)
752 {
return std::lower_bound(begin(), end(), __x, _M_comp); }
754 template<
typename _Key2>
755 requires same_as<_Key2, _Key> || __transparent_comparator<_Compare>
759 lower_bound(
const _Key2& __x)
const
760 {
return std::lower_bound(begin(), end(), __x, _M_comp); }
765 upper_bound(
const key_type& __x)
766 {
return upper_bound<key_type>(__x); }
771 upper_bound(
const key_type& __x)
const
772 {
return upper_bound<key_type>(__x); }
774 template<
typename _Key2>
775 requires same_as<_Key2, _Key> || __transparent_comparator<_Compare>
779 upper_bound(
const _Key2& __x)
780 {
return std::upper_bound(begin(), end(), __x, _M_comp); }
782 template<
typename _Key2>
783 requires same_as<_Key2, _Key> || __transparent_comparator<_Compare>
787 upper_bound(
const _Key2& __x)
const
788 {
return std::upper_bound(begin(), end(), __x, _M_comp); }
792 pair<iterator, iterator>
793 equal_range(
const key_type& __x)
794 {
return equal_range<key_type>(__x); }
798 pair<const_iterator, const_iterator>
799 equal_range(
const key_type& __x)
const
800 {
return equal_range<key_type>(__x); }
802 template<
typename _Key2>
803 requires same_as<_Key2, _Key> || __transparent_comparator<_Compare>
806 pair<iterator, iterator>
807 equal_range(
const _Key2& __x)
808 {
return std::equal_range(begin(), end(), __x, _M_comp); }
810 template<
typename _Key2>
811 requires same_as<_Key2, _Key> || __transparent_comparator<_Compare>
814 pair<const_iterator, const_iterator>
815 equal_range(
const _Key2& __x)
const
816 {
return std::equal_range(begin(), end(), __x, _M_comp); }
819 friend _GLIBCXX26_CONSTEXPR
bool
820 operator==(
const _Derived& __x,
const _Derived& __y)
821 {
return std::equal(__x.begin(), __x.end(), __y.begin(), __y.end()); }
823 template<
typename _Up = value_type>
825 friend _GLIBCXX26_CONSTEXPR __detail::__synth3way_t<_Up>
826 operator<=>(
const _Derived& __x,
const _Derived& __y)
829 __y.begin(), __y.end(),
830 __detail::__synth3way);
833 friend _GLIBCXX26_CONSTEXPR
void
834 swap(_Derived& __x, _Derived& __y)
noexcept
835 {
return __x.swap(__y); }
837 template<
typename _Predicate>
840 _M_erase_if(_Predicate __pred)
842 auto __guard = _M_make_clear_guard();
843 auto __first = _M_cont.begin();
844 auto __last = _M_cont.end();
845 __first = std::remove_if(__first, __last, __pred);
846 auto __n = __last - __first;
847 erase(__first, __last);
848 __guard._M_disable();
853 container_type _M_cont;
854 [[no_unique_address]] _Compare _M_comp;
860 std::sort(_M_cont.begin(), _M_cont.end(), _M_comp);
861 if constexpr (!_Multi)
867 _M_unique()
requires (!_Multi)
872 __key_equiv(key_compare __c) : _M_comp(__c) { }
876 operator()(const_reference __x, const_reference __y)
const
877 {
return !_M_comp(__x, __y) && !_M_comp(__y, __x); }
879 [[no_unique_address]] key_compare _M_comp;
882 auto __first = _M_cont.begin();
883 auto __last = _M_cont.end();
884 __first = std::unique(__first, __last, __key_equiv(_M_comp));
885 _M_cont.erase(__first, __last);
893 template<
typename _Key,
typename _Compare = less<_Key>,
894 typename _KeyContainer = vector<_Key>>
896 :
private _Flat_set_impl<_Key, _Compare, _KeyContainer, false>
898 using _Impl = _Flat_set_impl<_Key, _Compare, _KeyContainer, false>;
903 using typename _Impl::key_type;
904 using typename _Impl::value_type;
905 using typename _Impl::key_compare;
906 using typename _Impl::reference;
907 using typename _Impl::const_reference;
908 using typename _Impl::size_type;
909 using typename _Impl::difference_type;
910 using typename _Impl::iterator;
911 using typename _Impl::const_iterator;
912 using typename _Impl::reverse_iterator;
913 using typename _Impl::const_reverse_iterator;
914 using typename _Impl::container_type;
915 using typename _Impl::value_compare;
928 using _Impl::crbegin;
934 using _Impl::max_size;
937 using _Impl::emplace;
938 using _Impl::emplace_hint;
940 using _Impl::insert_range;
941 using _Impl::extract;
942 using _Impl::replace;
948 using _Impl::key_comp;
949 using _Impl::value_comp;
954 using _Impl::contains;
955 using _Impl::lower_bound;
956 using _Impl::upper_bound;
957 using _Impl::equal_range;
959 using _Impl::_M_erase_if;
962 template<
typename _KeyContainer,
964 flat_set(_KeyContainer, _Compare = _Compare())
965 -> flat_set<typename _KeyContainer::value_type, _Compare, _KeyContainer>;
967 template<
typename _KeyContainer, __allocator_for<_KeyContainer> _Alloc>
968 flat_set(_KeyContainer, _Alloc)
969 -> flat_set<
typename _KeyContainer::value_type,
972 template<
typename _KeyContainer, __not_allocator_like _Compare,
973 __allocator_for<_KeyContainer> _Alloc>
974 flat_set(_KeyContainer, _Compare, _Alloc)
975 -> flat_set<typename _KeyContainer::value_type, _Compare, _KeyContainer>;
977 template<
typename _KeyContainer,
979 flat_set(sorted_unique_t, _KeyContainer, _Compare = _Compare())
980 -> flat_set<typename _KeyContainer::value_type, _Compare, _KeyContainer>;
982 template<
typename _KeyContainer, __allocator_for<_KeyContainer> _Alloc>
983 flat_set(sorted_unique_t, _KeyContainer, _Alloc)
984 -> flat_set<
typename _KeyContainer::value_type,
987 template<
typename _KeyContainer, __not_allocator_like _Compare,
988 __allocator_for<_KeyContainer> _Alloc>
989 flat_set(sorted_unique_t, _KeyContainer, _Compare, _Alloc)
990 -> flat_set<typename _KeyContainer::value_type, _Compare, _KeyContainer>;
992 template<__has_input_iter_cat _InputIterator,
994 flat_set(_InputIterator, _InputIterator, _Compare = _Compare())
995 -> flat_set<__iter_key_t<_InputIterator>, __iter_val_t<_InputIterator>, _Compare>;
997 template<__has_input_iter_cat _InputIterator,
999 flat_set(sorted_unique_t, _InputIterator, _InputIterator, _Compare = _Compare())
1000 -> flat_set<__iter_key_t<_InputIterator>, __iter_val_t<_InputIterator>, _Compare>;
1005 flat_set(from_range_t, _Rg&&, _Compare = _Compare(), _Alloc = _Alloc())
1006 -> flat_set<ranges::range_value_t<_Rg>, _Compare,
1008 __alloc_rebind<_Alloc, ranges::range_value_t<_Rg>>>>;
1010 template<ranges::input_range _Rg, __allocator_like _Alloc>
1011 flat_set(from_range_t, _Rg&&, _Alloc)
1014 __alloc_rebind<_Alloc, ranges::range_value_t<_Rg>>>>;
1016 template<
typename _Key, __not_allocator_like _Compare = less<_Key>>
1018 -> flat_set<_Key, _Compare>;
1020 template<
typename _Key, __not_allocator_like _Compare = less<_Key>>
1022 -> flat_set<_Key, _Compare>;
1024 template<
typename _Key,
typename _Compare,
1025 typename _KeyContainer,
typename _Alloc>
1026 struct uses_allocator<flat_set<_Key, _Compare, _KeyContainer>, _Alloc>
1027 : bool_constant<uses_allocator_v<_KeyContainer, _Alloc>>
1030 template<
typename _Key,
typename _Compare,
typename _KeyContainer,
1031 typename _Predicate>
1032 _GLIBCXX26_CONSTEXPR
1033 typename flat_set<_Key, _Compare, _KeyContainer>::size_type
1034 erase_if(flat_set<_Key, _Compare, _KeyContainer>& __c, _Predicate __pred)
1035 {
return __c._M_erase_if(
std::move(__pred)); }
1041 template<
typename _Key,
typename _Compare = less<_Key>,
1042 typename _KeyContainer = vector<_Key>>
1044 :
private _Flat_set_impl<_Key, _Compare, _KeyContainer, true>
1046 using _Impl = _Flat_set_impl<_Key, _Compare, _KeyContainer, true>;
1051 using typename _Impl::key_type;
1052 using typename _Impl::value_type;
1053 using typename _Impl::key_compare;
1054 using typename _Impl::reference;
1055 using typename _Impl::const_reference;
1056 using typename _Impl::size_type;
1057 using typename _Impl::difference_type;
1058 using typename _Impl::iterator;
1059 using typename _Impl::const_iterator;
1060 using typename _Impl::reverse_iterator;
1061 using typename _Impl::const_reverse_iterator;
1062 using typename _Impl::container_type;
1063 using typename _Impl::value_compare;
1071 using _Impl::rbegin;
1074 using _Impl::cbegin;
1076 using _Impl::crbegin;
1082 using _Impl::max_size;
1085 using _Impl::emplace;
1086 using _Impl::emplace_hint;
1087 using _Impl::insert;
1088 using _Impl::insert_range;
1089 using _Impl::extract;
1090 using _Impl::replace;
1096 using _Impl::key_comp;
1097 using _Impl::value_comp;
1102 using _Impl::contains;
1103 using _Impl::lower_bound;
1104 using _Impl::upper_bound;
1105 using _Impl::equal_range;
1107 using _Impl::_M_erase_if;
1110 template<
typename _KeyContainer,
1112 flat_multiset(_KeyContainer, _Compare = _Compare())
1113 -> flat_multiset<typename _KeyContainer::value_type, _Compare, _KeyContainer>;
1115 template<
typename _KeyContainer, __allocator_for<_KeyContainer> _Alloc>
1116 flat_multiset(_KeyContainer, _Alloc)
1117 -> flat_multiset<
typename _KeyContainer::value_type,
1120 template<
typename _KeyContainer, __not_allocator_like _Compare,
1121 __allocator_for<_KeyContainer> _Alloc>
1122 flat_multiset(_KeyContainer, _Compare, _Alloc)
1123 -> flat_multiset<typename _KeyContainer::value_type, _Compare, _KeyContainer>;
1125 template<
typename _KeyContainer,
1127 flat_multiset(sorted_equivalent_t, _KeyContainer, _Compare = _Compare())
1128 -> flat_multiset<typename _KeyContainer::value_type, _Compare, _KeyContainer>;
1130 template<
typename _KeyContainer, __allocator_for<_KeyContainer> _Alloc>
1131 flat_multiset(sorted_equivalent_t, _KeyContainer, _Alloc)
1132 -> flat_multiset<
typename _KeyContainer::value_type,
1135 template<
typename _KeyContainer, __not_allocator_like _Compare,
1136 __allocator_for<_KeyContainer> _Alloc>
1137 flat_multiset(sorted_equivalent_t, _KeyContainer, _Compare, _Alloc)
1138 -> flat_multiset<typename _KeyContainer::value_type, _Compare, _KeyContainer>;
1140 template<__has_input_iter_cat _InputIterator,
1142 flat_multiset(_InputIterator, _InputIterator, _Compare = _Compare())
1143 -> flat_multiset<__iter_key_t<_InputIterator>, __iter_val_t<_InputIterator>, _Compare>;
1145 template<__has_input_iter_cat _InputIterator,
1147 flat_multiset(sorted_equivalent_t, _InputIterator, _InputIterator, _Compare = _Compare())
1148 -> flat_multiset<__iter_key_t<_InputIterator>, __iter_val_t<_InputIterator>, _Compare>;
1153 flat_multiset(from_range_t, _Rg&&, _Compare = _Compare(), _Alloc = _Alloc())
1154 -> flat_multiset<ranges::range_value_t<_Rg>, _Compare,
1156 __alloc_rebind<_Alloc, ranges::range_value_t<_Rg>>>>;
1158 template<ranges::input_range _Rg, __allocator_like _Alloc>
1159 flat_multiset(from_range_t, _Rg&&, _Alloc)
1162 __alloc_rebind<_Alloc, ranges::range_value_t<_Rg>>>>;
1164 template<
typename _Key, __not_allocator_like _Compare = less<_Key>>
1166 -> flat_multiset<_Key, _Compare>;
1168 template<
typename _Key, __not_allocator_like _Compare = less<_Key>>
1170 -> flat_multiset<_Key, _Compare>;
1172 template<
typename _Key,
typename _Compare,
1173 typename _KeyContainer,
typename _Alloc>
1174 struct uses_allocator<flat_multiset<_Key, _Compare, _KeyContainer>, _Alloc>
1175 : bool_constant<uses_allocator_v<_KeyContainer, _Alloc>>
1178 template<
typename _Key,
typename _Compare,
typename _KeyContainer,
1179 typename _Predicate>
1180 _GLIBCXX26_CONSTEXPR
1181 typename flat_multiset<_Key, _Compare, _KeyContainer>::size_type
1182 erase_if(flat_multiset<_Key, _Compare, _KeyContainer>& __c, _Predicate __pred)
1183 {
return __c._M_erase_if(
std::move(__pred)); }
1185_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.