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)
377 typedef typename iterator_traits<_II>::difference_type _Distance;
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)
397 typedef typename iterator_traits<_II>::difference_type _Distance;
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
418 using __assignable = conditional<_IsMove,
419 is_move_assignable<_Tp>,
420 is_copy_assignable<_Tp>>;
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>
437 class istreambuf_iterator;
439 template<
typename _CharT,
typename _Traits>
440 class ostreambuf_iterator;
442 template<
bool _IsMove,
typename _CharT>
443 typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
444 ostreambuf_iterator<_CharT, char_traits<_CharT> > >::__type
445 __copy_move_a2(_CharT*, _CharT*,
446 ostreambuf_iterator<_CharT, char_traits<_CharT> >);
448 template<
bool _IsMove,
typename _CharT>
449 typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
450 ostreambuf_iterator<_CharT, char_traits<_CharT> > >::__type
451 __copy_move_a2(
const _CharT*,
const _CharT*,
452 ostreambuf_iterator<_CharT, char_traits<_CharT> >);
454 template<
bool _IsMove,
typename _CharT>
455 typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
457 __copy_move_a2(istreambuf_iterator<_CharT, char_traits<_CharT> >,
458 istreambuf_iterator<_CharT, char_traits<_CharT> >, _CharT*);
460 template<
bool _IsMove,
typename _II,
typename _OI>
463 __copy_move_a2(_II __first, _II __last, _OI __result)
465 typedef typename iterator_traits<_II>::iterator_category _Category;
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)
648 typename iterator_traits<_BI1>::difference_type
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)
665 typename iterator_traits<_BI1>::difference_type
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
683 using __assignable = conditional<_IsMove,
684 is_move_assignable<_Tp>,
685 is_copy_assignable<_Tp>>;
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)
701 typedef typename iterator_traits<_BI1>::iterator_category _Category;
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>
879 __gnu_cxx::__enable_if<__is_byte<_Tp>::__value,
void>::__type
880 __fill_a1(_Tp* __first, _Tp* __last,
const _Tp& __c)
882 const _Tp __tmp = __c;
883 if (
const size_t __len = __last - __first)
884 __builtin_memset(__first,
static_cast<unsigned char>(__tmp), __len);
887 template<
typename _Ite,
typename _Cont,
typename _Tp>
890 __fill_a1(::__gnu_cxx::__normal_iterator<_Ite, _Cont> __first,
891 ::__gnu_cxx::__normal_iterator<_Ite, _Cont> __last,
893 { std::__fill_a1(__first.base(), __last.base(), __value); }
895 template<
typename _Tp,
typename _VTp>
897 __fill_a1(
const _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>&,
898 const _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>&,
901 template<
typename _FIte,
typename _Tp>
904 __fill_a(_FIte __first, _FIte __last,
const _Tp& __value)
905 { std::__fill_a1(__first, __last, __value); }
907 template<
typename _Ite,
typename _Seq,
typename _Cat,
typename _Tp>
909 __fill_a(const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>&,
910 const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>&,
925 template<
typename _ForwardIterator,
typename _Tp>
928 fill(_ForwardIterator __first, _ForwardIterator __last,
const _Tp& __value)
931 __glibcxx_function_requires(_Mutable_ForwardIteratorConcept<
933 __glibcxx_requires_valid_range(__first, __last);
935 std::__fill_a(__first, __last, __value);
939 inline _GLIBCXX_CONSTEXPR
int
940 __size_to_integer(
int __n) {
return __n; }
941 inline _GLIBCXX_CONSTEXPR
unsigned
942 __size_to_integer(
unsigned __n) {
return __n; }
943 inline _GLIBCXX_CONSTEXPR
long
944 __size_to_integer(
long __n) {
return __n; }
945 inline _GLIBCXX_CONSTEXPR
unsigned long
946 __size_to_integer(
unsigned long __n) {
return __n; }
947 inline _GLIBCXX_CONSTEXPR
long long
948 __size_to_integer(
long long __n) {
return __n; }
949 inline _GLIBCXX_CONSTEXPR
unsigned long long
950 __size_to_integer(
unsigned long long __n) {
return __n; }
952 #if defined(__GLIBCXX_TYPE_INT_N_0)
953 inline _GLIBCXX_CONSTEXPR __GLIBCXX_TYPE_INT_N_0
954 __size_to_integer(__GLIBCXX_TYPE_INT_N_0 __n) {
return __n; }
955 inline _GLIBCXX_CONSTEXPR
unsigned __GLIBCXX_TYPE_INT_N_0
956 __size_to_integer(
unsigned __GLIBCXX_TYPE_INT_N_0 __n) {
return __n; }
958 #if defined(__GLIBCXX_TYPE_INT_N_1)
959 inline _GLIBCXX_CONSTEXPR __GLIBCXX_TYPE_INT_N_1
960 __size_to_integer(__GLIBCXX_TYPE_INT_N_1 __n) {
return __n; }
961 inline _GLIBCXX_CONSTEXPR
unsigned __GLIBCXX_TYPE_INT_N_1
962 __size_to_integer(
unsigned __GLIBCXX_TYPE_INT_N_1 __n) {
return __n; }
964 #if defined(__GLIBCXX_TYPE_INT_N_2)
965 inline _GLIBCXX_CONSTEXPR __GLIBCXX_TYPE_INT_N_2
966 __size_to_integer(__GLIBCXX_TYPE_INT_N_2 __n) {
return __n; }
967 inline _GLIBCXX_CONSTEXPR
unsigned __GLIBCXX_TYPE_INT_N_2
968 __size_to_integer(
unsigned __GLIBCXX_TYPE_INT_N_2 __n) {
return __n; }
970 #if defined(__GLIBCXX_TYPE_INT_N_3)
971 inline _GLIBCXX_CONSTEXPR
unsigned __GLIBCXX_TYPE_INT_N_3
972 __size_to_integer(__GLIBCXX_TYPE_INT_N_3 __n) {
return __n; }
973 inline _GLIBCXX_CONSTEXPR __GLIBCXX_TYPE_INT_N_3
974 __size_to_integer(
unsigned __GLIBCXX_TYPE_INT_N_3 __n) {
return __n; }
977 inline _GLIBCXX_CONSTEXPR
long long
978 __size_to_integer(
float __n) {
return __n; }
979 inline _GLIBCXX_CONSTEXPR
long long
980 __size_to_integer(
double __n) {
return __n; }
981 inline _GLIBCXX_CONSTEXPR
long long
982 __size_to_integer(
long double __n) {
return __n; }
983 #if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_FLOAT128)
984 inline _GLIBCXX_CONSTEXPR
long long
985 __size_to_integer(__float128 __n) {
return __n; }
988 template<
typename _OutputIterator,
typename _Size,
typename _Tp>
991 __gnu_cxx::__enable_if<!__is_scalar<_Tp>::__value, _OutputIterator>::__type
992 __fill_n_a1(_OutputIterator __first, _Size __n,
const _Tp& __value)
994 for (; __n > 0; --__n, (void) ++__first)
999 template<
typename _OutputIterator,
typename _Size,
typename _Tp>
1000 _GLIBCXX20_CONSTEXPR
1002 __gnu_cxx::__enable_if<__is_scalar<_Tp>::__value, _OutputIterator>::__type
1003 __fill_n_a1(_OutputIterator __first, _Size __n,
const _Tp& __value)
1005 const _Tp __tmp = __value;
1006 for (; __n > 0; --__n, (void) ++__first)
1011 template<
typename _Ite,
typename _Seq,
typename _Cat,
typename _Size,
1014 __fill_n_a(const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>& __first,
1015 _Size __n,
const _Tp& __value,
1018 template<
typename _OutputIterator,
typename _Size,
typename _Tp>
1019 _GLIBCXX20_CONSTEXPR
1020 inline _OutputIterator
1021 __fill_n_a(_OutputIterator __first, _Size __n,
const _Tp& __value,
1024 #if __cplusplus >= 201103L
1025 static_assert(is_integral<_Size>{},
"fill_n must pass integral size");
1027 return __fill_n_a1(__first, __n, __value);
1030 template<
typename _OutputIterator,
typename _Size,
typename _Tp>
1031 _GLIBCXX20_CONSTEXPR
1032 inline _OutputIterator
1033 __fill_n_a(_OutputIterator __first, _Size __n,
const _Tp& __value,
1036 #if __cplusplus >= 201103L
1037 static_assert(is_integral<_Size>{},
"fill_n must pass integral size");
1039 return __fill_n_a1(__first, __n, __value);
1042 template<
typename _OutputIterator,
typename _Size,
typename _Tp>
1043 _GLIBCXX20_CONSTEXPR
1044 inline _OutputIterator
1045 __fill_n_a(_OutputIterator __first, _Size __n,
const _Tp& __value,
1048 #if __cplusplus >= 201103L
1049 static_assert(is_integral<_Size>{},
"fill_n must pass integral size");
1054 __glibcxx_requires_can_increment(__first, __n);
1056 std::__fill_a(__first, __first + __n, __value);
1057 return __first + __n;
1077 template<
typename _OI,
typename _Size,
typename _Tp>
1078 _GLIBCXX20_CONSTEXPR
1080 fill_n(_OI __first, _Size __n,
const _Tp& __value)
1083 __glibcxx_function_requires(_OutputIteratorConcept<_OI, _Tp>)
1085 return std::__fill_n_a(__first, std::__size_to_integer(__n), __value,
1089 template<
bool _BoolType>
1092 template<
typename _II1,
typename _II2>
1093 _GLIBCXX20_CONSTEXPR
1095 equal(_II1 __first1, _II1 __last1, _II2 __first2)
1097 for (; __first1 != __last1; ++__first1, (void) ++__first2)
1098 if (!(*__first1 == *__first2))
1105 struct __equal<true>
1107 template<
typename _Tp>
1108 _GLIBCXX20_CONSTEXPR
1110 equal(
const _Tp* __first1,
const _Tp* __last1,
const _Tp* __first2)
1112 if (
const size_t __len = (__last1 - __first1))
1113 return !std::__memcmp(__first1, __first2, __len);
1118 template<
typename _Tp,
typename _Ref,
typename _Ptr,
typename _II>
1119 typename __gnu_cxx::__enable_if<
1120 __is_random_access_iter<_II>::__value,
bool>::__type
1121 __equal_aux1(_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr>,
1122 _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr>,
1125 template<
typename _Tp1,
typename _Ref1,
typename _Ptr1,
1126 typename _Tp2,
typename _Ref2,
typename _Ptr2>
1128 __equal_aux1(_GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref1, _Ptr1>,
1129 _GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref1, _Ptr1>,
1130 _GLIBCXX_STD_C::_Deque_iterator<_Tp2, _Ref2, _Ptr2>);
1132 template<
typename _II,
typename _Tp,
typename _Ref,
typename _Ptr>
1133 typename __gnu_cxx::__enable_if<
1134 __is_random_access_iter<_II>::__value,
bool>::__type
1135 __equal_aux1(_II, _II,
1136 _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr>);
1138 template<
typename _II1,
typename _II2>
1139 _GLIBCXX20_CONSTEXPR
1141 __equal_aux1(_II1 __first1, _II1 __last1, _II2 __first2)
1143 typedef typename iterator_traits<_II1>::value_type _ValueType1;
1144 const bool __simple = ((__is_integer<_ValueType1>::__value
1145 || __is_pointer<_ValueType1>::__value)
1146 && __memcmpable<_II1, _II2>::__value);
1150 template<
typename _II1,
typename _II2>
1151 _GLIBCXX20_CONSTEXPR
1153 __equal_aux(_II1 __first1, _II1 __last1, _II2 __first2)
1155 return std::__equal_aux1(std::__niter_base(__first1),
1156 std::__niter_base(__last1),
1157 std::__niter_base(__first2));
1160 template<
typename _II1,
typename _Seq1,
typename _Cat1,
typename _II2>
1162 __equal_aux(const ::__gnu_debug::_Safe_iterator<_II1, _Seq1, _Cat1>&,
1163 const ::__gnu_debug::_Safe_iterator<_II1, _Seq1, _Cat1>&,
1166 template<
typename _II1,
typename _II2,
typename _Seq2,
typename _Cat2>
1168 __equal_aux(_II1, _II1,
1169 const ::__gnu_debug::_Safe_iterator<_II2, _Seq2, _Cat2>&);
1171 template<
typename _II1,
typename _Seq1,
typename _Cat1,
1172 typename _II2,
typename _Seq2,
typename _Cat2>
1174 __equal_aux(const ::__gnu_debug::_Safe_iterator<_II1, _Seq1, _Cat1>&,
1175 const ::__gnu_debug::_Safe_iterator<_II1, _Seq1, _Cat1>&,
1176 const ::__gnu_debug::_Safe_iterator<_II2, _Seq2, _Cat2>&);
1178 template<
typename,
typename>
1181 template<
typename _II1,
typename _II2>
1182 _GLIBCXX20_CONSTEXPR
1184 __newlast1(_II1, _II1 __last1, _II2, _II2)
1187 template<
typename _II>
1188 _GLIBCXX20_CONSTEXPR
1190 __cnd2(_II __first, _II __last)
1191 {
return __first != __last; }
1195 struct __lc_rai<random_access_iterator_tag, random_access_iterator_tag>
1197 template<
typename _RAI1,
typename _RAI2>
1198 _GLIBCXX20_CONSTEXPR
1200 __newlast1(_RAI1 __first1, _RAI1 __last1,
1201 _RAI2 __first2, _RAI2 __last2)
1203 const typename iterator_traits<_RAI1>::difference_type
1204 __diff1 = __last1 - __first1;
1205 const typename iterator_traits<_RAI2>::difference_type
1206 __diff2 = __last2 - __first2;
1207 return __diff2 < __diff1 ? __first1 + __diff2 : __last1;
1210 template<
typename _RAI>
1211 static _GLIBCXX20_CONSTEXPR
bool
1216 template<
typename _II1,
typename _II2,
typename _Compare>
1217 _GLIBCXX20_CONSTEXPR
1219 __lexicographical_compare_impl(_II1 __first1, _II1 __last1,
1220 _II2 __first2, _II2 __last2,
1223 typedef typename iterator_traits<_II1>::iterator_category _Category1;
1224 typedef typename iterator_traits<_II2>::iterator_category _Category2;
1225 typedef std::__lc_rai<_Category1, _Category2> __rai_type;
1227 __last1 = __rai_type::__newlast1(__first1, __last1, __first2, __last2);
1228 for (; __first1 != __last1 && __rai_type::__cnd2(__first2, __last2);
1229 ++__first1, (void)++__first2)
1231 if (__comp(__first1, __first2))
1233 if (__comp(__first2, __first1))
1236 return __first1 == __last1 && __first2 != __last2;
1239 template<
bool _BoolType>
1240 struct __lexicographical_compare
1242 template<
typename _II1,
typename _II2>
1243 _GLIBCXX20_CONSTEXPR
1245 __lc(_II1 __first1, _II1 __last1, _II2 __first2, _II2 __last2)
1247 using __gnu_cxx::__ops::__iter_less_iter;
1248 return std::__lexicographical_compare_impl(__first1, __last1,
1250 __iter_less_iter());
1255 struct __lexicographical_compare<true>
1257 template<
typename _Tp,
typename _Up>
1258 _GLIBCXX20_CONSTEXPR
1260 __lc(
const _Tp* __first1,
const _Tp* __last1,
1261 const _Up* __first2,
const _Up* __last2)
1263 const size_t __len1 = __last1 - __first1;
1264 const size_t __len2 = __last2 - __first2;
1265 if (
const size_t __len =
std::min(__len1, __len2))
1266 if (
int __result = std::__memcmp(__first1, __first2, __len))
1267 return __result < 0;
1268 return __len1 < __len2;
1272 template<
typename _II1,
typename _II2>
1273 _GLIBCXX20_CONSTEXPR
1275 __lexicographical_compare_aux(_II1 __first1, _II1 __last1,
1276 _II2 __first2, _II2 __last2)
1278 typedef typename iterator_traits<_II1>::value_type _ValueType1;
1279 typedef typename iterator_traits<_II2>::value_type _ValueType2;
1280 const bool __simple =
1281 (__is_byte<_ValueType1>::__value && __is_byte<_ValueType2>::__value
1282 && !__gnu_cxx::__numeric_traits<_ValueType1>::__is_signed
1283 && !__gnu_cxx::__numeric_traits<_ValueType2>::__is_signed
1284 && __is_pointer<_II1>::__value
1285 && __is_pointer<_II2>::__value
1286 #if __cplusplus > 201703L && __cpp_lib_concepts
1290 && !is_volatile_v<remove_reference_t<iter_reference_t<_II1>>>
1291 && !is_volatile_v<remove_reference_t<iter_reference_t<_II2>>>
1295 return std::__lexicographical_compare<__simple>::__lc(__first1, __last1,
1299 template<
typename _ForwardIterator,
typename _Tp,
typename _Compare>
1300 _GLIBCXX20_CONSTEXPR
1302 __lower_bound(_ForwardIterator __first, _ForwardIterator __last,
1303 const _Tp& __val, _Compare __comp)
1305 typedef typename iterator_traits<_ForwardIterator>::difference_type
1312 _DistanceType __half = __len >> 1;
1313 _ForwardIterator __middle = __first;
1315 if (__comp(__middle, __val))
1319 __len = __len - __half - 1;
1338 template<
typename _ForwardIterator,
typename _Tp>
1339 _GLIBCXX20_CONSTEXPR
1340 inline _ForwardIterator
1341 lower_bound(_ForwardIterator __first, _ForwardIterator __last,
1345 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
1346 __glibcxx_function_requires(_LessThanOpConcept<
1348 __glibcxx_requires_partitioned_lower(__first, __last, __val);
1350 return std::__lower_bound(__first, __last, __val,
1351 __gnu_cxx::__ops::__iter_less_val());
1356 inline _GLIBCXX_CONSTEXPR
int
1358 {
return (
int)
sizeof(int) * __CHAR_BIT__ - 1 - __builtin_clz(__n); }
1360 inline _GLIBCXX_CONSTEXPR
unsigned
1362 {
return (
int)
sizeof(int) * __CHAR_BIT__ - 1 - __builtin_clz(__n); }
1364 inline _GLIBCXX_CONSTEXPR
long
1366 {
return (
int)
sizeof(long) * __CHAR_BIT__ - 1 - __builtin_clzl(__n); }
1368 inline _GLIBCXX_CONSTEXPR
unsigned long
1369 __lg(
unsigned long __n)
1370 {
return (
int)
sizeof(long) * __CHAR_BIT__ - 1 - __builtin_clzl(__n); }
1372 inline _GLIBCXX_CONSTEXPR
long long
1374 {
return (
int)
sizeof(
long long) * __CHAR_BIT__ - 1 - __builtin_clzll(__n); }
1376 inline _GLIBCXX_CONSTEXPR
unsigned long long
1377 __lg(
unsigned long long __n)
1378 {
return (
int)
sizeof(
long long) * __CHAR_BIT__ - 1 - __builtin_clzll(__n); }
1380 _GLIBCXX_BEGIN_NAMESPACE_ALGO
1394 template<
typename _II1,
typename _II2>
1395 _GLIBCXX20_CONSTEXPR
1397 equal(_II1 __first1, _II1 __last1, _II2 __first2)
1400 __glibcxx_function_requires(_InputIteratorConcept<_II1>)
1401 __glibcxx_function_requires(_InputIteratorConcept<_II2>)
1402 __glibcxx_function_requires(_EqualOpConcept<
1405 __glibcxx_requires_can_increment_range(__first1, __last1, __first2);
1407 return std::__equal_aux(__first1, __last1, __first2);
1425 template<
typename _IIter1,
typename _IIter2,
typename _BinaryPredicate>
1426 _GLIBCXX20_CONSTEXPR
1428 equal(_IIter1 __first1, _IIter1 __last1,
1429 _IIter2 __first2, _BinaryPredicate __binary_pred)
1432 __glibcxx_function_requires(_InputIteratorConcept<_IIter1>)
1433 __glibcxx_function_requires(_InputIteratorConcept<_IIter2>)
1434 __glibcxx_requires_valid_range(__first1, __last1);
1436 for (; __first1 != __last1; ++__first1, (void)++__first2)
1437 if (!
bool(__binary_pred(*__first1, *__first2)))
1442 #if __cplusplus >= 201103L
1444 template<
typename _II1,
typename _II2>
1445 _GLIBCXX20_CONSTEXPR
1447 __equal4(_II1 __first1, _II1 __last1, _II2 __first2, _II2 __last2)
1449 using _RATag = random_access_iterator_tag;
1450 using _Cat1 =
typename iterator_traits<_II1>::iterator_category;
1451 using _Cat2 =
typename iterator_traits<_II2>::iterator_category;
1452 using _RAIters = __and_<is_same<_Cat1, _RATag>, is_same<_Cat2, _RATag>>;
1462 for (; __first1 != __last1 && __first2 != __last2;
1463 ++__first1, (void)++__first2)
1464 if (!(*__first1 == *__first2))
1466 return __first1 == __last1 && __first2 == __last2;
1470 template<
typename _II1,
typename _II2,
typename _BinaryPredicate>
1471 _GLIBCXX20_CONSTEXPR
1473 __equal4(_II1 __first1, _II1 __last1, _II2 __first2, _II2 __last2,
1474 _BinaryPredicate __binary_pred)
1476 using _RATag = random_access_iterator_tag;
1477 using _Cat1 =
typename iterator_traits<_II1>::iterator_category;
1478 using _Cat2 =
typename iterator_traits<_II2>::iterator_category;
1479 using _RAIters = __and_<is_same<_Cat1, _RATag>, is_same<_Cat2, _RATag>>;
1490 for (; __first1 != __last1 && __first2 != __last2;
1491 ++__first1, (void)++__first2)
1492 if (!
bool(__binary_pred(*__first1, *__first2)))
1494 return __first1 == __last1 && __first2 == __last2;
1498 #if __cplusplus > 201103L
1500 #define __cpp_lib_robust_nonmodifying_seq_ops 201304
1515 template<
typename _II1,
typename _II2>
1516 _GLIBCXX20_CONSTEXPR
1518 equal(_II1 __first1, _II1 __last1, _II2 __first2, _II2 __last2)
1521 __glibcxx_function_requires(_InputIteratorConcept<_II1>)
1522 __glibcxx_function_requires(_InputIteratorConcept<_II2>)
1523 __glibcxx_function_requires(_EqualOpConcept<
1526 __glibcxx_requires_valid_range(__first1, __last1);
1527 __glibcxx_requires_valid_range(__first2, __last2);
1529 return _GLIBCXX_STD_A::__equal4(__first1, __last1, __first2, __last2);
1548 template<
typename _IIter1,
typename _IIter2,
typename _BinaryPredicate>
1549 _GLIBCXX20_CONSTEXPR
1551 equal(_IIter1 __first1, _IIter1 __last1,
1552 _IIter2 __first2, _IIter2 __last2, _BinaryPredicate __binary_pred)
1555 __glibcxx_function_requires(_InputIteratorConcept<_IIter1>)
1556 __glibcxx_function_requires(_InputIteratorConcept<_IIter2>)
1557 __glibcxx_requires_valid_range(__first1, __last1);
1558 __glibcxx_requires_valid_range(__first2, __last2);
1560 return _GLIBCXX_STD_A::__equal4(__first1, __last1, __first2, __last2,
1580 template<
typename _II1,
typename _II2>
1581 _GLIBCXX20_CONSTEXPR
1583 lexicographical_compare(_II1 __first1, _II1 __last1,
1584 _II2 __first2, _II2 __last2)
1586 #ifdef _GLIBCXX_CONCEPT_CHECKS
1591 __glibcxx_function_requires(_InputIteratorConcept<_II1>)
1592 __glibcxx_function_requires(_InputIteratorConcept<_II2>)
1593 __glibcxx_function_requires(_LessThanOpConcept<_ValueType1, _ValueType2>)
1594 __glibcxx_function_requires(_LessThanOpConcept<_ValueType2, _ValueType1>)
1595 __glibcxx_requires_valid_range(__first1, __last1);
1596 __glibcxx_requires_valid_range(__first2, __last2);
1598 return std::__lexicographical_compare_aux(std::__niter_base(__first1),
1599 std::__niter_base(__last1),
1600 std::__niter_base(__first2),
1601 std::__niter_base(__last2));
1617 template<
typename _II1,
typename _II2,
typename _Compare>
1618 _GLIBCXX20_CONSTEXPR
1620 lexicographical_compare(_II1 __first1, _II1 __last1,
1621 _II2 __first2, _II2 __last2, _Compare __comp)
1624 __glibcxx_function_requires(_InputIteratorConcept<_II1>)
1625 __glibcxx_function_requires(_InputIteratorConcept<_II2>)
1626 __glibcxx_requires_valid_range(__first1, __last1);
1627 __glibcxx_requires_valid_range(__first2, __last2);
1629 return std::__lexicographical_compare_impl
1630 (__first1, __last1, __first2, __last2,
1631 __gnu_cxx::__ops::__iter_comp_iter(__comp));
1634 #if __cpp_lib_three_way_comparison
1637 template<
typename _Iter>
1638 concept __is_byte_iter = contiguous_iterator<_Iter>
1639 && __is_byte<iter_value_t<_Iter>>::__value != 0
1640 && !__gnu_cxx::__numeric_traits<iter_value_t<_Iter>>::__is_signed;
1644 template<
typename _Tp>
1646 __min_cmp(_Tp __x, _Tp __y)
1650 decltype(__x <=> __y) _M_cmp;
1652 auto __c = __x <=> __y;
1654 return _Res{__y, __c};
1655 return _Res{__x, __c};
1669 template<
typename _InputIter1,
typename _InputIter2,
typename _Comp>
1671 lexicographical_compare_three_way(_InputIter1 __first1,
1672 _InputIter1 __last1,
1673 _InputIter2 __first2,
1674 _InputIter2 __last2,
1676 -> decltype(__comp(*__first1, *__first2))
1679 __glibcxx_function_requires(_InputIteratorConcept<_InputIter1>)
1680 __glibcxx_function_requires(_InputIteratorConcept<_InputIter2>)
1681 __glibcxx_requires_valid_range(__first1, __last1);
1682 __glibcxx_requires_valid_range(__first2, __last2);
1684 #if __cpp_lib_is_constant_evaluated
1685 using _Cat = decltype(__comp(*__first1, *__first2));
1686 static_assert(same_as<common_comparison_category_t<_Cat>, _Cat>);
1688 if (!std::is_constant_evaluated())
1689 if constexpr (same_as<_Comp, __detail::_Synth3way>
1690 || same_as<_Comp, compare_three_way>)
1691 if constexpr (__is_byte_iter<_InputIter1>)
1692 if constexpr (__is_byte_iter<_InputIter2>)
1694 const auto [__len, __lencmp]
1695 = std::__min_cmp(__last1 - __first1, __last2 - __first2);
1699 = __builtin_memcmp(&*__first1, &*__first2, __len) <=> 0;
1705 #endif // is_constant_evaluated
1706 while (__first1 != __last1)
1708 if (__first2 == __last2)
1709 return strong_ordering::greater;
1710 if (
auto __cmp = __comp(*__first1, *__first2); __cmp != 0)
1715 return (__first2 == __last2) <=>
true;
1718 template<
typename _InputIter1,
typename _InputIter2>
1720 lexicographical_compare_three_way(_InputIter1 __first1,
1721 _InputIter1 __last1,
1722 _InputIter2 __first2,
1723 _InputIter2 __last2)
1725 return std::lexicographical_compare_three_way(__first1, __last1,
1727 compare_three_way{});
1729 #endif // three_way_comparison
1731 template<
typename _InputIterator1,
typename _InputIterator2,
1732 typename _BinaryPredicate>
1733 _GLIBCXX20_CONSTEXPR
1734 pair<_InputIterator1, _InputIterator2>
1735 __mismatch(_InputIterator1 __first1, _InputIterator1 __last1,
1736 _InputIterator2 __first2, _BinaryPredicate __binary_pred)
1738 while (__first1 != __last1 && __binary_pred(__first1, __first2))
1743 return pair<_InputIterator1, _InputIterator2>(__first1, __first2);
1759 template<
typename _InputIterator1,
typename _InputIterator2>
1760 _GLIBCXX20_CONSTEXPR
1761 inline pair<_InputIterator1, _InputIterator2>
1762 mismatch(_InputIterator1 __first1, _InputIterator1 __last1,
1763 _InputIterator2 __first2)
1766 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
1767 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
1768 __glibcxx_function_requires(_EqualOpConcept<
1771 __glibcxx_requires_valid_range(__first1, __last1);
1773 return _GLIBCXX_STD_A::__mismatch(__first1, __last1, __first2,
1774 __gnu_cxx::__ops::__iter_equal_to_iter());
1793 template<
typename _InputIterator1,
typename _InputIterator2,
1794 typename _BinaryPredicate>
1795 _GLIBCXX20_CONSTEXPR
1796 inline pair<_InputIterator1, _InputIterator2>
1797 mismatch(_InputIterator1 __first1, _InputIterator1 __last1,
1798 _InputIterator2 __first2, _BinaryPredicate __binary_pred)
1801 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
1802 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
1803 __glibcxx_requires_valid_range(__first1, __last1);
1805 return _GLIBCXX_STD_A::__mismatch(__first1, __last1, __first2,
1806 __gnu_cxx::__ops::__iter_comp_iter(__binary_pred));
1809 #if __cplusplus > 201103L
1811 template<
typename _InputIterator1,
typename _InputIterator2,
1812 typename _BinaryPredicate>
1813 _GLIBCXX20_CONSTEXPR
1814 pair<_InputIterator1, _InputIterator2>
1815 __mismatch(_InputIterator1 __first1, _InputIterator1 __last1,
1816 _InputIterator2 __first2, _InputIterator2 __last2,
1817 _BinaryPredicate __binary_pred)
1819 while (__first1 != __last1 && __first2 != __last2
1820 && __binary_pred(__first1, __first2))
1825 return pair<_InputIterator1, _InputIterator2>(__first1, __first2);
1842 template<
typename _InputIterator1,
typename _InputIterator2>
1843 _GLIBCXX20_CONSTEXPR
1844 inline pair<_InputIterator1, _InputIterator2>
1845 mismatch(_InputIterator1 __first1, _InputIterator1 __last1,
1846 _InputIterator2 __first2, _InputIterator2 __last2)
1849 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
1850 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
1851 __glibcxx_function_requires(_EqualOpConcept<
1854 __glibcxx_requires_valid_range(__first1, __last1);
1855 __glibcxx_requires_valid_range(__first2, __last2);
1857 return _GLIBCXX_STD_A::__mismatch(__first1, __last1, __first2, __last2,
1858 __gnu_cxx::__ops::__iter_equal_to_iter());
1878 template<
typename _InputIterator1,
typename _InputIterator2,
1879 typename _BinaryPredicate>
1880 _GLIBCXX20_CONSTEXPR
1881 inline pair<_InputIterator1, _InputIterator2>
1882 mismatch(_InputIterator1 __first1, _InputIterator1 __last1,
1883 _InputIterator2 __first2, _InputIterator2 __last2,
1884 _BinaryPredicate __binary_pred)
1887 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
1888 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
1889 __glibcxx_requires_valid_range(__first1, __last1);
1890 __glibcxx_requires_valid_range(__first2, __last2);
1892 return _GLIBCXX_STD_A::__mismatch(__first1, __last1, __first2, __last2,
1893 __gnu_cxx::__ops::__iter_comp_iter(__binary_pred));
1897 _GLIBCXX_END_NAMESPACE_ALGO
1900 template<
typename _InputIterator,
typename _Predicate>
1901 _GLIBCXX20_CONSTEXPR
1902 inline _InputIterator
1906 while (__first != __last && !__pred(__first))
1912 template<
typename _RandomAccessIterator,
typename _Predicate>
1913 _GLIBCXX20_CONSTEXPR
1914 _RandomAccessIterator
1915 __find_if(_RandomAccessIterator __first, _RandomAccessIterator __last,
1919 __trip_count = (__last - __first) >> 2;
1921 for (; __trip_count > 0; --__trip_count)
1923 if (__pred(__first))
1927 if (__pred(__first))
1931 if (__pred(__first))
1935 if (__pred(__first))
1940 switch (__last - __first)
1943 if (__pred(__first))
1947 if (__pred(__first))
1951 if (__pred(__first))
1960 template<
typename _Iterator,
typename _Predicate>
1961 _GLIBCXX20_CONSTEXPR
1963 __find_if(_Iterator __first, _Iterator __last, _Predicate __pred)
1965 return __find_if(__first, __last, __pred,
1969 template<
typename _InputIterator,
typename _Predicate>
1970 _GLIBCXX20_CONSTEXPR
1971 typename iterator_traits<_InputIterator>::difference_type
1972 __count_if(_InputIterator __first, _InputIterator __last, _Predicate __pred)
1974 typename iterator_traits<_InputIterator>::difference_type __n = 0;
1975 for (; __first != __last; ++__first)
1976 if (__pred(__first))
1981 #if __cplusplus >= 201103L
1982 template<
typename _ForwardIterator1,
typename _ForwardIterator2,
1983 typename _BinaryPredicate>
1984 _GLIBCXX20_CONSTEXPR
1986 __is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
1987 _ForwardIterator2 __first2, _BinaryPredicate __pred)
1991 for (; __first1 != __last1; ++__first1, (void)++__first2)
1992 if (!__pred(__first1, __first2))
1995 if (__first1 == __last1)
2000 _ForwardIterator2 __last2 = __first2;
2002 for (_ForwardIterator1 __scan = __first1; __scan != __last1; ++__scan)
2005 __gnu_cxx::__ops::__iter_comp_iter(__pred, __scan)))
2009 = std::__count_if(__first2, __last2,
2010 __gnu_cxx::__ops::__iter_comp_iter(__pred, __scan));
2011 if (0 == __matches ||
2012 std::__count_if(__scan, __last1,
2013 __gnu_cxx::__ops::__iter_comp_iter(__pred, __scan))
2032 template<
typename _ForwardIterator1,
typename _ForwardIterator2>
2033 _GLIBCXX20_CONSTEXPR
2035 is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
2036 _ForwardIterator2 __first2)
2039 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator1>)
2040 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator2>)
2041 __glibcxx_function_requires(_EqualOpConcept<
2044 __glibcxx_requires_valid_range(__first1, __last1);
2046 return std::__is_permutation(__first1, __last1, __first2,
2047 __gnu_cxx::__ops::__iter_equal_to_iter());
2051 _GLIBCXX_END_NAMESPACE_VERSION
2057 #ifdef _GLIBCXX_PARALLEL