56 #ifndef _STL_ALGOBASE_H 57 #define _STL_ALGOBASE_H 1 73 namespace std _GLIBCXX_VISIBILITY(default)
75 _GLIBCXX_BEGIN_NAMESPACE_VERSION
77 #if __cplusplus < 201103L 81 template<
bool _BoolType>
84 template<
typename _ForwardIterator1,
typename _ForwardIterator2>
86 iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b)
88 typedef typename iterator_traits<_ForwardIterator1>::value_type
90 _ValueType1 __tmp = _GLIBCXX_MOVE(*__a);
91 *__a = _GLIBCXX_MOVE(*__b);
92 *__b = _GLIBCXX_MOVE(__tmp);
97 struct __iter_swap<true>
99 template<
typename _ForwardIterator1,
typename _ForwardIterator2>
101 iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b)
118 template<
typename _ForwardIterator1,
typename _ForwardIterator2>
120 iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b)
123 __glibcxx_function_requires(_Mutable_ForwardIteratorConcept<
125 __glibcxx_function_requires(_Mutable_ForwardIteratorConcept<
128 #if __cplusplus < 201103L 129 typedef typename iterator_traits<_ForwardIterator1>::value_type
131 typedef typename iterator_traits<_ForwardIterator2>::value_type
134 __glibcxx_function_requires(_ConvertibleConcept<_ValueType1,
136 __glibcxx_function_requires(_ConvertibleConcept<_ValueType2,
139 typedef typename iterator_traits<_ForwardIterator1>::reference
141 typedef typename iterator_traits<_ForwardIterator2>::reference
143 std::__iter_swap<__are_same<_ValueType1, _ValueType2>::__value
144 && __are_same<_ValueType1&, _ReferenceType1>::__value
145 && __are_same<_ValueType2&, _ReferenceType2>::__value>::
164 template<
typename _ForwardIterator1,
typename _ForwardIterator2>
166 swap_ranges(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
167 _ForwardIterator2 __first2)
170 __glibcxx_function_requires(_Mutable_ForwardIteratorConcept<
172 __glibcxx_function_requires(_Mutable_ForwardIteratorConcept<
174 __glibcxx_requires_valid_range(__first1, __last1);
176 for (; __first1 != __last1; ++__first1, (void)++__first2)
192 template<
typename _Tp>
195 min(
const _Tp& __a,
const _Tp& __b)
198 __glibcxx_function_requires(_LessThanComparableConcept<_Tp>)
216 template<
typename _Tp>
219 max(
const _Tp& __a,
const _Tp& __b)
222 __glibcxx_function_requires(_LessThanComparableConcept<_Tp>)
240 template<
typename _Tp,
typename _Compare>
243 min(
const _Tp& __a,
const _Tp& __b, _Compare __comp)
246 if (__comp(__b, __a))
262 template<
typename _Tp,
typename _Compare>
265 max(
const _Tp& __a,
const _Tp& __b, _Compare __comp)
268 if (__comp(__a, __b))
275 template<
typename _Iterator>
277 __niter_base(_Iterator __it)
286 template<
bool,
bool,
typename>
289 template<
typename _II,
typename _OI>
291 __copy_m(_II __first, _II __last, _OI __result)
293 for (; __first != __last; ++__result, (void)++__first)
294 *__result = *__first;
299 #if __cplusplus >= 201103L 300 template<
typename _Category>
301 struct __copy_move<true, false, _Category>
303 template<
typename _II,
typename _OI>
305 __copy_m(_II __first, _II __last, _OI __result)
307 for (; __first != __last; ++__result, (void)++__first)
308 *__result = std::move(*__first);
315 struct __copy_move<false, false, random_access_iterator_tag>
317 template<
typename _II,
typename _OI>
319 __copy_m(_II __first, _II __last, _OI __result)
321 typedef typename iterator_traits<_II>::difference_type _Distance;
322 for(_Distance __n = __last - __first; __n > 0; --__n)
324 *__result = *__first;
332 #if __cplusplus >= 201103L 334 struct __copy_move<true, false, random_access_iterator_tag>
336 template<
typename _II,
typename _OI>
338 __copy_m(_II __first, _II __last, _OI __result)
340 typedef typename iterator_traits<_II>::difference_type _Distance;
341 for(_Distance __n = __last - __first; __n > 0; --__n)
343 *__result = std::move(*__first);
352 template<
bool _IsMove>
353 struct __copy_move<_IsMove, true, random_access_iterator_tag>
355 template<
typename _Tp>
357 __copy_m(
const _Tp* __first,
const _Tp* __last, _Tp* __result)
359 #if __cplusplus >= 201103L 360 using __assignable = conditional<_IsMove,
361 is_move_assignable<_Tp>,
362 is_copy_assignable<_Tp>>;
364 static_assert( __assignable::type::value,
"type is not assignable" );
366 const ptrdiff_t _Num = __last - __first;
368 __builtin_memmove(__result, __first,
sizeof(_Tp) * _Num);
369 return __result + _Num;
373 template<
bool _IsMove,
typename _II,
typename _OI>
375 __copy_move_a(_II __first, _II __last, _OI __result)
377 typedef typename iterator_traits<_II>::value_type _ValueTypeI;
378 typedef typename iterator_traits<_OI>::value_type _ValueTypeO;
379 typedef typename iterator_traits<_II>::iterator_category _Category;
380 const bool __simple = (__is_trivial(_ValueTypeI)
381 && __is_pointer<_II>::__value
382 && __is_pointer<_OI>::__value
383 && __are_same<_ValueTypeI, _ValueTypeO>::__value);
385 return std::__copy_move<_IsMove, __simple,
386 _Category>::__copy_m(__first, __last, __result);
391 template<
typename _CharT>
394 template<
typename _CharT,
typename _Traits>
397 template<
typename _CharT,
typename _Traits>
400 template<
bool _IsMove,
typename _CharT>
401 typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
403 __copy_move_a2(_CharT*, _CharT*,
406 template<
bool _IsMove,
typename _CharT>
407 typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
409 __copy_move_a2(
const _CharT*,
const _CharT*,
412 template<
bool _IsMove,
typename _CharT>
413 typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
418 template<
bool _IsMove,
typename _II,
typename _OI>
420 __copy_move_a2(_II __first, _II __last, _OI __result)
422 return _OI(std::__copy_move_a<_IsMove>(std::__niter_base(__first),
423 std::__niter_base(__last),
424 std::__niter_base(__result)));
444 template<
typename _II,
typename _OI>
446 copy(_II __first, _II __last, _OI __result)
449 __glibcxx_function_requires(_InputIteratorConcept<_II>)
450 __glibcxx_function_requires(_OutputIteratorConcept<_OI,
451 typename iterator_traits<_II>::value_type>)
452 __glibcxx_requires_valid_range(__first, __last);
454 return (std::__copy_move_a2<__is_move_iterator<_II>::__value>
455 (std::__miter_base(__first), std::__miter_base(__last),
459 #if __cplusplus >= 201103L 477 template<
typename _II,
typename _OI>
479 move(_II __first, _II __last, _OI __result)
482 __glibcxx_function_requires(_InputIteratorConcept<_II>)
483 __glibcxx_function_requires(_OutputIteratorConcept<_OI,
484 typename iterator_traits<_II>::value_type>)
485 __glibcxx_requires_valid_range(__first, __last);
487 return std::__copy_move_a2<true>(std::__miter_base(__first),
488 std::__miter_base(__last), __result);
491 #define _GLIBCXX_MOVE3(_Tp, _Up, _Vp) std::move(_Tp, _Up, _Vp) 493 #define _GLIBCXX_MOVE3(_Tp, _Up, _Vp) std::copy(_Tp, _Up, _Vp) 496 template<
bool,
bool,
typename>
497 struct __copy_move_backward
499 template<
typename _BI1,
typename _BI2>
501 __copy_move_b(_BI1 __first, _BI1 __last, _BI2 __result)
503 while (__first != __last)
504 *--__result = *--__last;
509 #if __cplusplus >= 201103L 510 template<
typename _Category>
511 struct __copy_move_backward<true, false, _Category>
513 template<
typename _BI1,
typename _BI2>
515 __copy_move_b(_BI1 __first, _BI1 __last, _BI2 __result)
517 while (__first != __last)
518 *--__result = std::move(*--__last);
525 struct __copy_move_backward<false, false, random_access_iterator_tag>
527 template<
typename _BI1,
typename _BI2>
529 __copy_move_b(_BI1 __first, _BI1 __last, _BI2 __result)
531 typename iterator_traits<_BI1>::difference_type __n;
532 for (__n = __last - __first; __n > 0; --__n)
533 *--__result = *--__last;
538 #if __cplusplus >= 201103L 540 struct __copy_move_backward<true, false, random_access_iterator_tag>
542 template<
typename _BI1,
typename _BI2>
544 __copy_move_b(_BI1 __first, _BI1 __last, _BI2 __result)
546 typename iterator_traits<_BI1>::difference_type __n;
547 for (__n = __last - __first; __n > 0; --__n)
548 *--__result = std::move(*--__last);
554 template<
bool _IsMove>
555 struct __copy_move_backward<_IsMove, true, random_access_iterator_tag>
557 template<
typename _Tp>
559 __copy_move_b(
const _Tp* __first,
const _Tp* __last, _Tp* __result)
561 #if __cplusplus >= 201103L 562 using __assignable = conditional<_IsMove,
563 is_move_assignable<_Tp>,
564 is_copy_assignable<_Tp>>;
566 static_assert( __assignable::type::value,
"type is not assignable" );
568 const ptrdiff_t _Num = __last - __first;
570 __builtin_memmove(__result - _Num, __first,
sizeof(_Tp) * _Num);
571 return __result - _Num;
575 template<
bool _IsMove,
typename _BI1,
typename _BI2>
577 __copy_move_backward_a(_BI1 __first, _BI1 __last, _BI2 __result)
579 typedef typename iterator_traits<_BI1>::value_type _ValueType1;
580 typedef typename iterator_traits<_BI2>::value_type _ValueType2;
581 typedef typename iterator_traits<_BI1>::iterator_category _Category;
582 const bool __simple = (__is_trivial(_ValueType1)
583 && __is_pointer<_BI1>::__value
584 && __is_pointer<_BI2>::__value
585 && __are_same<_ValueType1, _ValueType2>::__value);
587 return std::__copy_move_backward<_IsMove, __simple,
588 _Category>::__copy_move_b(__first,
593 template<
bool _IsMove,
typename _BI1,
typename _BI2>
595 __copy_move_backward_a2(_BI1 __first, _BI1 __last, _BI2 __result)
597 return _BI2(std::__copy_move_backward_a<_IsMove>
598 (std::__niter_base(__first), std::__niter_base(__last),
599 std::__niter_base(__result)));
620 template<
typename _BI1,
typename _BI2>
622 copy_backward(_BI1 __first, _BI1 __last, _BI2 __result)
625 __glibcxx_function_requires(_BidirectionalIteratorConcept<_BI1>)
626 __glibcxx_function_requires(_Mutable_BidirectionalIteratorConcept<_BI2>)
627 __glibcxx_function_requires(_ConvertibleConcept<
628 typename iterator_traits<_BI1>::value_type,
629 typename iterator_traits<_BI2>::value_type>)
630 __glibcxx_requires_valid_range(__first, __last);
632 return (std::__copy_move_backward_a2<__is_move_iterator<_BI1>::__value>
633 (std::__miter_base(__first), std::__miter_base(__last),
637 #if __cplusplus >= 201103L 656 template<
typename _BI1,
typename _BI2>
658 move_backward(_BI1 __first, _BI1 __last, _BI2 __result)
661 __glibcxx_function_requires(_BidirectionalIteratorConcept<_BI1>)
662 __glibcxx_function_requires(_Mutable_BidirectionalIteratorConcept<_BI2>)
663 __glibcxx_function_requires(_ConvertibleConcept<
664 typename iterator_traits<_BI1>::value_type,
665 typename iterator_traits<_BI2>::value_type>)
666 __glibcxx_requires_valid_range(__first, __last);
668 return std::__copy_move_backward_a2<true>(std::__miter_base(__first),
669 std::__miter_base(__last),
673 #define _GLIBCXX_MOVE_BACKWARD3(_Tp, _Up, _Vp) std::move_backward(_Tp, _Up, _Vp) 675 #define _GLIBCXX_MOVE_BACKWARD3(_Tp, _Up, _Vp) std::copy_backward(_Tp, _Up, _Vp) 678 template<
typename _ForwardIterator,
typename _Tp>
680 __gnu_cxx::__enable_if<!__is_scalar<_Tp>::__value,
void>::__type
681 __fill_a(_ForwardIterator __first, _ForwardIterator __last,
684 for (; __first != __last; ++__first)
688 template<
typename _ForwardIterator,
typename _Tp>
690 __gnu_cxx::__enable_if<__is_scalar<_Tp>::__value,
void>::__type
691 __fill_a(_ForwardIterator __first, _ForwardIterator __last,
694 const _Tp __tmp = __value;
695 for (; __first != __last; ++__first)
700 template<
typename _Tp>
702 __gnu_cxx::__enable_if<__is_byte<_Tp>::__value,
void>::__type
703 __fill_a(_Tp* __first, _Tp* __last,
const _Tp& __c)
705 const _Tp __tmp = __c;
706 if (
const size_t __len = __last - __first)
707 __builtin_memset(__first, static_cast<unsigned char>(__tmp), __len);
722 template<
typename _ForwardIterator,
typename _Tp>
724 fill(_ForwardIterator __first, _ForwardIterator __last,
const _Tp& __value)
727 __glibcxx_function_requires(_Mutable_ForwardIteratorConcept<
729 __glibcxx_requires_valid_range(__first, __last);
731 std::__fill_a(std::__niter_base(__first), std::__niter_base(__last),
735 template<
typename _OutputIterator,
typename _Size,
typename _Tp>
737 __gnu_cxx::__enable_if<!__is_scalar<_Tp>::__value, _OutputIterator>::__type
738 __fill_n_a(_OutputIterator __first, _Size __n,
const _Tp& __value)
740 for (__decltype(__n + 0) __niter = __n;
741 __niter > 0; --__niter, ++__first)
746 template<
typename _OutputIterator,
typename _Size,
typename _Tp>
748 __gnu_cxx::__enable_if<__is_scalar<_Tp>::__value, _OutputIterator>::__type
749 __fill_n_a(_OutputIterator __first, _Size __n,
const _Tp& __value)
751 const _Tp __tmp = __value;
752 for (__decltype(__n + 0) __niter = __n;
753 __niter > 0; --__niter, ++__first)
758 template<
typename _Size,
typename _Tp>
760 __gnu_cxx::__enable_if<__is_byte<_Tp>::__value, _Tp*>::__type
761 __fill_n_a(_Tp* __first, _Size __n,
const _Tp& __c)
763 std::__fill_a(__first, __first + __n, __c);
764 return __first + __n;
782 template<
typename _OI,
typename _Size,
typename _Tp>
784 fill_n(_OI __first, _Size __n,
const _Tp& __value)
787 __glibcxx_function_requires(_OutputIteratorConcept<_OI, _Tp>)
789 return _OI(std::__fill_n_a(std::__niter_base(__first), __n, __value));
792 template<
bool _BoolType>
795 template<
typename _II1,
typename _II2>
797 equal(_II1 __first1, _II1 __last1, _II2 __first2)
799 for (; __first1 != __last1; ++__first1, (void)++__first2)
800 if (!(*__first1 == *__first2))
809 template<
typename _Tp>
811 equal(
const _Tp* __first1,
const _Tp* __last1,
const _Tp* __first2)
813 if (
const size_t __len = (__last1 - __first1))
814 return !__builtin_memcmp(__first1, __first2,
sizeof(_Tp) * __len);
819 template<
typename _II1,
typename _II2>
821 __equal_aux(_II1 __first1, _II1 __last1, _II2 __first2)
823 typedef typename iterator_traits<_II1>::value_type _ValueType1;
824 typedef typename iterator_traits<_II2>::value_type _ValueType2;
825 const bool __simple = ((__is_integer<_ValueType1>::__value
826 || __is_pointer<_ValueType1>::__value)
827 && __is_pointer<_II1>::__value
828 && __is_pointer<_II2>::__value
829 && __are_same<_ValueType1, _ValueType2>::__value);
834 template<
typename,
typename>
837 template<
typename _II1,
typename _II2>
839 __newlast1(_II1, _II1 __last1, _II2, _II2)
842 template<
typename _II>
844 __cnd2(_II __first, _II __last)
845 {
return __first != __last; }
849 struct __lc_rai<random_access_iterator_tag, random_access_iterator_tag>
851 template<
typename _RAI1,
typename _RAI2>
853 __newlast1(_RAI1 __first1, _RAI1 __last1,
854 _RAI2 __first2, _RAI2 __last2)
856 const typename iterator_traits<_RAI1>::difference_type
857 __diff1 = __last1 - __first1;
858 const typename iterator_traits<_RAI2>::difference_type
859 __diff2 = __last2 - __first2;
860 return __diff2 < __diff1 ? __first1 + __diff2 : __last1;
863 template<
typename _RAI>
869 template<
typename _II1,
typename _II2,
typename _Compare>
871 __lexicographical_compare_impl(_II1 __first1, _II1 __last1,
872 _II2 __first2, _II2 __last2,
875 typedef typename iterator_traits<_II1>::iterator_category _Category1;
876 typedef typename iterator_traits<_II2>::iterator_category _Category2;
877 typedef std::__lc_rai<_Category1, _Category2> __rai_type;
879 __last1 = __rai_type::__newlast1(__first1, __last1, __first2, __last2);
880 for (; __first1 != __last1 && __rai_type::__cnd2(__first2, __last2);
881 ++__first1, (void)++__first2)
883 if (__comp(__first1, __first2))
885 if (__comp(__first2, __first1))
888 return __first1 == __last1 && __first2 != __last2;
891 template<
bool _BoolType>
892 struct __lexicographical_compare
894 template<
typename _II1,
typename _II2>
895 static bool __lc(_II1, _II1, _II2, _II2);
898 template<
bool _BoolType>
899 template<
typename _II1,
typename _II2>
901 __lexicographical_compare<_BoolType>::
902 __lc(_II1 __first1, _II1 __last1, _II2 __first2, _II2 __last2)
904 return std::__lexicographical_compare_impl(__first1, __last1,
906 __gnu_cxx::__ops::__iter_less_iter());
910 struct __lexicographical_compare<true>
912 template<
typename _Tp,
typename _Up>
914 __lc(
const _Tp* __first1,
const _Tp* __last1,
915 const _Up* __first2,
const _Up* __last2)
917 const size_t __len1 = __last1 - __first1;
918 const size_t __len2 = __last2 - __first2;
919 if (
const size_t __len =
std::min(__len1, __len2))
920 if (
int __result = __builtin_memcmp(__first1, __first2, __len))
922 return __len1 < __len2;
926 template<
typename _II1,
typename _II2>
928 __lexicographical_compare_aux(_II1 __first1, _II1 __last1,
929 _II2 __first2, _II2 __last2)
931 typedef typename iterator_traits<_II1>::value_type _ValueType1;
932 typedef typename iterator_traits<_II2>::value_type _ValueType2;
933 const bool __simple =
934 (__is_byte<_ValueType1>::__value && __is_byte<_ValueType2>::__value
935 && !__gnu_cxx::__numeric_traits<_ValueType1>::__is_signed
936 && !__gnu_cxx::__numeric_traits<_ValueType2>::__is_signed
937 && __is_pointer<_II1>::__value
938 && __is_pointer<_II2>::__value);
940 return std::__lexicographical_compare<__simple>::__lc(__first1, __last1,
944 template<
typename _ForwardIterator,
typename _Tp,
typename _Compare>
946 __lower_bound(_ForwardIterator __first, _ForwardIterator __last,
947 const _Tp& __val, _Compare __comp)
949 typedef typename iterator_traits<_ForwardIterator>::difference_type
956 _DistanceType __half = __len >> 1;
957 _ForwardIterator __middle = __first;
959 if (__comp(__middle, __val))
963 __len = __len - __half - 1;
982 template<
typename _ForwardIterator,
typename _Tp>
983 inline _ForwardIterator
984 lower_bound(_ForwardIterator __first, _ForwardIterator __last,
988 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
989 __glibcxx_function_requires(_LessThanOpConcept<
990 typename iterator_traits<_ForwardIterator>::value_type, _Tp>)
991 __glibcxx_requires_partitioned_lower(__first, __last, __val);
993 return std::__lower_bound(__first, __last, __val,
994 __gnu_cxx::__ops::__iter_less_val());
999 inline _GLIBCXX_CONSTEXPR
int 1001 {
return sizeof(int) * __CHAR_BIT__ - 1 - __builtin_clz(__n); }
1003 inline _GLIBCXX_CONSTEXPR
unsigned 1005 {
return sizeof(int) * __CHAR_BIT__ - 1 - __builtin_clz(__n); }
1007 inline _GLIBCXX_CONSTEXPR
long 1009 {
return sizeof(long) * __CHAR_BIT__ - 1 - __builtin_clzl(__n); }
1011 inline _GLIBCXX_CONSTEXPR
unsigned long 1012 __lg(
unsigned long __n)
1013 {
return sizeof(long) * __CHAR_BIT__ - 1 - __builtin_clzl(__n); }
1015 inline _GLIBCXX_CONSTEXPR
long long 1017 {
return sizeof(
long long) * __CHAR_BIT__ - 1 - __builtin_clzll(__n); }
1019 inline _GLIBCXX_CONSTEXPR
unsigned long long 1020 __lg(
unsigned long long __n)
1021 {
return sizeof(
long long) * __CHAR_BIT__ - 1 - __builtin_clzll(__n); }
1023 _GLIBCXX_END_NAMESPACE_VERSION
1025 _GLIBCXX_BEGIN_NAMESPACE_ALGO
1039 template<
typename _II1,
typename _II2>
1041 equal(_II1 __first1, _II1 __last1, _II2 __first2)
1044 __glibcxx_function_requires(_InputIteratorConcept<_II1>)
1045 __glibcxx_function_requires(_InputIteratorConcept<_II2>)
1046 __glibcxx_function_requires(_EqualOpConcept<
1047 typename iterator_traits<_II1>::value_type,
1048 typename iterator_traits<_II2>::value_type>)
1049 __glibcxx_requires_valid_range(__first1, __last1);
1051 return std::__equal_aux(std::__niter_base(__first1),
1052 std::__niter_base(__last1),
1053 std::__niter_base(__first2));
1071 template<
typename _IIter1,
typename _IIter2,
typename _BinaryPredicate>
1073 equal(_IIter1 __first1, _IIter1 __last1,
1074 _IIter2 __first2, _BinaryPredicate __binary_pred)
1077 __glibcxx_function_requires(_InputIteratorConcept<_IIter1>)
1078 __glibcxx_function_requires(_InputIteratorConcept<_IIter2>)
1079 __glibcxx_requires_valid_range(__first1, __last1);
1081 for (; __first1 != __last1; ++__first1, (void)++__first2)
1082 if (!
bool(__binary_pred(*__first1, *__first2)))
1087 #if __cplusplus > 201103L 1089 #define __cpp_lib_robust_nonmodifying_seq_ops 201304 1104 template<
typename _II1,
typename _II2>
1106 equal(_II1 __first1, _II1 __last1, _II2 __first2, _II2 __last2)
1109 __glibcxx_function_requires(_InputIteratorConcept<_II1>)
1110 __glibcxx_function_requires(_InputIteratorConcept<_II2>)
1111 __glibcxx_function_requires(_EqualOpConcept<
1112 typename iterator_traits<_II1>::value_type,
1113 typename iterator_traits<_II2>::value_type>)
1114 __glibcxx_requires_valid_range(__first1, __last1);
1115 __glibcxx_requires_valid_range(__first2, __last2);
1117 using _RATag = random_access_iterator_tag;
1118 using _Cat1 =
typename iterator_traits<_II1>::iterator_category;
1119 using _Cat2 =
typename iterator_traits<_II2>::iterator_category;
1120 using _RAIters = __and_<is_same<_Cat1, _RATag>, is_same<_Cat2, _RATag>>;
1130 for (; __first1 != __last1 && __first2 != __last2;
1131 ++__first1, (void)++__first2)
1132 if (!(*__first1 == *__first2))
1134 return __first1 == __last1 && __first2 == __last2;
1153 template<
typename _IIter1,
typename _IIter2,
typename _BinaryPredicate>
1155 equal(_IIter1 __first1, _IIter1 __last1,
1156 _IIter2 __first2, _IIter2 __last2, _BinaryPredicate __binary_pred)
1159 __glibcxx_function_requires(_InputIteratorConcept<_IIter1>)
1160 __glibcxx_function_requires(_InputIteratorConcept<_IIter2>)
1161 __glibcxx_requires_valid_range(__first1, __last1);
1162 __glibcxx_requires_valid_range(__first2, __last2);
1164 using _RATag = random_access_iterator_tag;
1165 using _Cat1 =
typename iterator_traits<_IIter1>::iterator_category;
1166 using _Cat2 =
typename iterator_traits<_IIter2>::iterator_category;
1167 using _RAIters = __and_<is_same<_Cat1, _RATag>, is_same<_Cat2, _RATag>>;
1178 for (; __first1 != __last1 && __first2 != __last2;
1179 ++__first1, (void)++__first2)
1180 if (!
bool(__binary_pred(*__first1, *__first2)))
1182 return __first1 == __last1 && __first2 == __last2;
1201 template<
typename _II1,
typename _II2>
1203 lexicographical_compare(_II1 __first1, _II1 __last1,
1204 _II2 __first2, _II2 __last2)
1206 #ifdef _GLIBCXX_CONCEPT_CHECKS 1208 typedef typename iterator_traits<_II1>::value_type _ValueType1;
1209 typedef typename iterator_traits<_II2>::value_type _ValueType2;
1211 __glibcxx_function_requires(_InputIteratorConcept<_II1>)
1212 __glibcxx_function_requires(_InputIteratorConcept<_II2>)
1213 __glibcxx_function_requires(_LessThanOpConcept<_ValueType1, _ValueType2>)
1214 __glibcxx_function_requires(_LessThanOpConcept<_ValueType2, _ValueType1>)
1215 __glibcxx_requires_valid_range(__first1, __last1);
1216 __glibcxx_requires_valid_range(__first2, __last2);
1218 return std::__lexicographical_compare_aux(std::__niter_base(__first1),
1219 std::__niter_base(__last1),
1220 std::__niter_base(__first2),
1221 std::__niter_base(__last2));
1237 template<
typename _II1,
typename _II2,
typename _Compare>
1239 lexicographical_compare(_II1 __first1, _II1 __last1,
1240 _II2 __first2, _II2 __last2, _Compare __comp)
1243 __glibcxx_function_requires(_InputIteratorConcept<_II1>)
1244 __glibcxx_function_requires(_InputIteratorConcept<_II2>)
1245 __glibcxx_requires_valid_range(__first1, __last1);
1246 __glibcxx_requires_valid_range(__first2, __last2);
1248 return std::__lexicographical_compare_impl
1249 (__first1, __last1, __first2, __last2,
1250 __gnu_cxx::__ops::__iter_comp_iter(__comp));
1253 template<
typename _InputIterator1,
typename _InputIterator2,
1254 typename _BinaryPredicate>
1256 __mismatch(_InputIterator1 __first1, _InputIterator1 __last1,
1257 _InputIterator2 __first2, _BinaryPredicate __binary_pred)
1259 while (__first1 != __last1 && __binary_pred(__first1, __first2))
1280 template<
typename _InputIterator1,
typename _InputIterator2>
1282 mismatch(_InputIterator1 __first1, _InputIterator1 __last1,
1283 _InputIterator2 __first2)
1286 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
1287 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
1288 __glibcxx_function_requires(_EqualOpConcept<
1289 typename iterator_traits<_InputIterator1>::value_type,
1290 typename iterator_traits<_InputIterator2>::value_type>)
1291 __glibcxx_requires_valid_range(__first1, __last1);
1293 return _GLIBCXX_STD_A::__mismatch(__first1, __last1, __first2,
1294 __gnu_cxx::__ops::__iter_equal_to_iter());
1313 template<
typename _InputIterator1,
typename _InputIterator2,
1314 typename _BinaryPredicate>
1316 mismatch(_InputIterator1 __first1, _InputIterator1 __last1,
1317 _InputIterator2 __first2, _BinaryPredicate __binary_pred)
1320 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
1321 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
1322 __glibcxx_requires_valid_range(__first1, __last1);
1324 return _GLIBCXX_STD_A::__mismatch(__first1, __last1, __first2,
1325 __gnu_cxx::__ops::__iter_comp_iter(__binary_pred));
1328 #if __cplusplus > 201103L 1330 template<
typename _InputIterator1,
typename _InputIterator2,
1331 typename _BinaryPredicate>
1333 __mismatch(_InputIterator1 __first1, _InputIterator1 __last1,
1334 _InputIterator2 __first2, _InputIterator2 __last2,
1335 _BinaryPredicate __binary_pred)
1337 while (__first1 != __last1 && __first2 != __last2
1338 && __binary_pred(__first1, __first2))
1360 template<
typename _InputIterator1,
typename _InputIterator2>
1362 mismatch(_InputIterator1 __first1, _InputIterator1 __last1,
1363 _InputIterator2 __first2, _InputIterator2 __last2)
1366 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
1367 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
1368 __glibcxx_function_requires(_EqualOpConcept<
1369 typename iterator_traits<_InputIterator1>::value_type,
1370 typename iterator_traits<_InputIterator2>::value_type>)
1371 __glibcxx_requires_valid_range(__first1, __last1);
1372 __glibcxx_requires_valid_range(__first2, __last2);
1374 return _GLIBCXX_STD_A::__mismatch(__first1, __last1, __first2, __last2,
1375 __gnu_cxx::__ops::__iter_equal_to_iter());
1395 template<
typename _InputIterator1,
typename _InputIterator2,
1396 typename _BinaryPredicate>
1398 mismatch(_InputIterator1 __first1, _InputIterator1 __last1,
1399 _InputIterator2 __first2, _InputIterator2 __last2,
1400 _BinaryPredicate __binary_pred)
1403 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
1404 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
1405 __glibcxx_requires_valid_range(__first1, __last1);
1406 __glibcxx_requires_valid_range(__first2, __last2);
1408 return _GLIBCXX_STD_A::__mismatch(__first1, __last1, __first2, __last2,
1409 __gnu_cxx::__ops::__iter_comp_iter(__binary_pred));
1413 _GLIBCXX_END_NAMESPACE_ALGO
1419 #ifdef _GLIBCXX_PARALLEL
Provides output iterator semantics for streambufs.
void advance(_InputIterator &__i, _Distance __n)
A generalization of pointer arithmetic.
_GLIBCXX14_CONSTEXPR const _Tp & max(const _Tp &, const _Tp &)
This does what you think it does.
Parallel STL function calls corresponding to the stl_algobase.h header. The functions defined here ma...
constexpr int __lg(int __n)
This is a helper function for the sort routines and for random.tcc.
_OI copy(_II __first, _II __last, _OI __result)
Copies the range [first,last) into result.
Struct holding two objects of arbitrary type.
_GLIBCXX14_CONSTEXPR const _Tp & min(const _Tp &, const _Tp &)
This does what you think it does.
void iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b)
Swaps the contents of two iterators.
Basis for explicit traits specializations.
_OI move(_II __first, _II __last, _OI __result)
Moves the range [first,last) into result.
ISO C++ entities toplevel namespace is std.
bool equal(_IIter1 __first1, _IIter1 __last1, _IIter2 __first2, _IIter2 __last2, _BinaryPredicate __binary_pred)
Tests a range for element-wise equality.
iterator_traits< _InputIterator >::difference_type distance(_InputIterator __first, _InputIterator __last)
A generalization of pointer arithmetic.
Provides input iterator semantics for streambufs.