56 #ifndef _STL_ALGOBASE_H 57 #define _STL_ALGOBASE_H 1 72 #if __cplusplus >= 201103L 75 #if __cplusplus > 201703L 79 namespace std _GLIBCXX_VISIBILITY(default)
81 _GLIBCXX_BEGIN_NAMESPACE_VERSION
87 template<
typename _Tp,
typename _Up>
90 __memcmp(
const _Tp* __first1,
const _Up* __first2,
size_t __num)
92 #if __cplusplus >= 201103L 93 static_assert(
sizeof(_Tp) ==
sizeof(_Up),
"can be compared with memcmp");
95 #ifdef __cpp_lib_is_constant_evaluated 96 if (std::is_constant_evaluated())
98 for(; __num > 0; ++__first1, ++__first2, --__num)
99 if (*__first1 != *__first2)
100 return *__first1 < *__first2 ? -1 : 1;
105 return __builtin_memcmp(__first1, __first2,
sizeof(_Tp) * __num);
108 #if __cplusplus < 201103L 112 template<
bool _BoolType>
115 template<
typename _ForwardIterator1,
typename _ForwardIterator2>
117 iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b)
119 typedef typename iterator_traits<_ForwardIterator1>::value_type
121 _ValueType1 __tmp = *__a;
128 struct __iter_swap<true>
130 template<
typename _ForwardIterator1,
typename _ForwardIterator2>
132 iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b)
149 template<
typename _ForwardIterator1,
typename _ForwardIterator2>
152 iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b)
155 __glibcxx_function_requires(_Mutable_ForwardIteratorConcept<
157 __glibcxx_function_requires(_Mutable_ForwardIteratorConcept<
160 #if __cplusplus < 201103L 166 __glibcxx_function_requires(_ConvertibleConcept<_ValueType1,
168 __glibcxx_function_requires(_ConvertibleConcept<_ValueType2,
175 std::__iter_swap<__are_same<_ValueType1, _ValueType2>::__value
176 && __are_same<_ValueType1&, _ReferenceType1>::__value
177 && __are_same<_ValueType2&, _ReferenceType2>::__value>::
198 template<
typename _ForwardIterator1,
typename _ForwardIterator2>
201 swap_ranges(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
202 _ForwardIterator2 __first2)
205 __glibcxx_function_requires(_Mutable_ForwardIteratorConcept<
207 __glibcxx_function_requires(_Mutable_ForwardIteratorConcept<
209 __glibcxx_requires_valid_range(__first1, __last1);
211 for (; __first1 != __last1; ++__first1, (void)++__first2)
227 template<
typename _Tp>
230 min(
const _Tp& __a,
const _Tp& __b)
233 __glibcxx_function_requires(_LessThanComparableConcept<_Tp>)
251 template<
typename _Tp>
254 max(
const _Tp& __a,
const _Tp& __b)
257 __glibcxx_function_requires(_LessThanComparableConcept<_Tp>)
275 template<
typename _Tp,
typename _Compare>
278 min(
const _Tp& __a,
const _Tp& __b, _Compare __comp)
281 if (__comp(__b, __a))
297 template<
typename _Tp,
typename _Compare>
300 max(
const _Tp& __a,
const _Tp& __b, _Compare __comp)
303 if (__comp(__a, __b))
310 template<
typename _Iterator>
313 __niter_base(_Iterator __it)
320 template<
typename _From,
typename _To>
323 __niter_wrap(_From __from, _To __res)
324 {
return __from + (__res - std::__niter_base(__from)); }
327 template<
typename _Iterator>
330 __niter_wrap(
const _Iterator&, _Iterator __res)
339 template<
bool _IsMove,
bool _IsSimple,
typename _Category>
342 template<
typename _II,
typename _OI>
345 __copy_m(_II __first, _II __last, _OI __result)
347 for (; __first != __last; ++__result, (void)++__first)
348 *__result = *__first;
353 #if __cplusplus >= 201103L 354 template<
typename _Category>
355 struct __copy_move<true, false, _Category>
357 template<
typename _II,
typename _OI>
360 __copy_m(_II __first, _II __last, _OI __result)
362 for (; __first != __last; ++__result, (void)++__first)
370 struct __copy_move<false, false, random_access_iterator_tag>
372 template<
typename _II,
typename _OI>
375 __copy_m(_II __first, _II __last, _OI __result)
378 for(_Distance __n = __last - __first; __n > 0; --__n)
380 *__result = *__first;
388 #if __cplusplus >= 201103L 390 struct __copy_move<true, false, random_access_iterator_tag>
392 template<
typename _II,
typename _OI>
395 __copy_m(_II __first, _II __last, _OI __result)
398 for(_Distance __n = __last - __first; __n > 0; --__n)
409 template<
bool _IsMove>
410 struct __copy_move<_IsMove, true, random_access_iterator_tag>
412 template<
typename _Tp>
415 __copy_m(
const _Tp* __first,
const _Tp* __last, _Tp* __result)
417 #if __cplusplus >= 201103L 422 static_assert( __assignable::type::value,
"type is not assignable" );
424 const ptrdiff_t _Num = __last - __first;
426 __builtin_memmove(__result, __first,
sizeof(_Tp) * _Num);
427 return __result + _Num;
433 template<
typename _CharT>
436 template<
typename _CharT,
typename _Traits>
439 template<
typename _CharT,
typename _Traits>
442 template<
bool _IsMove,
typename _CharT>
443 typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
445 __copy_move_a2(_CharT*, _CharT*,
448 template<
bool _IsMove,
typename _CharT>
449 typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
451 __copy_move_a2(
const _CharT*,
const _CharT*,
454 template<
bool _IsMove,
typename _CharT>
455 typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
460 template<
bool _IsMove,
typename _II,
typename _OI>
463 __copy_move_a2(_II __first, _II __last, _OI __result)
466 #ifdef __cpp_lib_is_constant_evaluated 467 if (std::is_constant_evaluated())
468 return std::__copy_move<_IsMove, false, _Category>::
469 __copy_m(__first, __last, __result);
471 return std::__copy_move<_IsMove, __memcpyable<_OI, _II>::__value,
472 _Category>::__copy_m(__first, __last, __result);
475 _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
477 template<
typename _Tp,
typename _Ref,
typename _Ptr>
480 _GLIBCXX_END_NAMESPACE_CONTAINER
482 template<
bool _IsMove,
483 typename _Tp,
typename _Ref,
typename _Ptr,
typename _OI>
485 __copy_move_a1(_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr>,
486 _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr>,
489 template<
bool _IsMove,
490 typename _ITp,
typename _IRef,
typename _IPtr,
typename _OTp>
491 _GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*>
492 __copy_move_a1(_GLIBCXX_STD_C::_Deque_iterator<_ITp, _IRef, _IPtr>,
493 _GLIBCXX_STD_C::_Deque_iterator<_ITp, _IRef, _IPtr>,
494 _GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*>);
496 template<
bool _IsMove,
typename _II,
typename _Tp>
497 typename __gnu_cxx::__enable_if<
498 __is_random_access_iter<_II>::__value,
499 _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> >::__type
500 __copy_move_a1(_II, _II, _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>);
502 template<
bool _IsMove,
typename _II,
typename _OI>
505 __copy_move_a1(_II __first, _II __last, _OI __result)
506 {
return std::__copy_move_a2<_IsMove>(__first, __last, __result); }
508 template<
bool _IsMove,
typename _II,
typename _OI>
511 __copy_move_a(_II __first, _II __last, _OI __result)
513 return std::__niter_wrap(__result,
514 std::__copy_move_a1<_IsMove>(std::__niter_base(__first),
515 std::__niter_base(__last),
516 std::__niter_base(__result)));
519 template<
bool _IsMove,
520 typename _Ite,
typename _Seq,
typename _Cat,
typename _OI>
522 __copy_move_a(const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>&,
523 const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>&,
526 template<
bool _IsMove,
527 typename _II,
typename _Ite,
typename _Seq,
typename _Cat>
529 __copy_move_a(_II, _II,
530 const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>&);
532 template<
bool _IsMove,
533 typename _IIte,
typename _ISeq,
typename _ICat,
534 typename _OIte,
typename _OSeq,
typename _OCat>
536 __copy_move_a(const ::__gnu_debug::_Safe_iterator<_IIte, _ISeq, _ICat>&,
537 const ::__gnu_debug::_Safe_iterator<_IIte, _ISeq, _ICat>&,
538 const ::__gnu_debug::_Safe_iterator<_OIte, _OSeq, _OCat>&);
557 template<
typename _II,
typename _OI>
560 copy(_II __first, _II __last, _OI __result)
563 __glibcxx_function_requires(_InputIteratorConcept<_II>)
564 __glibcxx_function_requires(_OutputIteratorConcept<_OI,
566 __glibcxx_requires_can_increment_range(__first, __last, __result);
568 return std::__copy_move_a<__is_move_iterator<_II>::__value>
569 (std::__miter_base(__first), std::__miter_base(__last), __result);
572 #if __cplusplus >= 201103L 590 template<
typename _II,
typename _OI>
593 move(_II __first, _II __last, _OI __result)
596 __glibcxx_function_requires(_InputIteratorConcept<_II>)
597 __glibcxx_function_requires(_OutputIteratorConcept<_OI,
599 __glibcxx_requires_can_increment_range(__first, __last, __result);
601 return std::__copy_move_a<true>(std::__miter_base(__first),
602 std::__miter_base(__last), __result);
605 #define _GLIBCXX_MOVE3(_Tp, _Up, _Vp) std::move(_Tp, _Up, _Vp) 607 #define _GLIBCXX_MOVE3(_Tp, _Up, _Vp) std::copy(_Tp, _Up, _Vp) 610 template<
bool _IsMove,
bool _IsSimple,
typename _Category>
611 struct __copy_move_backward
613 template<
typename _BI1,
typename _BI2>
616 __copy_move_b(_BI1 __first, _BI1 __last, _BI2 __result)
618 while (__first != __last)
619 *--__result = *--__last;
624 #if __cplusplus >= 201103L 625 template<
typename _Category>
626 struct __copy_move_backward<true, false, _Category>
628 template<
typename _BI1,
typename _BI2>
631 __copy_move_b(_BI1 __first, _BI1 __last, _BI2 __result)
633 while (__first != __last)
641 struct __copy_move_backward<false, false, random_access_iterator_tag>
643 template<
typename _BI1,
typename _BI2>
646 __copy_move_b(_BI1 __first, _BI1 __last, _BI2 __result)
649 __n = __last - __first;
650 for (; __n > 0; --__n)
651 *--__result = *--__last;
656 #if __cplusplus >= 201103L 658 struct __copy_move_backward<true, false, random_access_iterator_tag>
660 template<
typename _BI1,
typename _BI2>
663 __copy_move_b(_BI1 __first, _BI1 __last, _BI2 __result)
666 __n = __last - __first;
667 for (; __n > 0; --__n)
674 template<
bool _IsMove>
675 struct __copy_move_backward<_IsMove, true, random_access_iterator_tag>
677 template<
typename _Tp>
680 __copy_move_b(
const _Tp* __first,
const _Tp* __last, _Tp* __result)
682 #if __cplusplus >= 201103L 687 static_assert( __assignable::type::value,
"type is not assignable" );
689 const ptrdiff_t _Num = __last - __first;
691 __builtin_memmove(__result - _Num, __first,
sizeof(_Tp) * _Num);
692 return __result - _Num;
696 template<
bool _IsMove,
typename _BI1,
typename _BI2>
699 __copy_move_backward_a2(_BI1 __first, _BI1 __last, _BI2 __result)
702 #ifdef __cpp_lib_is_constant_evaluated 703 if (std::is_constant_evaluated())
704 return std::__copy_move_backward<_IsMove, false, _Category>::
705 __copy_move_b(__first, __last, __result);
707 return std::__copy_move_backward<_IsMove,
708 __memcpyable<_BI2, _BI1>::__value,
709 _Category>::__copy_move_b(__first,
714 template<
bool _IsMove,
typename _BI1,
typename _BI2>
717 __copy_move_backward_a1(_BI1 __first, _BI1 __last, _BI2 __result)
718 {
return std::__copy_move_backward_a2<_IsMove>(__first, __last, __result); }
720 template<
bool _IsMove,
721 typename _Tp,
typename _Ref,
typename _Ptr,
typename _OI>
723 __copy_move_backward_a1(_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr>,
724 _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr>,
727 template<
bool _IsMove,
728 typename _ITp,
typename _IRef,
typename _IPtr,
typename _OTp>
729 _GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*>
730 __copy_move_backward_a1(
731 _GLIBCXX_STD_C::_Deque_iterator<_ITp, _IRef, _IPtr>,
732 _GLIBCXX_STD_C::_Deque_iterator<_ITp, _IRef, _IPtr>,
733 _GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*>);
735 template<
bool _IsMove,
typename _II,
typename _Tp>
736 typename __gnu_cxx::__enable_if<
737 __is_random_access_iter<_II>::__value,
738 _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> >::__type
739 __copy_move_backward_a1(_II, _II,
740 _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>);
742 template<
bool _IsMove,
typename _II,
typename _OI>
745 __copy_move_backward_a(_II __first, _II __last, _OI __result)
747 return std::__niter_wrap(__result,
748 std::__copy_move_backward_a1<_IsMove>
749 (std::__niter_base(__first), std::__niter_base(__last),
750 std::__niter_base(__result)));
753 template<
bool _IsMove,
754 typename _Ite,
typename _Seq,
typename _Cat,
typename _OI>
756 __copy_move_backward_a(
757 const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>&,
758 const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>&,
761 template<
bool _IsMove,
762 typename _II,
typename _Ite,
typename _Seq,
typename _Cat>
764 __copy_move_backward_a(_II, _II,
765 const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>&);
767 template<
bool _IsMove,
768 typename _IIte,
typename _ISeq,
typename _ICat,
769 typename _OIte,
typename _OSeq,
typename _OCat>
771 __copy_move_backward_a(
772 const ::__gnu_debug::_Safe_iterator<_IIte, _ISeq, _ICat>&,
773 const ::__gnu_debug::_Safe_iterator<_IIte, _ISeq, _ICat>&,
774 const ::__gnu_debug::_Safe_iterator<_OIte, _OSeq, _OCat>&);
794 template<
typename _BI1,
typename _BI2>
797 copy_backward(_BI1 __first, _BI1 __last, _BI2 __result)
800 __glibcxx_function_requires(_BidirectionalIteratorConcept<_BI1>)
801 __glibcxx_function_requires(_Mutable_BidirectionalIteratorConcept<_BI2>)
802 __glibcxx_function_requires(_ConvertibleConcept<
805 __glibcxx_requires_can_decrement_range(__first, __last, __result);
807 return std::__copy_move_backward_a<__is_move_iterator<_BI1>::__value>
808 (std::__miter_base(__first), std::__miter_base(__last), __result);
811 #if __cplusplus >= 201103L 830 template<
typename _BI1,
typename _BI2>
836 __glibcxx_function_requires(_BidirectionalIteratorConcept<_BI1>)
837 __glibcxx_function_requires(_Mutable_BidirectionalIteratorConcept<_BI2>)
838 __glibcxx_function_requires(_ConvertibleConcept<
841 __glibcxx_requires_can_decrement_range(__first, __last, __result);
843 return std::__copy_move_backward_a<true>(std::__miter_base(__first),
844 std::__miter_base(__last),
848 #define _GLIBCXX_MOVE_BACKWARD3(_Tp, _Up, _Vp) std::move_backward(_Tp, _Up, _Vp) 850 #define _GLIBCXX_MOVE_BACKWARD3(_Tp, _Up, _Vp) std::copy_backward(_Tp, _Up, _Vp) 853 template<
typename _ForwardIterator,
typename _Tp>
856 __gnu_cxx::__enable_if<!__is_scalar<_Tp>::__value,
void>::__type
857 __fill_a1(_ForwardIterator __first, _ForwardIterator __last,
860 for (; __first != __last; ++__first)
864 template<
typename _ForwardIterator,
typename _Tp>
867 __gnu_cxx::__enable_if<__is_scalar<_Tp>::__value,
void>::__type
868 __fill_a1(_ForwardIterator __first, _ForwardIterator __last,
871 const _Tp __tmp = __value;
872 for (; __first != __last; ++__first)
877 template<
typename _Tp>
880 __gnu_cxx::__enable_if<__is_byte<_Tp>::__value,
void>::__type
881 __fill_a1(_Tp* __first, _Tp* __last,
const _Tp& __c)
883 const _Tp __tmp = __c;
884 #if __cpp_lib_is_constant_evaluated 885 if (std::is_constant_evaluated())
887 for (; __first != __last; ++__first)
892 if (
const size_t __len = __last - __first)
893 __builtin_memset(__first, static_cast<unsigned char>(__tmp), __len);
896 template<
typename _Ite,
typename _Cont,
typename _Tp>
899 __fill_a1(::__gnu_cxx::__normal_iterator<_Ite, _Cont> __first,
900 ::__gnu_cxx::__normal_iterator<_Ite, _Cont> __last,
902 { std::__fill_a1(__first.base(), __last.base(), __value); }
904 template<
typename _Tp,
typename _VTp>
906 __fill_a1(
const _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>&,
907 const _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>&,
910 template<
typename _FIte,
typename _Tp>
913 __fill_a(_FIte __first, _FIte __last,
const _Tp& __value)
914 { std::__fill_a1(__first, __last, __value); }
916 template<
typename _Ite,
typename _Seq,
typename _Cat,
typename _Tp>
918 __fill_a(const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>&,
919 const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>&,
934 template<
typename _ForwardIterator,
typename _Tp>
937 fill(_ForwardIterator __first, _ForwardIterator __last,
const _Tp& __value)
940 __glibcxx_function_requires(_Mutable_ForwardIteratorConcept<
942 __glibcxx_requires_valid_range(__first, __last);
944 std::__fill_a(__first, __last, __value);
948 inline _GLIBCXX_CONSTEXPR
int 949 __size_to_integer(
int __n) {
return __n; }
950 inline _GLIBCXX_CONSTEXPR
unsigned 951 __size_to_integer(
unsigned __n) {
return __n; }
952 inline _GLIBCXX_CONSTEXPR
long 953 __size_to_integer(
long __n) {
return __n; }
954 inline _GLIBCXX_CONSTEXPR
unsigned long 955 __size_to_integer(
unsigned long __n) {
return __n; }
956 inline _GLIBCXX_CONSTEXPR
long long 957 __size_to_integer(
long long __n) {
return __n; }
958 inline _GLIBCXX_CONSTEXPR
unsigned long long 959 __size_to_integer(
unsigned long long __n) {
return __n; }
961 #if defined(__GLIBCXX_TYPE_INT_N_0) 962 inline _GLIBCXX_CONSTEXPR __GLIBCXX_TYPE_INT_N_0
963 __size_to_integer(__GLIBCXX_TYPE_INT_N_0 __n) {
return __n; }
964 inline _GLIBCXX_CONSTEXPR
unsigned __GLIBCXX_TYPE_INT_N_0
965 __size_to_integer(
unsigned __GLIBCXX_TYPE_INT_N_0 __n) {
return __n; }
967 #if defined(__GLIBCXX_TYPE_INT_N_1) 968 inline _GLIBCXX_CONSTEXPR __GLIBCXX_TYPE_INT_N_1
969 __size_to_integer(__GLIBCXX_TYPE_INT_N_1 __n) {
return __n; }
970 inline _GLIBCXX_CONSTEXPR
unsigned __GLIBCXX_TYPE_INT_N_1
971 __size_to_integer(
unsigned __GLIBCXX_TYPE_INT_N_1 __n) {
return __n; }
973 #if defined(__GLIBCXX_TYPE_INT_N_2) 974 inline _GLIBCXX_CONSTEXPR __GLIBCXX_TYPE_INT_N_2
975 __size_to_integer(__GLIBCXX_TYPE_INT_N_2 __n) {
return __n; }
976 inline _GLIBCXX_CONSTEXPR
unsigned __GLIBCXX_TYPE_INT_N_2
977 __size_to_integer(
unsigned __GLIBCXX_TYPE_INT_N_2 __n) {
return __n; }
979 #if defined(__GLIBCXX_TYPE_INT_N_3) 980 inline _GLIBCXX_CONSTEXPR
unsigned __GLIBCXX_TYPE_INT_N_3
981 __size_to_integer(__GLIBCXX_TYPE_INT_N_3 __n) {
return __n; }
982 inline _GLIBCXX_CONSTEXPR __GLIBCXX_TYPE_INT_N_3
983 __size_to_integer(
unsigned __GLIBCXX_TYPE_INT_N_3 __n) {
return __n; }
986 inline _GLIBCXX_CONSTEXPR
long long 987 __size_to_integer(
float __n) {
return __n; }
988 inline _GLIBCXX_CONSTEXPR
long long 989 __size_to_integer(
double __n) {
return __n; }
990 inline _GLIBCXX_CONSTEXPR
long long 991 __size_to_integer(
long double __n) {
return __n; }
992 #if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_FLOAT128) && !defined(__CUDACC__) 993 inline _GLIBCXX_CONSTEXPR
long long 994 __size_to_integer(__float128 __n) {
return __n; }
997 template<
typename _OutputIterator,
typename _Size,
typename _Tp>
1000 __gnu_cxx::__enable_if<!__is_scalar<_Tp>::__value, _OutputIterator>::__type
1001 __fill_n_a1(_OutputIterator __first, _Size __n,
const _Tp& __value)
1003 for (; __n > 0; --__n, (void) ++__first)
1008 template<
typename _OutputIterator,
typename _Size,
typename _Tp>
1009 _GLIBCXX20_CONSTEXPR
1011 __gnu_cxx::__enable_if<__is_scalar<_Tp>::__value, _OutputIterator>::__type
1012 __fill_n_a1(_OutputIterator __first, _Size __n,
const _Tp& __value)
1014 const _Tp __tmp = __value;
1015 for (; __n > 0; --__n, (void) ++__first)
1020 template<
typename _Ite,
typename _Seq,
typename _Cat,
typename _Size,
1023 __fill_n_a(const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>& __first,
1024 _Size __n,
const _Tp& __value,
1027 template<
typename _OutputIterator,
typename _Size,
typename _Tp>
1028 _GLIBCXX20_CONSTEXPR
1029 inline _OutputIterator
1030 __fill_n_a(_OutputIterator __first, _Size __n,
const _Tp& __value,
1033 #if __cplusplus >= 201103L 1036 return __fill_n_a1(__first, __n, __value);
1039 template<
typename _OutputIterator,
typename _Size,
typename _Tp>
1040 _GLIBCXX20_CONSTEXPR
1041 inline _OutputIterator
1042 __fill_n_a(_OutputIterator __first, _Size __n,
const _Tp& __value,
1045 #if __cplusplus >= 201103L 1048 return __fill_n_a1(__first, __n, __value);
1051 template<
typename _OutputIterator,
typename _Size,
typename _Tp>
1052 _GLIBCXX20_CONSTEXPR
1053 inline _OutputIterator
1054 __fill_n_a(_OutputIterator __first, _Size __n,
const _Tp& __value,
1057 #if __cplusplus >= 201103L 1063 __glibcxx_requires_can_increment(__first, __n);
1065 std::__fill_a(__first, __first + __n, __value);
1066 return __first + __n;
1086 template<
typename _OI,
typename _Size,
typename _Tp>
1087 _GLIBCXX20_CONSTEXPR
1089 fill_n(_OI __first, _Size __n,
const _Tp& __value)
1092 __glibcxx_function_requires(_OutputIteratorConcept<_OI, _Tp>)
1094 return std::__fill_n_a(__first, std::__size_to_integer(__n), __value,
1098 template<
bool _BoolType>
1101 template<
typename _II1,
typename _II2>
1102 _GLIBCXX20_CONSTEXPR
1104 equal(_II1 __first1, _II1 __last1, _II2 __first2)
1106 for (; __first1 != __last1; ++__first1, (void) ++__first2)
1107 if (!(*__first1 == *__first2))
1114 struct __equal<true>
1116 template<
typename _Tp>
1117 _GLIBCXX20_CONSTEXPR
1119 equal(
const _Tp* __first1,
const _Tp* __last1,
const _Tp* __first2)
1121 if (
const size_t __len = (__last1 - __first1))
1122 return !std::__memcmp(__first1, __first2, __len);
1127 template<
typename _Tp,
typename _Ref,
typename _Ptr,
typename _II>
1128 typename __gnu_cxx::__enable_if<
1129 __is_random_access_iter<_II>::__value,
bool>::__type
1130 __equal_aux1(_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr>,
1131 _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr>,
1134 template<
typename _Tp1,
typename _Ref1,
typename _Ptr1,
1135 typename _Tp2,
typename _Ref2,
typename _Ptr2>
1137 __equal_aux1(_GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref1, _Ptr1>,
1138 _GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref1, _Ptr1>,
1139 _GLIBCXX_STD_C::_Deque_iterator<_Tp2, _Ref2, _Ptr2>);
1141 template<
typename _II,
typename _Tp,
typename _Ref,
typename _Ptr>
1142 typename __gnu_cxx::__enable_if<
1143 __is_random_access_iter<_II>::__value,
bool>::__type
1144 __equal_aux1(_II, _II,
1145 _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr>);
1147 template<
typename _II1,
typename _II2>
1148 _GLIBCXX20_CONSTEXPR
1150 __equal_aux1(_II1 __first1, _II1 __last1, _II2 __first2)
1153 const bool __simple = ((__is_integer<_ValueType1>::__value
1154 || __is_pointer<_ValueType1>::__value)
1155 && __memcmpable<_II1, _II2>::__value);
1159 template<
typename _II1,
typename _II2>
1160 _GLIBCXX20_CONSTEXPR
1162 __equal_aux(_II1 __first1, _II1 __last1, _II2 __first2)
1164 return std::__equal_aux1(std::__niter_base(__first1),
1165 std::__niter_base(__last1),
1166 std::__niter_base(__first2));
1169 template<
typename _II1,
typename _Seq1,
typename _Cat1,
typename _II2>
1171 __equal_aux(const ::__gnu_debug::_Safe_iterator<_II1, _Seq1, _Cat1>&,
1172 const ::__gnu_debug::_Safe_iterator<_II1, _Seq1, _Cat1>&,
1175 template<
typename _II1,
typename _II2,
typename _Seq2,
typename _Cat2>
1177 __equal_aux(_II1, _II1,
1178 const ::__gnu_debug::_Safe_iterator<_II2, _Seq2, _Cat2>&);
1180 template<
typename _II1,
typename _Seq1,
typename _Cat1,
1181 typename _II2,
typename _Seq2,
typename _Cat2>
1183 __equal_aux(const ::__gnu_debug::_Safe_iterator<_II1, _Seq1, _Cat1>&,
1184 const ::__gnu_debug::_Safe_iterator<_II1, _Seq1, _Cat1>&,
1185 const ::__gnu_debug::_Safe_iterator<_II2, _Seq2, _Cat2>&);
1187 template<
typename,
typename>
1190 template<
typename _II1,
typename _II2>
1191 _GLIBCXX20_CONSTEXPR
1193 __newlast1(_II1, _II1 __last1, _II2, _II2)
1196 template<
typename _II>
1197 _GLIBCXX20_CONSTEXPR
1199 __cnd2(_II __first, _II __last)
1200 {
return __first != __last; }
1204 struct __lc_rai<random_access_iterator_tag, random_access_iterator_tag>
1206 template<
typename _RAI1,
typename _RAI2>
1207 _GLIBCXX20_CONSTEXPR
1209 __newlast1(_RAI1 __first1, _RAI1 __last1,
1210 _RAI2 __first2, _RAI2 __last2)
1213 __diff1 = __last1 - __first1;
1215 __diff2 = __last2 - __first2;
1216 return __diff2 < __diff1 ? __first1 + __diff2 : __last1;
1219 template<
typename _RAI>
1220 static _GLIBCXX20_CONSTEXPR
bool 1225 template<
typename _II1,
typename _II2,
typename _Compare>
1226 _GLIBCXX20_CONSTEXPR
1228 __lexicographical_compare_impl(_II1 __first1, _II1 __last1,
1229 _II2 __first2, _II2 __last2,
1234 typedef std::__lc_rai<_Category1, _Category2> __rai_type;
1236 __last1 = __rai_type::__newlast1(__first1, __last1, __first2, __last2);
1237 for (; __first1 != __last1 && __rai_type::__cnd2(__first2, __last2);
1238 ++__first1, (void)++__first2)
1240 if (__comp(__first1, __first2))
1242 if (__comp(__first2, __first1))
1245 return __first1 == __last1 && __first2 != __last2;
1248 template<
bool _BoolType>
1249 struct __lexicographical_compare
1251 template<
typename _II1,
typename _II2>
1252 _GLIBCXX20_CONSTEXPR
1254 __lc(_II1 __first1, _II1 __last1, _II2 __first2, _II2 __last2)
1256 using __gnu_cxx::__ops::__iter_less_iter;
1257 return std::__lexicographical_compare_impl(__first1, __last1,
1259 __iter_less_iter());
1264 struct __lexicographical_compare<true>
1266 template<
typename _Tp,
typename _Up>
1267 _GLIBCXX20_CONSTEXPR
1269 __lc(
const _Tp* __first1,
const _Tp* __last1,
1270 const _Up* __first2,
const _Up* __last2)
1272 const size_t __len1 = __last1 - __first1;
1273 const size_t __len2 = __last2 - __first2;
1274 if (
const size_t __len =
std::min(__len1, __len2))
1275 if (
int __result = std::__memcmp(__first1, __first2, __len))
1276 return __result < 0;
1277 return __len1 < __len2;
1281 template<
typename _II1,
typename _II2>
1282 _GLIBCXX20_CONSTEXPR
1284 __lexicographical_compare_aux(_II1 __first1, _II1 __last1,
1285 _II2 __first2, _II2 __last2)
1289 const bool __simple =
1290 (__is_memcmp_ordered_with<_ValueType1, _ValueType2>::__value
1291 && __is_pointer<_II1>::__value
1292 && __is_pointer<_II2>::__value
1293 #if __cplusplus > 201703L && __cpp_lib_concepts 1297 && !is_volatile_v<remove_reference_t<iter_reference_t<_II1>>>
1298 && !is_volatile_v<remove_reference_t<iter_reference_t<_II2>>>
1302 return std::__lexicographical_compare<__simple>::__lc(__first1, __last1,
1306 template<
typename _ForwardIterator,
typename _Tp,
typename _Compare>
1307 _GLIBCXX20_CONSTEXPR
1309 __lower_bound(_ForwardIterator __first, _ForwardIterator __last,
1310 const _Tp& __val, _Compare __comp)
1319 _DistanceType __half = __len >> 1;
1320 _ForwardIterator __middle = __first;
1322 if (__comp(__middle, __val))
1326 __len = __len - __half - 1;
1345 template<
typename _ForwardIterator,
typename _Tp>
1346 _GLIBCXX20_CONSTEXPR
1347 inline _ForwardIterator
1348 lower_bound(_ForwardIterator __first, _ForwardIterator __last,
1352 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
1353 __glibcxx_function_requires(_LessThanOpConcept<
1355 __glibcxx_requires_partitioned_lower(__first, __last, __val);
1357 return std::__lower_bound(__first, __last, __val,
1358 __gnu_cxx::__ops::__iter_less_val());
1363 inline _GLIBCXX_CONSTEXPR
int 1365 {
return (
int)
sizeof(int) * __CHAR_BIT__ - 1 - __builtin_clz(__n); }
1367 inline _GLIBCXX_CONSTEXPR
unsigned 1369 {
return (
int)
sizeof(int) * __CHAR_BIT__ - 1 - __builtin_clz(__n); }
1371 inline _GLIBCXX_CONSTEXPR
long 1373 {
return (
int)
sizeof(long) * __CHAR_BIT__ - 1 - __builtin_clzl(__n); }
1375 inline _GLIBCXX_CONSTEXPR
unsigned long 1376 __lg(
unsigned long __n)
1377 {
return (
int)
sizeof(long) * __CHAR_BIT__ - 1 - __builtin_clzl(__n); }
1379 inline _GLIBCXX_CONSTEXPR
long long 1381 {
return (
int)
sizeof(
long long) * __CHAR_BIT__ - 1 - __builtin_clzll(__n); }
1383 inline _GLIBCXX_CONSTEXPR
unsigned long long 1384 __lg(
unsigned long long __n)
1385 {
return (
int)
sizeof(
long long) * __CHAR_BIT__ - 1 - __builtin_clzll(__n); }
1387 _GLIBCXX_BEGIN_NAMESPACE_ALGO
1401 template<
typename _II1,
typename _II2>
1402 _GLIBCXX20_CONSTEXPR
1404 equal(_II1 __first1, _II1 __last1, _II2 __first2)
1407 __glibcxx_function_requires(_InputIteratorConcept<_II1>)
1408 __glibcxx_function_requires(_InputIteratorConcept<_II2>)
1409 __glibcxx_function_requires(_EqualOpConcept<
1412 __glibcxx_requires_can_increment_range(__first1, __last1, __first2);
1414 return std::__equal_aux(__first1, __last1, __first2);
1432 template<
typename _IIter1,
typename _IIter2,
typename _BinaryPredicate>
1433 _GLIBCXX20_CONSTEXPR
1435 equal(_IIter1 __first1, _IIter1 __last1,
1436 _IIter2 __first2, _BinaryPredicate __binary_pred)
1439 __glibcxx_function_requires(_InputIteratorConcept<_IIter1>)
1440 __glibcxx_function_requires(_InputIteratorConcept<_IIter2>)
1441 __glibcxx_requires_valid_range(__first1, __last1);
1443 for (; __first1 != __last1; ++__first1, (void)++__first2)
1444 if (!
bool(__binary_pred(*__first1, *__first2)))
1449 #if __cplusplus >= 201103L 1451 template<
typename _II1,
typename _II2>
1452 _GLIBCXX20_CONSTEXPR
1454 __equal4(_II1 __first1, _II1 __last1, _II2 __first2, _II2 __last2)
1456 using _RATag = random_access_iterator_tag;
1469 for (; __first1 != __last1 && __first2 != __last2;
1470 ++__first1, (void)++__first2)
1471 if (!(*__first1 == *__first2))
1473 return __first1 == __last1 && __first2 == __last2;
1477 template<
typename _II1,
typename _II2,
typename _BinaryPredicate>
1478 _GLIBCXX20_CONSTEXPR
1480 __equal4(_II1 __first1, _II1 __last1, _II2 __first2, _II2 __last2,
1481 _BinaryPredicate __binary_pred)
1483 using _RATag = random_access_iterator_tag;
1497 for (; __first1 != __last1 && __first2 != __last2;
1498 ++__first1, (void)++__first2)
1499 if (!
bool(__binary_pred(*__first1, *__first2)))
1501 return __first1 == __last1 && __first2 == __last2;
1505 #if __cplusplus > 201103L 1507 #define __cpp_lib_robust_nonmodifying_seq_ops 201304 1522 template<
typename _II1,
typename _II2>
1523 _GLIBCXX20_CONSTEXPR
1525 equal(_II1 __first1, _II1 __last1, _II2 __first2, _II2 __last2)
1528 __glibcxx_function_requires(_InputIteratorConcept<_II1>)
1529 __glibcxx_function_requires(_InputIteratorConcept<_II2>)
1530 __glibcxx_function_requires(_EqualOpConcept<
1533 __glibcxx_requires_valid_range(__first1, __last1);
1534 __glibcxx_requires_valid_range(__first2, __last2);
1536 return _GLIBCXX_STD_A::__equal4(__first1, __last1, __first2, __last2);
1555 template<
typename _IIter1,
typename _IIter2,
typename _BinaryPredicate>
1556 _GLIBCXX20_CONSTEXPR
1558 equal(_IIter1 __first1, _IIter1 __last1,
1559 _IIter2 __first2, _IIter2 __last2, _BinaryPredicate __binary_pred)
1562 __glibcxx_function_requires(_InputIteratorConcept<_IIter1>)
1563 __glibcxx_function_requires(_InputIteratorConcept<_IIter2>)
1564 __glibcxx_requires_valid_range(__first1, __last1);
1565 __glibcxx_requires_valid_range(__first2, __last2);
1567 return _GLIBCXX_STD_A::__equal4(__first1, __last1, __first2, __last2,
1587 template<
typename _II1,
typename _II2>
1588 _GLIBCXX20_CONSTEXPR
1590 lexicographical_compare(_II1 __first1, _II1 __last1,
1591 _II2 __first2, _II2 __last2)
1593 #ifdef _GLIBCXX_CONCEPT_CHECKS 1598 __glibcxx_function_requires(_InputIteratorConcept<_II1>)
1599 __glibcxx_function_requires(_InputIteratorConcept<_II2>)
1600 __glibcxx_function_requires(_LessThanOpConcept<_ValueType1, _ValueType2>)
1601 __glibcxx_function_requires(_LessThanOpConcept<_ValueType2, _ValueType1>)
1602 __glibcxx_requires_valid_range(__first1, __last1);
1603 __glibcxx_requires_valid_range(__first2, __last2);
1605 return std::__lexicographical_compare_aux(std::__niter_base(__first1),
1606 std::__niter_base(__last1),
1607 std::__niter_base(__first2),
1608 std::__niter_base(__last2));
1624 template<
typename _II1,
typename _II2,
typename _Compare>
1625 _GLIBCXX20_CONSTEXPR
1627 lexicographical_compare(_II1 __first1, _II1 __last1,
1628 _II2 __first2, _II2 __last2, _Compare __comp)
1631 __glibcxx_function_requires(_InputIteratorConcept<_II1>)
1632 __glibcxx_function_requires(_InputIteratorConcept<_II2>)
1633 __glibcxx_requires_valid_range(__first1, __last1);
1634 __glibcxx_requires_valid_range(__first2, __last2);
1636 return std::__lexicographical_compare_impl
1637 (__first1, __last1, __first2, __last2,
1638 __gnu_cxx::__ops::__iter_comp_iter(__comp));
1641 #if __cpp_lib_three_way_comparison 1644 template<
typename _Iter>
1645 concept __is_byte_iter = contiguous_iterator<_Iter>
1646 && __is_memcmp_ordered<iter_value_t<_Iter>>::__value;
1650 template<
typename _Tp>
1652 __min_cmp(_Tp __x, _Tp __y)
1656 decltype(__x <=> __y) _M_cmp;
1658 auto __c = __x <=> __y;
1660 return _Res{__y, __c};
1661 return _Res{__x, __c};
1675 template<
typename _InputIter1,
typename _InputIter2,
typename _Comp>
1677 lexicographical_compare_three_way(_InputIter1 __first1,
1678 _InputIter1 __last1,
1679 _InputIter2 __first2,
1680 _InputIter2 __last2,
1682 -> decltype(__comp(*__first1, *__first2))
1685 __glibcxx_function_requires(_InputIteratorConcept<_InputIter1>)
1686 __glibcxx_function_requires(_InputIteratorConcept<_InputIter2>)
1687 __glibcxx_requires_valid_range(__first1, __last1);
1688 __glibcxx_requires_valid_range(__first2, __last2);
1690 #if __cpp_lib_is_constant_evaluated 1691 using _Cat = decltype(__comp(*__first1, *__first2));
1692 static_assert(same_as<common_comparison_category_t<_Cat>, _Cat>);
1694 if (!std::is_constant_evaluated())
1695 if constexpr (same_as<_Comp, __detail::_Synth3way>
1696 || same_as<_Comp, compare_three_way>)
1697 if constexpr (__is_byte_iter<_InputIter1>)
1698 if constexpr (__is_byte_iter<_InputIter2>)
1700 const auto [__len, __lencmp]
1701 = std::__min_cmp(__last1 - __first1, __last2 - __first2);
1705 = __builtin_memcmp(&*__first1, &*__first2, __len) <=> 0;
1711 #endif // is_constant_evaluated 1712 while (__first1 != __last1)
1714 if (__first2 == __last2)
1715 return strong_ordering::greater;
1716 if (
auto __cmp = __comp(*__first1, *__first2); __cmp != 0)
1721 return (__first2 == __last2) <=>
true;
1724 template<
typename _InputIter1,
typename _InputIter2>
1726 lexicographical_compare_three_way(_InputIter1 __first1,
1727 _InputIter1 __last1,
1728 _InputIter2 __first2,
1729 _InputIter2 __last2)
1731 return std::lexicographical_compare_three_way(__first1, __last1,
1733 compare_three_way{});
1735 #endif // three_way_comparison 1737 template<
typename _InputIterator1,
typename _InputIterator2,
1738 typename _BinaryPredicate>
1739 _GLIBCXX20_CONSTEXPR
1741 __mismatch(_InputIterator1 __first1, _InputIterator1 __last1,
1742 _InputIterator2 __first2, _BinaryPredicate __binary_pred)
1744 while (__first1 != __last1 && __binary_pred(__first1, __first2))
1765 template<
typename _InputIterator1,
typename _InputIterator2>
1766 _GLIBCXX20_CONSTEXPR
1768 mismatch(_InputIterator1 __first1, _InputIterator1 __last1,
1769 _InputIterator2 __first2)
1772 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
1773 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
1774 __glibcxx_function_requires(_EqualOpConcept<
1777 __glibcxx_requires_valid_range(__first1, __last1);
1779 return _GLIBCXX_STD_A::__mismatch(__first1, __last1, __first2,
1780 __gnu_cxx::__ops::__iter_equal_to_iter());
1799 template<
typename _InputIterator1,
typename _InputIterator2,
1800 typename _BinaryPredicate>
1801 _GLIBCXX20_CONSTEXPR
1803 mismatch(_InputIterator1 __first1, _InputIterator1 __last1,
1804 _InputIterator2 __first2, _BinaryPredicate __binary_pred)
1807 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
1808 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
1809 __glibcxx_requires_valid_range(__first1, __last1);
1811 return _GLIBCXX_STD_A::__mismatch(__first1, __last1, __first2,
1812 __gnu_cxx::__ops::__iter_comp_iter(__binary_pred));
1815 #if __cplusplus > 201103L 1817 template<
typename _InputIterator1,
typename _InputIterator2,
1818 typename _BinaryPredicate>
1819 _GLIBCXX20_CONSTEXPR
1821 __mismatch(_InputIterator1 __first1, _InputIterator1 __last1,
1822 _InputIterator2 __first2, _InputIterator2 __last2,
1823 _BinaryPredicate __binary_pred)
1825 while (__first1 != __last1 && __first2 != __last2
1826 && __binary_pred(__first1, __first2))
1848 template<
typename _InputIterator1,
typename _InputIterator2>
1849 _GLIBCXX20_CONSTEXPR
1851 mismatch(_InputIterator1 __first1, _InputIterator1 __last1,
1852 _InputIterator2 __first2, _InputIterator2 __last2)
1855 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
1856 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
1857 __glibcxx_function_requires(_EqualOpConcept<
1860 __glibcxx_requires_valid_range(__first1, __last1);
1861 __glibcxx_requires_valid_range(__first2, __last2);
1863 return _GLIBCXX_STD_A::__mismatch(__first1, __last1, __first2, __last2,
1864 __gnu_cxx::__ops::__iter_equal_to_iter());
1884 template<
typename _InputIterator1,
typename _InputIterator2,
1885 typename _BinaryPredicate>
1886 _GLIBCXX20_CONSTEXPR
1888 mismatch(_InputIterator1 __first1, _InputIterator1 __last1,
1889 _InputIterator2 __first2, _InputIterator2 __last2,
1890 _BinaryPredicate __binary_pred)
1893 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
1894 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
1895 __glibcxx_requires_valid_range(__first1, __last1);
1896 __glibcxx_requires_valid_range(__first2, __last2);
1898 return _GLIBCXX_STD_A::__mismatch(__first1, __last1, __first2, __last2,
1899 __gnu_cxx::__ops::__iter_comp_iter(__binary_pred));
1903 _GLIBCXX_END_NAMESPACE_ALGO
1906 template<
typename _InputIterator,
typename _Predicate>
1907 _GLIBCXX20_CONSTEXPR
1908 inline _InputIterator
1912 while (__first != __last && !__pred(__first))
1918 template<
typename _RandomAccessIterator,
typename _Predicate>
1919 _GLIBCXX20_CONSTEXPR
1920 _RandomAccessIterator
1921 __find_if(_RandomAccessIterator __first, _RandomAccessIterator __last,
1922 _Predicate __pred, random_access_iterator_tag)
1925 __trip_count = (__last - __first) >> 2;
1927 for (; __trip_count > 0; --__trip_count)
1929 if (__pred(__first))
1933 if (__pred(__first))
1937 if (__pred(__first))
1941 if (__pred(__first))
1946 switch (__last - __first)
1949 if (__pred(__first))
1954 if (__pred(__first))
1959 if (__pred(__first))
1969 template<
typename _Iterator,
typename _Predicate>
1970 _GLIBCXX20_CONSTEXPR
1972 __find_if(_Iterator __first, _Iterator __last, _Predicate __pred)
1974 return __find_if(__first, __last, __pred,
1978 template<
typename _InputIterator,
typename _Predicate>
1979 _GLIBCXX20_CONSTEXPR
1981 __count_if(_InputIterator __first, _InputIterator __last, _Predicate __pred)
1984 for (; __first != __last; ++__first)
1985 if (__pred(__first))
1990 #if __cplusplus >= 201103L 1991 template<
typename _ForwardIterator1,
typename _ForwardIterator2,
1992 typename _BinaryPredicate>
1993 _GLIBCXX20_CONSTEXPR
1995 __is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
1996 _ForwardIterator2 __first2, _BinaryPredicate __pred)
2000 for (; __first1 != __last1; ++__first1, (void)++__first2)
2001 if (!__pred(__first1, __first2))
2004 if (__first1 == __last1)
2009 _ForwardIterator2 __last2 = __first2;
2011 for (_ForwardIterator1 __scan = __first1; __scan != __last1; ++__scan)
2014 __gnu_cxx::__ops::__iter_comp_iter(__pred, __scan)))
2018 = std::__count_if(__first2, __last2,
2019 __gnu_cxx::__ops::__iter_comp_iter(__pred, __scan));
2020 if (0 == __matches ||
2021 std::__count_if(__scan, __last1,
2022 __gnu_cxx::__ops::__iter_comp_iter(__pred, __scan))
2041 template<
typename _ForwardIterator1,
typename _ForwardIterator2>
2042 _GLIBCXX20_CONSTEXPR
2044 is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
2045 _ForwardIterator2 __first2)
2048 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator1>)
2049 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator2>)
2050 __glibcxx_function_requires(_EqualOpConcept<
2053 __glibcxx_requires_valid_range(__first1, __last1);
2055 return std::__is_permutation(__first1, __last1, __first2,
2056 __gnu_cxx::__ops::__iter_equal_to_iter());
2060 _GLIBCXX_END_NAMESPACE_VERSION
2066 #ifdef _GLIBCXX_PARALLEL constexpr int __lg(int __n)
This is a helper function for the sort routines and for random.tcc.
constexpr _BI2 move_backward(_BI1 __first, _BI1 __last, _BI2 __result)
Moves the range [first,last) into result.
constexpr iterator_traits< _Iter >::iterator_category __iterator_category(const _Iter &)
constexpr void iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b)
Swaps the contents of two iterators.
Parallel STL function calls corresponding to the stl_algobase.h header. The functions defined here ma...
Provides output iterator semantics for streambufs.
Define a member typedef type to one of two argument types.
is_nothrow_copy_constructible
Provides input iterator semantics for streambufs.
constexpr void advance(_InputIterator &__i, _Distance __n)
A generalization of pointer arithmetic.
constexpr _OI copy(_II __first, _II __last, _OI __result)
Copies the range [first,last) into result.
ISO C++ entities toplevel namespace is std.
constexpr const _Tp & min(const _Tp &, const _Tp &)
This does what you think it does.
constexpr iterator_traits< _InputIterator >::difference_type distance(_InputIterator __first, _InputIterator __last)
A generalization of pointer arithmetic.
constexpr bool equal(_IIter1 __first1, _IIter1 __last1, _IIter2 __first2, _IIter2 __last2, _BinaryPredicate __binary_pred)
Tests a range for element-wise equality.
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
constexpr _InputIterator __find_if(_InputIterator __first, _InputIterator __last, _Predicate __pred, input_iterator_tag)
This is an overload used by find algos for the Input Iterator case.
Basis for explicit traits specializations.
Struct holding two objects of arbitrary type.
Traits class for iterators.
constexpr const _Tp & max(const _Tp &, const _Tp &)
This does what you think it does.
Random-access iterators support a superset of bidirectional iterator operations.
Marking output iterators.