1 // Core algorithmic facilities -*- C++ -*-
3 // Copyright (C) 2001-2020 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // Under Section 7 of GPL version 3, you are granted additional
17 // permissions described in the GCC Runtime Library Exception, version
18 // 3.1, as published by the Free Software Foundation.
20 // You should have received a copy of the GNU General Public License and
21 // a copy of the GCC Runtime Library Exception along with this program;
22 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 // <http://www.gnu.org/licenses/>.
28 * Hewlett-Packard Company
30 * Permission to use, copy, modify, distribute and sell this software
31 * and its documentation for any purpose is hereby granted without fee,
32 * provided that the above copyright notice appear in all copies and
33 * that both that copyright notice and this permission notice appear
34 * in supporting documentation. Hewlett-Packard Company makes no
35 * representations about the suitability of this software for any
36 * purpose. It is provided "as is" without express or implied warranty.
39 * Copyright (c) 1996-1998
40 * Silicon Graphics Computer Systems, Inc.
42 * Permission to use, copy, modify, distribute and sell this software
43 * and its documentation for any purpose is hereby granted without fee,
44 * provided that the above copyright notice appear in all copies and
45 * that both that copyright notice and this permission notice appear
46 * in supporting documentation. Silicon Graphics makes no
47 * representations about the suitability of this software for any
48 * purpose. It is provided "as is" without express or implied warranty.
51 /** @file bits/stl_algobase.h
52 * This is an internal header file, included by other library headers.
53 * Do not attempt to use it directly. @headername{algorithm}
56 #ifndef _STL_ALGOBASE_H
57 #define _STL_ALGOBASE_H 1
59 #include <bits/c++config.h>
60 #include <bits/functexcept.h>
61 #include <bits/cpp_type_traits.h>
62 #include <ext/type_traits.h>
63 #include <ext/numeric_traits.h>
64 #include <bits/stl_pair.h>
65 #include <bits/stl_iterator_base_types.h>
66 #include <bits/stl_iterator_base_funcs.h>
67 #include <bits/stl_iterator.h>
68 #include <bits/concept_check.h>
69 #include <debug/debug.h>
70 #include <bits/move.h> // For std::swap
71 #include <bits/predefined_ops.h>
72 #if __cplusplus >= 201103L
73 # include <type_traits>
75 #if __cplusplus > 201703L
79 namespace std
_GLIBCXX_VISIBILITY(default)
81 _GLIBCXX_BEGIN_NAMESPACE_VERSION
84 * A constexpr wrapper for __builtin_memcmp.
85 * @param __num The number of elements of type _Tp (not bytes).
87 template<typename _Tp
>
90 __memcmp(const _Tp
* __first1
, const _Tp
* __first2
, size_t __num
)
92 #ifdef __cpp_lib_is_constant_evaluated
93 if (std::is_constant_evaluated())
95 for(; __num
> 0; ++__first1
, ++__first2
, --__num
)
96 if (*__first1
!= *__first2
)
97 return *__first1
< *__first2
? -1 : 1;
102 return __builtin_memcmp(__first1
, __first2
, sizeof(_Tp
) * __num
);
105 #if __cplusplus < 201103L
106 // See http://gcc.gnu.org/ml/libstdc++/2004-08/msg00167.html: in a
107 // nutshell, we are partially implementing the resolution of DR 187,
108 // when it's safe, i.e., the value_types are equal.
109 template<bool _BoolType
>
112 template<typename _ForwardIterator1
, typename _ForwardIterator2
>
114 iter_swap(_ForwardIterator1 __a
, _ForwardIterator2 __b
)
116 typedef typename iterator_traits
<_ForwardIterator1
>::value_type
118 _ValueType1 __tmp
= *__a
;
125 struct __iter_swap
<true>
127 template<typename _ForwardIterator1
, typename _ForwardIterator2
>
129 iter_swap(_ForwardIterator1 __a
, _ForwardIterator2 __b
)
137 * @brief Swaps the contents of two iterators.
138 * @ingroup mutating_algorithms
139 * @param __a An iterator.
140 * @param __b Another iterator.
143 * This function swaps the values pointed to by two iterators, not the
144 * iterators themselves.
146 template<typename _ForwardIterator1
, typename _ForwardIterator2
>
149 iter_swap(_ForwardIterator1 __a
, _ForwardIterator2 __b
)
151 // concept requirements
152 __glibcxx_function_requires(_Mutable_ForwardIteratorConcept
<
154 __glibcxx_function_requires(_Mutable_ForwardIteratorConcept
<
157 #if __cplusplus < 201103L
158 typedef typename iterator_traits
<_ForwardIterator1
>::value_type
160 typedef typename iterator_traits
<_ForwardIterator2
>::value_type
163 __glibcxx_function_requires(_ConvertibleConcept
<_ValueType1
,
165 __glibcxx_function_requires(_ConvertibleConcept
<_ValueType2
,
168 typedef typename iterator_traits
<_ForwardIterator1
>::reference
170 typedef typename iterator_traits
<_ForwardIterator2
>::reference
172 std::__iter_swap
<__are_same
<_ValueType1
, _ValueType2
>::__value
173 && __are_same
<_ValueType1
&, _ReferenceType1
>::__value
174 && __are_same
<_ValueType2
&, _ReferenceType2
>::__value
>::
177 // _GLIBCXX_RESOLVE_LIB_DEFECTS
178 // 187. iter_swap underspecified
184 * @brief Swap the elements of two sequences.
185 * @ingroup mutating_algorithms
186 * @param __first1 A forward iterator.
187 * @param __last1 A forward iterator.
188 * @param __first2 A forward iterator.
189 * @return An iterator equal to @p first2+(last1-first1).
191 * Swaps each element in the range @p [first1,last1) with the
192 * corresponding element in the range @p [first2,(last1-first1)).
193 * The ranges must not overlap.
195 template<typename _ForwardIterator1
, typename _ForwardIterator2
>
198 swap_ranges(_ForwardIterator1 __first1
, _ForwardIterator1 __last1
,
199 _ForwardIterator2 __first2
)
201 // concept requirements
202 __glibcxx_function_requires(_Mutable_ForwardIteratorConcept
<
204 __glibcxx_function_requires(_Mutable_ForwardIteratorConcept
<
206 __glibcxx_requires_valid_range(__first1
, __last1
);
208 for (; __first1
!= __last1
; ++__first1
, (void)++__first2
)
209 std::iter_swap(__first1
, __first2
);
214 * @brief This does what you think it does.
215 * @ingroup sorting_algorithms
216 * @param __a A thing of arbitrary type.
217 * @param __b Another thing of arbitrary type.
218 * @return The lesser of the parameters.
220 * This is the simple classic generic implementation. It will work on
221 * temporary expressions, since they are only evaluated once, unlike a
222 * preprocessor macro.
224 template<typename _Tp
>
227 min(const _Tp
& __a
, const _Tp
& __b
)
229 // concept requirements
230 __glibcxx_function_requires(_LessThanComparableConcept
<_Tp
>)
231 //return __b < __a ? __b : __a;
238 * @brief This does what you think it does.
239 * @ingroup sorting_algorithms
240 * @param __a A thing of arbitrary type.
241 * @param __b Another thing of arbitrary type.
242 * @return The greater of the parameters.
244 * This is the simple classic generic implementation. It will work on
245 * temporary expressions, since they are only evaluated once, unlike a
246 * preprocessor macro.
248 template<typename _Tp
>
251 max(const _Tp
& __a
, const _Tp
& __b
)
253 // concept requirements
254 __glibcxx_function_requires(_LessThanComparableConcept
<_Tp
>)
255 //return __a < __b ? __b : __a;
262 * @brief This does what you think it does.
263 * @ingroup sorting_algorithms
264 * @param __a A thing of arbitrary type.
265 * @param __b Another thing of arbitrary type.
266 * @param __comp A @link comparison_functors comparison functor@endlink.
267 * @return The lesser of the parameters.
269 * This will work on temporary expressions, since they are only evaluated
270 * once, unlike a preprocessor macro.
272 template<typename _Tp
, typename _Compare
>
275 min(const _Tp
& __a
, const _Tp
& __b
, _Compare __comp
)
277 //return __comp(__b, __a) ? __b : __a;
278 if (__comp(__b
, __a
))
284 * @brief This does what you think it does.
285 * @ingroup sorting_algorithms
286 * @param __a A thing of arbitrary type.
287 * @param __b Another thing of arbitrary type.
288 * @param __comp A @link comparison_functors comparison functor@endlink.
289 * @return The greater of the parameters.
291 * This will work on temporary expressions, since they are only evaluated
292 * once, unlike a preprocessor macro.
294 template<typename _Tp
, typename _Compare
>
297 max(const _Tp
& __a
, const _Tp
& __b
, _Compare __comp
)
299 //return __comp(__a, __b) ? __b : __a;
300 if (__comp(__a
, __b
))
305 // Fallback implementation of the function in bits/stl_iterator.h used to
306 // remove the __normal_iterator wrapper. See copy, fill, ...
307 template<typename _Iterator
>
310 __niter_base(_Iterator __it
)
311 _GLIBCXX_NOEXCEPT_IF(std::is_nothrow_copy_constructible
<_Iterator
>::value
)
314 // Reverse the __niter_base transformation to get a
315 // __normal_iterator back again (this assumes that __normal_iterator
316 // is only used to wrap random access iterators, like pointers).
317 template<typename _From
, typename _To
>
320 __niter_wrap(_From __from
, _To __res
)
321 { return __from
+ (__res
- std::__niter_base(__from
)); }
323 // No need to wrap, iterator already has the right type.
324 template<typename _Iterator
>
327 __niter_wrap(const _Iterator
&, _Iterator __res
)
330 // All of these auxiliary structs serve two purposes. (1) Replace
331 // calls to copy with memmove whenever possible. (Memmove, not memcpy,
332 // because the input and output ranges are permitted to overlap.)
333 // (2) If we're using random access iterators, then write the loop as
334 // a for loop with an explicit count.
336 template<bool _IsMove
, bool _IsSimple
, typename _Category
>
339 template<typename _II
, typename _OI
>
342 __copy_m(_II __first
, _II __last
, _OI __result
)
344 for (; __first
!= __last
; ++__result
, (void)++__first
)
345 *__result
= *__first
;
350 #if __cplusplus >= 201103L
351 template<typename _Category
>
352 struct __copy_move
<true, false, _Category
>
354 template<typename _II
, typename _OI
>
357 __copy_m(_II __first
, _II __last
, _OI __result
)
359 for (; __first
!= __last
; ++__result
, (void)++__first
)
360 *__result
= std::move(*__first
);
367 struct __copy_move
<false, false, random_access_iterator_tag
>
369 template<typename _II
, typename _OI
>
372 __copy_m(_II __first
, _II __last
, _OI __result
)
374 typedef typename iterator_traits
<_II
>::difference_type _Distance
;
375 for(_Distance __n
= __last
- __first
; __n
> 0; --__n
)
377 *__result
= *__first
;
385 #if __cplusplus >= 201103L
387 struct __copy_move
<true, false, random_access_iterator_tag
>
389 template<typename _II
, typename _OI
>
392 __copy_m(_II __first
, _II __last
, _OI __result
)
394 typedef typename iterator_traits
<_II
>::difference_type _Distance
;
395 for(_Distance __n
= __last
- __first
; __n
> 0; --__n
)
397 *__result
= std::move(*__first
);
406 template<bool _IsMove
>
407 struct __copy_move
<_IsMove
, true, random_access_iterator_tag
>
409 template<typename _Tp
>
412 __copy_m(const _Tp
* __first
, const _Tp
* __last
, _Tp
* __result
)
414 #if __cplusplus >= 201103L
415 using __assignable
= conditional
<_IsMove
,
416 is_move_assignable
<_Tp
>,
417 is_copy_assignable
<_Tp
>>;
418 // trivial types can have deleted assignment
419 static_assert( __assignable::type::value
, "type is not assignable" );
421 const ptrdiff_t _Num
= __last
- __first
;
423 __builtin_memmove(__result
, __first
, sizeof(_Tp
) * _Num
);
424 return __result
+ _Num
;
428 // Helpers for streambuf iterators (either istream or ostream).
429 // NB: avoid including <iosfwd>, relatively large.
430 template<typename _CharT
>
433 template<typename _CharT
, typename _Traits
>
434 class istreambuf_iterator
;
436 template<typename _CharT
, typename _Traits
>
437 class ostreambuf_iterator
;
439 template<bool _IsMove
, typename _CharT
>
440 typename
__gnu_cxx::__enable_if
<__is_char
<_CharT
>::__value
,
441 ostreambuf_iterator
<_CharT
, char_traits
<_CharT
> > >::__type
442 __copy_move_a2(_CharT
*, _CharT
*,
443 ostreambuf_iterator
<_CharT
, char_traits
<_CharT
> >);
445 template<bool _IsMove
, typename _CharT
>
446 typename
__gnu_cxx::__enable_if
<__is_char
<_CharT
>::__value
,
447 ostreambuf_iterator
<_CharT
, char_traits
<_CharT
> > >::__type
448 __copy_move_a2(const _CharT
*, const _CharT
*,
449 ostreambuf_iterator
<_CharT
, char_traits
<_CharT
> >);
451 template<bool _IsMove
, typename _CharT
>
452 typename
__gnu_cxx::__enable_if
<__is_char
<_CharT
>::__value
,
454 __copy_move_a2(istreambuf_iterator
<_CharT
, char_traits
<_CharT
> >,
455 istreambuf_iterator
<_CharT
, char_traits
<_CharT
> >, _CharT
*);
457 template<bool _IsMove
, typename _II
, typename _OI
>
460 __copy_move_a2(_II __first
, _II __last
, _OI __result
)
462 typedef typename iterator_traits
<_II
>::iterator_category _Category
;
463 #ifdef __cpp_lib_is_constant_evaluated
464 if (std::is_constant_evaluated())
465 return std::__copy_move
<_IsMove
, false, _Category
>::
466 __copy_m(__first
, __last
, __result
);
468 typedef typename iterator_traits
<_II
>::value_type _ValueTypeI
;
469 typedef typename iterator_traits
<_OI
>::value_type _ValueTypeO
;
470 const bool __simple
= (__is_trivially_copyable(_ValueTypeI
)
471 && __is_pointer
<_II
>::__value
472 && __is_pointer
<_OI
>::__value
473 && __are_same
<_ValueTypeI
, _ValueTypeO
>::__value
);
474 return std::__copy_move
<_IsMove
, __simple
,
475 _Category
>::__copy_m(__first
, __last
, __result
);
478 _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
480 template<typename _Tp
, typename _Ref
, typename _Ptr
>
481 struct _Deque_iterator
;
483 _GLIBCXX_END_NAMESPACE_CONTAINER
485 template<bool _IsMove
,
486 typename _Tp
, typename _Ref
, typename _Ptr
, typename _OI
>
488 __copy_move_a1(_GLIBCXX_STD_C::_Deque_iterator
<_Tp
, _Ref
, _Ptr
>,
489 _GLIBCXX_STD_C::_Deque_iterator
<_Tp
, _Ref
, _Ptr
>,
492 template<bool _IsMove
,
493 typename _ITp
, typename _IRef
, typename _IPtr
, typename _OTp
>
494 _GLIBCXX_STD_C::_Deque_iterator
<_OTp
, _OTp
&, _OTp
*>
495 __copy_move_a1(_GLIBCXX_STD_C::_Deque_iterator
<_ITp
, _IRef
, _IPtr
>,
496 _GLIBCXX_STD_C::_Deque_iterator
<_ITp
, _IRef
, _IPtr
>,
497 _GLIBCXX_STD_C::_Deque_iterator
<_OTp
, _OTp
&, _OTp
*>);
499 template<bool _IsMove
, typename _II
, typename _Tp
>
500 typename
__gnu_cxx::__enable_if
<
501 __is_random_access_iter
<_II
>::__value
,
502 _GLIBCXX_STD_C::_Deque_iterator
<_Tp
, _Tp
&, _Tp
*> >::__type
503 __copy_move_a1(_II
, _II
, _GLIBCXX_STD_C::_Deque_iterator
<_Tp
, _Tp
&, _Tp
*>);
505 template<bool _IsMove
, typename _II
, typename _OI
>
508 __copy_move_a1(_II __first
, _II __last
, _OI __result
)
509 { return std::__copy_move_a2
<_IsMove
>(__first
, __last
, __result
); }
511 template<bool _IsMove
, typename _II
, typename _OI
>
514 __copy_move_a(_II __first
, _II __last
, _OI __result
)
516 return std::__niter_wrap(__result
,
517 std::__copy_move_a1
<_IsMove
>(std::__niter_base(__first
),
518 std::__niter_base(__last
),
519 std::__niter_base(__result
)));
522 template<bool _IsMove
,
523 typename _Ite
, typename _Seq
, typename _Cat
, typename _OI
>
525 __copy_move_a(const ::__gnu_debug::_Safe_iterator
<_Ite
, _Seq
, _Cat
>&,
526 const ::__gnu_debug::_Safe_iterator
<_Ite
, _Seq
, _Cat
>&,
529 template<bool _IsMove
,
530 typename _II
, typename _Ite
, typename _Seq
, typename _Cat
>
531 __gnu_debug::_Safe_iterator
<_Ite
, _Seq
, _Cat
>
532 __copy_move_a(_II
, _II
,
533 const ::__gnu_debug::_Safe_iterator
<_Ite
, _Seq
, _Cat
>&);
535 template<bool _IsMove
,
536 typename _IIte
, typename _ISeq
, typename _ICat
,
537 typename _OIte
, typename _OSeq
, typename _OCat
>
538 ::__gnu_debug::_Safe_iterator
<_OIte
, _OSeq
, _OCat
>
539 __copy_move_a(const ::__gnu_debug::_Safe_iterator
<_IIte
, _ISeq
, _ICat
>&,
540 const ::__gnu_debug::_Safe_iterator
<_IIte
, _ISeq
, _ICat
>&,
541 const ::__gnu_debug::_Safe_iterator
<_OIte
, _OSeq
, _OCat
>&);
544 * @brief Copies the range [first,last) into result.
545 * @ingroup mutating_algorithms
546 * @param __first An input iterator.
547 * @param __last An input iterator.
548 * @param __result An output iterator.
549 * @return result + (first - last)
551 * This inline function will boil down to a call to @c memmove whenever
552 * possible. Failing that, if random access iterators are passed, then the
553 * loop count will be known (and therefore a candidate for compiler
554 * optimizations such as unrolling). Result may not be contained within
555 * [first,last); the copy_backward function should be used instead.
557 * Note that the end of the output range is permitted to be contained
558 * within [first,last).
560 template<typename _II
, typename _OI
>
563 copy(_II __first
, _II __last
, _OI __result
)
565 // concept requirements
566 __glibcxx_function_requires(_InputIteratorConcept
<_II
>)
567 __glibcxx_function_requires(_OutputIteratorConcept
<_OI
,
568 typename iterator_traits
<_II
>::value_type
>)
569 __glibcxx_requires_can_increment_range(__first
, __last
, __result
);
571 return std::__copy_move_a
<__is_move_iterator
<_II
>::__value
>
572 (std::__miter_base(__first
), std::__miter_base(__last
), __result
);
575 #if __cplusplus >= 201103L
577 * @brief Moves the range [first,last) into result.
578 * @ingroup mutating_algorithms
579 * @param __first An input iterator.
580 * @param __last An input iterator.
581 * @param __result An output iterator.
582 * @return result + (first - last)
584 * This inline function will boil down to a call to @c memmove whenever
585 * possible. Failing that, if random access iterators are passed, then the
586 * loop count will be known (and therefore a candidate for compiler
587 * optimizations such as unrolling). Result may not be contained within
588 * [first,last); the move_backward function should be used instead.
590 * Note that the end of the output range is permitted to be contained
591 * within [first,last).
593 template<typename _II
, typename _OI
>
596 move(_II __first
, _II __last
, _OI __result
)
598 // concept requirements
599 __glibcxx_function_requires(_InputIteratorConcept
<_II
>)
600 __glibcxx_function_requires(_OutputIteratorConcept
<_OI
,
601 typename iterator_traits
<_II
>::value_type
>)
602 __glibcxx_requires_can_increment_range(__first
, __last
, __result
);
604 return std::__copy_move_a
<true>(std::__miter_base(__first
),
605 std::__miter_base(__last
), __result
);
608 #define _GLIBCXX_MOVE3(_Tp, _Up, _Vp) std::move(_Tp, _Up, _Vp)
610 #define _GLIBCXX_MOVE3(_Tp, _Up, _Vp) std::copy(_Tp, _Up, _Vp)
613 template<bool _IsMove
, bool _IsSimple
, typename _Category
>
614 struct __copy_move_backward
616 template<typename _BI1
, typename _BI2
>
619 __copy_move_b(_BI1 __first
, _BI1 __last
, _BI2 __result
)
621 while (__first
!= __last
)
622 *--__result
= *--__last
;
627 #if __cplusplus >= 201103L
628 template<typename _Category
>
629 struct __copy_move_backward
<true, false, _Category
>
631 template<typename _BI1
, typename _BI2
>
634 __copy_move_b(_BI1 __first
, _BI1 __last
, _BI2 __result
)
636 while (__first
!= __last
)
637 *--__result
= std::move(*--__last
);
644 struct __copy_move_backward
<false, false, random_access_iterator_tag
>
646 template<typename _BI1
, typename _BI2
>
649 __copy_move_b(_BI1 __first
, _BI1 __last
, _BI2 __result
)
651 typename iterator_traits
<_BI1
>::difference_type
652 __n
= __last
- __first
;
653 for (; __n
> 0; --__n
)
654 *--__result
= *--__last
;
659 #if __cplusplus >= 201103L
661 struct __copy_move_backward
<true, false, random_access_iterator_tag
>
663 template<typename _BI1
, typename _BI2
>
666 __copy_move_b(_BI1 __first
, _BI1 __last
, _BI2 __result
)
668 typename iterator_traits
<_BI1
>::difference_type
669 __n
= __last
- __first
;
670 for (; __n
> 0; --__n
)
671 *--__result
= std::move(*--__last
);
677 template<bool _IsMove
>
678 struct __copy_move_backward
<_IsMove
, true, random_access_iterator_tag
>
680 template<typename _Tp
>
683 __copy_move_b(const _Tp
* __first
, const _Tp
* __last
, _Tp
* __result
)
685 #if __cplusplus >= 201103L
686 using __assignable
= conditional
<_IsMove
,
687 is_move_assignable
<_Tp
>,
688 is_copy_assignable
<_Tp
>>;
689 // trivial types can have deleted assignment
690 static_assert( __assignable::type::value
, "type is not assignable" );
692 const ptrdiff_t _Num
= __last
- __first
;
694 __builtin_memmove(__result
- _Num
, __first
, sizeof(_Tp
) * _Num
);
695 return __result
- _Num
;
699 template<bool _IsMove
, typename _BI1
, typename _BI2
>
702 __copy_move_backward_a2(_BI1 __first
, _BI1 __last
, _BI2 __result
)
704 typedef typename iterator_traits
<_BI1
>::iterator_category _Category
;
705 #ifdef __cpp_lib_is_constant_evaluated
706 if (std::is_constant_evaluated())
707 return std::__copy_move_backward
<_IsMove
, false, _Category
>::
708 __copy_move_b(__first
, __last
, __result
);
710 typedef typename iterator_traits
<_BI1
>::value_type _ValueType1
;
711 typedef typename iterator_traits
<_BI2
>::value_type _ValueType2
;
712 const bool __simple
= (__is_trivially_copyable(_ValueType1
)
713 && __is_pointer
<_BI1
>::__value
714 && __is_pointer
<_BI2
>::__value
715 && __are_same
<_ValueType1
, _ValueType2
>::__value
);
717 return std::__copy_move_backward
<_IsMove
, __simple
,
718 _Category
>::__copy_move_b(__first
,
723 template<bool _IsMove
, typename _BI1
, typename _BI2
>
726 __copy_move_backward_a1(_BI1 __first
, _BI1 __last
, _BI2 __result
)
727 { return std::__copy_move_backward_a2
<_IsMove
>(__first
, __last
, __result
); }
729 template<bool _IsMove
,
730 typename _Tp
, typename _Ref
, typename _Ptr
, typename _OI
>
732 __copy_move_backward_a1(_GLIBCXX_STD_C::_Deque_iterator
<_Tp
, _Ref
, _Ptr
>,
733 _GLIBCXX_STD_C::_Deque_iterator
<_Tp
, _Ref
, _Ptr
>,
736 template<bool _IsMove
,
737 typename _ITp
, typename _IRef
, typename _IPtr
, typename _OTp
>
738 _GLIBCXX_STD_C::_Deque_iterator
<_OTp
, _OTp
&, _OTp
*>
739 __copy_move_backward_a1(
740 _GLIBCXX_STD_C::_Deque_iterator
<_ITp
, _IRef
, _IPtr
>,
741 _GLIBCXX_STD_C::_Deque_iterator
<_ITp
, _IRef
, _IPtr
>,
742 _GLIBCXX_STD_C::_Deque_iterator
<_OTp
, _OTp
&, _OTp
*>);
744 template<bool _IsMove
, typename _II
, typename _Tp
>
745 typename
__gnu_cxx::__enable_if
<
746 __is_random_access_iter
<_II
>::__value
,
747 _GLIBCXX_STD_C::_Deque_iterator
<_Tp
, _Tp
&, _Tp
*> >::__type
748 __copy_move_backward_a1(_II
, _II
,
749 _GLIBCXX_STD_C::_Deque_iterator
<_Tp
, _Tp
&, _Tp
*>);
751 template<bool _IsMove
, typename _II
, typename _OI
>
754 __copy_move_backward_a(_II __first
, _II __last
, _OI __result
)
756 return std::__niter_wrap(__result
,
757 std::__copy_move_backward_a1
<_IsMove
>
758 (std::__niter_base(__first
), std::__niter_base(__last
),
759 std::__niter_base(__result
)));
762 template<bool _IsMove
,
763 typename _Ite
, typename _Seq
, typename _Cat
, typename _OI
>
765 __copy_move_backward_a(
766 const ::__gnu_debug::_Safe_iterator
<_Ite
, _Seq
, _Cat
>&,
767 const ::__gnu_debug::_Safe_iterator
<_Ite
, _Seq
, _Cat
>&,
770 template<bool _IsMove
,
771 typename _II
, typename _Ite
, typename _Seq
, typename _Cat
>
772 __gnu_debug::_Safe_iterator
<_Ite
, _Seq
, _Cat
>
773 __copy_move_backward_a(_II
, _II
,
774 const ::__gnu_debug::_Safe_iterator
<_Ite
, _Seq
, _Cat
>&);
776 template<bool _IsMove
,
777 typename _IIte
, typename _ISeq
, typename _ICat
,
778 typename _OIte
, typename _OSeq
, typename _OCat
>
779 ::__gnu_debug::_Safe_iterator
<_OIte
, _OSeq
, _OCat
>
780 __copy_move_backward_a(
781 const ::__gnu_debug::_Safe_iterator
<_IIte
, _ISeq
, _ICat
>&,
782 const ::__gnu_debug::_Safe_iterator
<_IIte
, _ISeq
, _ICat
>&,
783 const ::__gnu_debug::_Safe_iterator
<_OIte
, _OSeq
, _OCat
>&);
786 * @brief Copies the range [first,last) into result.
787 * @ingroup mutating_algorithms
788 * @param __first A bidirectional iterator.
789 * @param __last A bidirectional iterator.
790 * @param __result A bidirectional iterator.
791 * @return result - (first - last)
793 * The function has the same effect as copy, but starts at the end of the
794 * range and works its way to the start, returning the start of the result.
795 * This inline function will boil down to a call to @c memmove whenever
796 * possible. Failing that, if random access iterators are passed, then the
797 * loop count will be known (and therefore a candidate for compiler
798 * optimizations such as unrolling).
800 * Result may not be in the range (first,last]. Use copy instead. Note
801 * that the start of the output range may overlap [first,last).
803 template<typename _BI1
, typename _BI2
>
806 copy_backward(_BI1 __first
, _BI1 __last
, _BI2 __result
)
808 // concept requirements
809 __glibcxx_function_requires(_BidirectionalIteratorConcept
<_BI1
>)
810 __glibcxx_function_requires(_Mutable_BidirectionalIteratorConcept
<_BI2
>)
811 __glibcxx_function_requires(_ConvertibleConcept
<
812 typename iterator_traits
<_BI1
>::value_type
,
813 typename iterator_traits
<_BI2
>::value_type
>)
814 __glibcxx_requires_can_decrement_range(__first
, __last
, __result
);
816 return std::__copy_move_backward_a
<__is_move_iterator
<_BI1
>::__value
>
817 (std::__miter_base(__first
), std::__miter_base(__last
), __result
);
820 #if __cplusplus >= 201103L
822 * @brief Moves the range [first,last) into result.
823 * @ingroup mutating_algorithms
824 * @param __first A bidirectional iterator.
825 * @param __last A bidirectional iterator.
826 * @param __result A bidirectional iterator.
827 * @return result - (first - last)
829 * The function has the same effect as move, but starts at the end of the
830 * range and works its way to the start, returning the start of the result.
831 * This inline function will boil down to a call to @c memmove whenever
832 * possible. Failing that, if random access iterators are passed, then the
833 * loop count will be known (and therefore a candidate for compiler
834 * optimizations such as unrolling).
836 * Result may not be in the range (first,last]. Use move instead. Note
837 * that the start of the output range may overlap [first,last).
839 template<typename _BI1
, typename _BI2
>
842 move_backward(_BI1 __first
, _BI1 __last
, _BI2 __result
)
844 // concept requirements
845 __glibcxx_function_requires(_BidirectionalIteratorConcept
<_BI1
>)
846 __glibcxx_function_requires(_Mutable_BidirectionalIteratorConcept
<_BI2
>)
847 __glibcxx_function_requires(_ConvertibleConcept
<
848 typename iterator_traits
<_BI1
>::value_type
,
849 typename iterator_traits
<_BI2
>::value_type
>)
850 __glibcxx_requires_can_decrement_range(__first
, __last
, __result
);
852 return std::__copy_move_backward_a
<true>(std::__miter_base(__first
),
853 std::__miter_base(__last
),
857 #define _GLIBCXX_MOVE_BACKWARD3(_Tp, _Up, _Vp) std::move_backward(_Tp, _Up, _Vp)
859 #define _GLIBCXX_MOVE_BACKWARD3(_Tp, _Up, _Vp) std::copy_backward(_Tp, _Up, _Vp)
862 template<typename _ForwardIterator
, typename _Tp
>
865 __gnu_cxx::__enable_if
<!__is_scalar
<_Tp
>::__value
, void>::__type
866 __fill_a1(_ForwardIterator __first
, _ForwardIterator __last
,
869 for (; __first
!= __last
; ++__first
)
873 template<typename _ForwardIterator
, typename _Tp
>
876 __gnu_cxx::__enable_if
<__is_scalar
<_Tp
>::__value
, void>::__type
877 __fill_a1(_ForwardIterator __first
, _ForwardIterator __last
,
880 const _Tp __tmp
= __value
;
881 for (; __first
!= __last
; ++__first
)
885 // Specialization: for char types we can use memset.
886 template<typename _Tp
>
888 __gnu_cxx::__enable_if
<__is_byte
<_Tp
>::__value
, void>::__type
889 __fill_a1(_Tp
* __first
, _Tp
* __last
, const _Tp
& __c
)
891 const _Tp __tmp
= __c
;
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
>&,
923 * @brief Fills the range [first,last) with copies of value.
924 * @ingroup mutating_algorithms
925 * @param __first A forward iterator.
926 * @param __last A forward iterator.
927 * @param __value A reference-to-const of arbitrary type.
930 * This function fills a range with copies of the same value. For char
931 * types filling contiguous areas of memory, this becomes an inline call
932 * to @c memset or @c wmemset.
934 template<typename _ForwardIterator
, typename _Tp
>
937 fill(_ForwardIterator __first
, _ForwardIterator __last
, const _Tp
& __value
)
939 // concept requirements
940 __glibcxx_function_requires(_Mutable_ForwardIteratorConcept
<
942 __glibcxx_requires_valid_range(__first
, __last
);
944 std::__fill_a(__first
, __last
, __value
);
947 // Used by fill_n, generate_n, etc. to convert _Size to an integral type:
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)
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
,
1022 ::__gnu_debug::_Safe_iterator
<_Ite
, _Seq
, _Cat
>
1023 __fill_n_a(const ::__gnu_debug::_Safe_iterator
<_Ite
, _Seq
, _Cat
>& __first
,
1024 _Size __n
, const _Tp
& __value
,
1025 std::input_iterator_tag
);
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
,
1031 std::output_iterator_tag
)
1033 #if __cplusplus >= 201103L
1034 static_assert(is_integral
<_Size
>{}, "fill_n must pass integral size");
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
,
1043 std::input_iterator_tag
)
1045 #if __cplusplus >= 201103L
1046 static_assert(is_integral
<_Size
>{}, "fill_n must pass integral size");
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
,
1055 std::random_access_iterator_tag
)
1057 #if __cplusplus >= 201103L
1058 static_assert(is_integral
<_Size
>{}, "fill_n must pass integral size");
1063 __glibcxx_requires_can_increment(__first
, __n
);
1065 std::__fill_a(__first
, __first
+ __n
, __value
);
1066 return __first
+ __n
;
1070 * @brief Fills the range [first,first+n) with copies of value.
1071 * @ingroup mutating_algorithms
1072 * @param __first An output iterator.
1073 * @param __n The count of copies to perform.
1074 * @param __value A reference-to-const of arbitrary type.
1075 * @return The iterator at first+n.
1077 * This function fills a range with copies of the same value. For char
1078 * types filling contiguous areas of memory, this becomes an inline call
1079 * to @c memset or @c wmemset.
1081 * If @p __n is negative, the function does nothing.
1083 // _GLIBCXX_RESOLVE_LIB_DEFECTS
1084 // DR 865. More algorithms that throw away information
1085 // DR 426. search_n(), fill_n(), and generate_n() with negative n
1086 template<typename _OI
, typename _Size
, typename _Tp
>
1087 _GLIBCXX20_CONSTEXPR
1089 fill_n(_OI __first
, _Size __n
, const _Tp
& __value
)
1091 // concept requirements
1092 __glibcxx_function_requires(_OutputIteratorConcept
<_OI
, _Tp
>)
1094 return std::__fill_n_a(__first
, std::__size_to_integer(__n
), __value
,
1095 std::__iterator_category(__first
));
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
)
1152 typedef typename iterator_traits
<_II1
>::value_type _ValueType1
;
1153 typedef typename iterator_traits
<_II2
>::value_type _ValueType2
;
1154 const bool __simple
= ((__is_integer
<_ValueType1
>::__value
1155 || __is_pointer
<_ValueType1
>::__value
)
1156 && __is_pointer
<_II1
>::__value
1157 && __is_pointer
<_II2
>::__value
1158 && __are_same
<_ValueType1
, _ValueType2
>::__value
);
1160 return std::__equal
<__simple
>::equal(__first1
, __last1
, __first2
);
1163 template<typename _II1
, typename _II2
>
1164 _GLIBCXX20_CONSTEXPR
1166 __equal_aux(_II1 __first1
, _II1 __last1
, _II2 __first2
)
1168 return std::__equal_aux1(std::__niter_base(__first1
),
1169 std::__niter_base(__last1
),
1170 std::__niter_base(__first2
));
1173 template<typename _II1
, typename _Seq1
, typename _Cat1
, typename _II2
>
1175 __equal_aux(const ::__gnu_debug::_Safe_iterator
<_II1
, _Seq1
, _Cat1
>&,
1176 const ::__gnu_debug::_Safe_iterator
<_II1
, _Seq1
, _Cat1
>&,
1179 template<typename _II1
, typename _II2
, typename _Seq2
, typename _Cat2
>
1181 __equal_aux(_II1
, _II1
,
1182 const ::__gnu_debug::_Safe_iterator
<_II2
, _Seq2
, _Cat2
>&);
1184 template<typename _II1
, typename _Seq1
, typename _Cat1
,
1185 typename _II2
, typename _Seq2
, typename _Cat2
>
1187 __equal_aux(const ::__gnu_debug::_Safe_iterator
<_II1
, _Seq1
, _Cat1
>&,
1188 const ::__gnu_debug::_Safe_iterator
<_II1
, _Seq1
, _Cat1
>&,
1189 const ::__gnu_debug::_Safe_iterator
<_II2
, _Seq2
, _Cat2
>&);
1191 template<typename
, typename
>
1194 template<typename _II1
, typename _II2
>
1195 _GLIBCXX20_CONSTEXPR
1197 __newlast1(_II1
, _II1 __last1
, _II2
, _II2
)
1200 template<typename _II
>
1201 _GLIBCXX20_CONSTEXPR
1203 __cnd2(_II __first
, _II __last
)
1204 { return __first
!= __last
; }
1208 struct __lc_rai
<random_access_iterator_tag
, random_access_iterator_tag
>
1210 template<typename _RAI1
, typename _RAI2
>
1211 _GLIBCXX20_CONSTEXPR
1213 __newlast1(_RAI1 __first1
, _RAI1 __last1
,
1214 _RAI2 __first2
, _RAI2 __last2
)
1216 const typename iterator_traits
<_RAI1
>::difference_type
1217 __diff1
= __last1
- __first1
;
1218 const typename iterator_traits
<_RAI2
>::difference_type
1219 __diff2
= __last2
- __first2
;
1220 return __diff2
< __diff1
? __first1
+ __diff2
: __last1
;
1223 template<typename _RAI
>
1224 static _GLIBCXX20_CONSTEXPR
bool
1229 template<typename _II1
, typename _II2
, typename _Compare
>
1230 _GLIBCXX20_CONSTEXPR
1232 __lexicographical_compare_impl(_II1 __first1
, _II1 __last1
,
1233 _II2 __first2
, _II2 __last2
,
1236 typedef typename iterator_traits
<_II1
>::iterator_category _Category1
;
1237 typedef typename iterator_traits
<_II2
>::iterator_category _Category2
;
1238 typedef std::__lc_rai
<_Category1
, _Category2
> __rai_type
;
1240 __last1
= __rai_type::__newlast1(__first1
, __last1
, __first2
, __last2
);
1241 for (; __first1
!= __last1
&& __rai_type::__cnd2(__first2
, __last2
);
1242 ++__first1
, (void)++__first2
)
1244 if (__comp(__first1
, __first2
))
1246 if (__comp(__first2
, __first1
))
1249 return __first1
== __last1
&& __first2
!= __last2
;
1252 template<bool _BoolType
>
1253 struct __lexicographical_compare
1255 template<typename _II1
, typename _II2
>
1256 _GLIBCXX20_CONSTEXPR
1257 static bool __lc(_II1
, _II1
, _II2
, _II2
);
1260 template<bool _BoolType
>
1261 template<typename _II1
, typename _II2
>
1262 _GLIBCXX20_CONSTEXPR
1264 __lexicographical_compare
<_BoolType
>::
1265 __lc(_II1 __first1
, _II1 __last1
, _II2 __first2
, _II2 __last2
)
1267 return std::__lexicographical_compare_impl(__first1
, __last1
,
1269 __gnu_cxx::__ops::__iter_less_iter());
1273 struct __lexicographical_compare
<true>
1275 template<typename _Tp
, typename _Up
>
1276 _GLIBCXX20_CONSTEXPR
1278 __lc(const _Tp
* __first1
, const _Tp
* __last1
,
1279 const _Up
* __first2
, const _Up
* __last2
)
1281 const size_t __len1
= __last1
- __first1
;
1282 const size_t __len2
= __last2
- __first2
;
1283 if (const size_t __len
= std::min(__len1
, __len2
))
1284 if (int __result
= std::__memcmp(__first1
, __first2
, __len
))
1285 return __result
< 0;
1286 return __len1
< __len2
;
1290 template<typename _II1
, typename _II2
>
1291 _GLIBCXX20_CONSTEXPR
1293 __lexicographical_compare_aux(_II1 __first1
, _II1 __last1
,
1294 _II2 __first2
, _II2 __last2
)
1296 typedef typename iterator_traits
<_II1
>::value_type _ValueType1
;
1297 typedef typename iterator_traits
<_II2
>::value_type _ValueType2
;
1298 const bool __simple
=
1299 (__is_byte
<_ValueType1
>::__value
&& __is_byte
<_ValueType2
>::__value
1300 && !__gnu_cxx::__numeric_traits
<_ValueType1
>::__is_signed
1301 && !__gnu_cxx::__numeric_traits
<_ValueType2
>::__is_signed
1302 && __is_pointer
<_II1
>::__value
1303 && __is_pointer
<_II2
>::__value
);
1305 return std::__lexicographical_compare
<__simple
>::__lc(__first1
, __last1
,
1309 template<typename _ForwardIterator
, typename _Tp
, typename _Compare
>
1310 _GLIBCXX20_CONSTEXPR
1312 __lower_bound(_ForwardIterator __first
, _ForwardIterator __last
,
1313 const _Tp
& __val
, _Compare __comp
)
1315 typedef typename iterator_traits
<_ForwardIterator
>::difference_type
1318 _DistanceType __len
= std::distance(__first
, __last
);
1322 _DistanceType __half
= __len
>> 1;
1323 _ForwardIterator __middle
= __first
;
1324 std::advance(__middle
, __half
);
1325 if (__comp(__middle
, __val
))
1329 __len
= __len
- __half
- 1;
1338 * @brief Finds the first position in which @a val could be inserted
1339 * without changing the ordering.
1340 * @param __first An iterator.
1341 * @param __last Another iterator.
1342 * @param __val The search term.
1343 * @return An iterator pointing to the first element <em>not less
1344 * than</em> @a val, or end() if every element is less than
1346 * @ingroup binary_search_algorithms
1348 template<typename _ForwardIterator
, typename _Tp
>
1349 _GLIBCXX20_CONSTEXPR
1350 inline _ForwardIterator
1351 lower_bound(_ForwardIterator __first
, _ForwardIterator __last
,
1354 // concept requirements
1355 __glibcxx_function_requires(_ForwardIteratorConcept
<_ForwardIterator
>)
1356 __glibcxx_function_requires(_LessThanOpConcept
<
1357 typename iterator_traits
<_ForwardIterator
>::value_type
, _Tp
>)
1358 __glibcxx_requires_partitioned_lower(__first
, __last
, __val
);
1360 return std::__lower_bound(__first
, __last
, __val
,
1361 __gnu_cxx::__ops::__iter_less_val());
1364 /// This is a helper function for the sort routines and for random.tcc.
1365 // Precondition: __n > 0.
1366 inline _GLIBCXX_CONSTEXPR
int
1368 { return (int)sizeof(int) * __CHAR_BIT__
- 1 - __builtin_clz(__n
); }
1370 inline _GLIBCXX_CONSTEXPR
unsigned
1372 { return (int)sizeof(int) * __CHAR_BIT__
- 1 - __builtin_clz(__n
); }
1374 inline _GLIBCXX_CONSTEXPR
long
1376 { return (int)sizeof(long) * __CHAR_BIT__
- 1 - __builtin_clzl(__n
); }
1378 inline _GLIBCXX_CONSTEXPR
unsigned long
1379 __lg(unsigned long __n
)
1380 { return (int)sizeof(long) * __CHAR_BIT__
- 1 - __builtin_clzl(__n
); }
1382 inline _GLIBCXX_CONSTEXPR
long long
1384 { return (int)sizeof(long long) * __CHAR_BIT__
- 1 - __builtin_clzll(__n
); }
1386 inline _GLIBCXX_CONSTEXPR
unsigned long long
1387 __lg(unsigned long long __n
)
1388 { return (int)sizeof(long long) * __CHAR_BIT__
- 1 - __builtin_clzll(__n
); }
1390 _GLIBCXX_BEGIN_NAMESPACE_ALGO
1393 * @brief Tests a range for element-wise equality.
1394 * @ingroup non_mutating_algorithms
1395 * @param __first1 An input iterator.
1396 * @param __last1 An input iterator.
1397 * @param __first2 An input iterator.
1398 * @return A boolean true or false.
1400 * This compares the elements of two ranges using @c == and returns true or
1401 * false depending on whether all of the corresponding elements of the
1404 template<typename _II1
, typename _II2
>
1405 _GLIBCXX20_CONSTEXPR
1407 equal(_II1 __first1
, _II1 __last1
, _II2 __first2
)
1409 // concept requirements
1410 __glibcxx_function_requires(_InputIteratorConcept
<_II1
>)
1411 __glibcxx_function_requires(_InputIteratorConcept
<_II2
>)
1412 __glibcxx_function_requires(_EqualOpConcept
<
1413 typename iterator_traits
<_II1
>::value_type
,
1414 typename iterator_traits
<_II2
>::value_type
>)
1415 __glibcxx_requires_can_increment_range(__first1
, __last1
, __first2
);
1417 return std::__equal_aux(__first1
, __last1
, __first2
);
1421 * @brief Tests a range for element-wise equality.
1422 * @ingroup non_mutating_algorithms
1423 * @param __first1 An input iterator.
1424 * @param __last1 An input iterator.
1425 * @param __first2 An input iterator.
1426 * @param __binary_pred A binary predicate @link functors
1428 * @return A boolean true or false.
1430 * This compares the elements of two ranges using the binary_pred
1431 * parameter, and returns true or
1432 * false depending on whether all of the corresponding elements of the
1435 template<typename _IIter1
, typename _IIter2
, typename _BinaryPredicate
>
1436 _GLIBCXX20_CONSTEXPR
1438 equal(_IIter1 __first1
, _IIter1 __last1
,
1439 _IIter2 __first2
, _BinaryPredicate __binary_pred
)
1441 // concept requirements
1442 __glibcxx_function_requires(_InputIteratorConcept
<_IIter1
>)
1443 __glibcxx_function_requires(_InputIteratorConcept
<_IIter2
>)
1444 __glibcxx_requires_valid_range(__first1
, __last1
);
1446 for (; __first1
!= __last1
; ++__first1
, (void)++__first2
)
1447 if (!bool(__binary_pred(*__first1
, *__first2
)))
1452 #if __cplusplus >= 201103L
1453 // 4-iterator version of std::equal<It1, It2> for use in C++11.
1454 template<typename _II1
, typename _II2
>
1455 _GLIBCXX20_CONSTEXPR
1457 __equal4(_II1 __first1
, _II1 __last1
, _II2 __first2
, _II2 __last2
)
1459 using _RATag
= random_access_iterator_tag
;
1460 using _Cat1
= typename iterator_traits
<_II1
>::iterator_category
;
1461 using _Cat2
= typename iterator_traits
<_II2
>::iterator_category
;
1462 using _RAIters
= __and_
<is_same
<_Cat1
, _RATag
>, is_same
<_Cat2
, _RATag
>>;
1465 auto __d1
= std::distance(__first1
, __last1
);
1466 auto __d2
= std::distance(__first2
, __last2
);
1469 return _GLIBCXX_STD_A::equal(__first1
, __last1
, __first2
);
1472 for (; __first1
!= __last1
&& __first2
!= __last2
;
1473 ++__first1
, (void)++__first2
)
1474 if (!(*__first1
== *__first2
))
1476 return __first1
== __last1
&& __first2
== __last2
;
1479 // 4-iterator version of std::equal<It1, It2, BinaryPred> for use in C++11.
1480 template<typename _II1
, typename _II2
, typename _BinaryPredicate
>
1481 _GLIBCXX20_CONSTEXPR
1483 __equal4(_II1 __first1
, _II1 __last1
, _II2 __first2
, _II2 __last2
,
1484 _BinaryPredicate __binary_pred
)
1486 using _RATag
= random_access_iterator_tag
;
1487 using _Cat1
= typename iterator_traits
<_II1
>::iterator_category
;
1488 using _Cat2
= typename iterator_traits
<_II2
>::iterator_category
;
1489 using _RAIters
= __and_
<is_same
<_Cat1
, _RATag
>, is_same
<_Cat2
, _RATag
>>;
1492 auto __d1
= std::distance(__first1
, __last1
);
1493 auto __d2
= std::distance(__first2
, __last2
);
1496 return _GLIBCXX_STD_A::equal(__first1
, __last1
, __first2
,
1500 for (; __first1
!= __last1
&& __first2
!= __last2
;
1501 ++__first1
, (void)++__first2
)
1502 if (!bool(__binary_pred(*__first1
, *__first2
)))
1504 return __first1
== __last1
&& __first2
== __last2
;
1508 #if __cplusplus > 201103L
1510 #define __cpp_lib_robust_nonmodifying_seq_ops 201304
1513 * @brief Tests a range for element-wise equality.
1514 * @ingroup non_mutating_algorithms
1515 * @param __first1 An input iterator.
1516 * @param __last1 An input iterator.
1517 * @param __first2 An input iterator.
1518 * @param __last2 An input iterator.
1519 * @return A boolean true or false.
1521 * This compares the elements of two ranges using @c == and returns true or
1522 * false depending on whether all of the corresponding elements of the
1525 template<typename _II1
, typename _II2
>
1526 _GLIBCXX20_CONSTEXPR
1528 equal(_II1 __first1
, _II1 __last1
, _II2 __first2
, _II2 __last2
)
1530 // concept requirements
1531 __glibcxx_function_requires(_InputIteratorConcept
<_II1
>)
1532 __glibcxx_function_requires(_InputIteratorConcept
<_II2
>)
1533 __glibcxx_function_requires(_EqualOpConcept
<
1534 typename iterator_traits
<_II1
>::value_type
,
1535 typename iterator_traits
<_II2
>::value_type
>)
1536 __glibcxx_requires_valid_range(__first1
, __last1
);
1537 __glibcxx_requires_valid_range(__first2
, __last2
);
1539 return _GLIBCXX_STD_A::__equal4(__first1
, __last1
, __first2
, __last2
);
1543 * @brief Tests a range for element-wise equality.
1544 * @ingroup non_mutating_algorithms
1545 * @param __first1 An input iterator.
1546 * @param __last1 An input iterator.
1547 * @param __first2 An input iterator.
1548 * @param __last2 An input iterator.
1549 * @param __binary_pred A binary predicate @link functors
1551 * @return A boolean true or false.
1553 * This compares the elements of two ranges using the binary_pred
1554 * parameter, and returns true or
1555 * false depending on whether all of the corresponding elements of the
1558 template<typename _IIter1
, typename _IIter2
, typename _BinaryPredicate
>
1559 _GLIBCXX20_CONSTEXPR
1561 equal(_IIter1 __first1
, _IIter1 __last1
,
1562 _IIter2 __first2
, _IIter2 __last2
, _BinaryPredicate __binary_pred
)
1564 // concept requirements
1565 __glibcxx_function_requires(_InputIteratorConcept
<_IIter1
>)
1566 __glibcxx_function_requires(_InputIteratorConcept
<_IIter2
>)
1567 __glibcxx_requires_valid_range(__first1
, __last1
);
1568 __glibcxx_requires_valid_range(__first2
, __last2
);
1570 return _GLIBCXX_STD_A::__equal4(__first1
, __last1
, __first2
, __last2
,
1576 * @brief Performs @b dictionary comparison on ranges.
1577 * @ingroup sorting_algorithms
1578 * @param __first1 An input iterator.
1579 * @param __last1 An input iterator.
1580 * @param __first2 An input iterator.
1581 * @param __last2 An input iterator.
1582 * @return A boolean true or false.
1584 * <em>Returns true if the sequence of elements defined by the range
1585 * [first1,last1) is lexicographically less than the sequence of elements
1586 * defined by the range [first2,last2). Returns false otherwise.</em>
1587 * (Quoted from [25.3.8]/1.) If the iterators are all character pointers,
1588 * then this is an inline call to @c memcmp.
1590 template<typename _II1
, typename _II2
>
1591 _GLIBCXX20_CONSTEXPR
1593 lexicographical_compare(_II1 __first1
, _II1 __last1
,
1594 _II2 __first2
, _II2 __last2
)
1596 #ifdef _GLIBCXX_CONCEPT_CHECKS
1597 // concept requirements
1598 typedef typename iterator_traits
<_II1
>::value_type _ValueType1
;
1599 typedef typename iterator_traits
<_II2
>::value_type _ValueType2
;
1601 __glibcxx_function_requires(_InputIteratorConcept
<_II1
>)
1602 __glibcxx_function_requires(_InputIteratorConcept
<_II2
>)
1603 __glibcxx_function_requires(_LessThanOpConcept
<_ValueType1
, _ValueType2
>)
1604 __glibcxx_function_requires(_LessThanOpConcept
<_ValueType2
, _ValueType1
>)
1605 __glibcxx_requires_valid_range(__first1
, __last1
);
1606 __glibcxx_requires_valid_range(__first2
, __last2
);
1608 return std::__lexicographical_compare_aux(std::__niter_base(__first1
),
1609 std::__niter_base(__last1
),
1610 std::__niter_base(__first2
),
1611 std::__niter_base(__last2
));
1615 * @brief Performs @b dictionary comparison on ranges.
1616 * @ingroup sorting_algorithms
1617 * @param __first1 An input iterator.
1618 * @param __last1 An input iterator.
1619 * @param __first2 An input iterator.
1620 * @param __last2 An input iterator.
1621 * @param __comp A @link comparison_functors comparison functor@endlink.
1622 * @return A boolean true or false.
1624 * The same as the four-parameter @c lexicographical_compare, but uses the
1625 * comp parameter instead of @c <.
1627 template<typename _II1
, typename _II2
, typename _Compare
>
1628 _GLIBCXX20_CONSTEXPR
1630 lexicographical_compare(_II1 __first1
, _II1 __last1
,
1631 _II2 __first2
, _II2 __last2
, _Compare __comp
)
1633 // concept requirements
1634 __glibcxx_function_requires(_InputIteratorConcept
<_II1
>)
1635 __glibcxx_function_requires(_InputIteratorConcept
<_II2
>)
1636 __glibcxx_requires_valid_range(__first1
, __last1
);
1637 __glibcxx_requires_valid_range(__first2
, __last2
);
1639 return std::__lexicographical_compare_impl
1640 (__first1
, __last1
, __first2
, __last2
,
1641 __gnu_cxx::__ops::__iter_comp_iter(__comp
));
1644 #if __cpp_lib_three_way_comparison
1645 // Iter points to a contiguous range of unsigned narrow character type
1646 // or std::byte, suitable for comparison by memcmp.
1647 template<typename _Iter
>
1648 concept __is_byte_iter
= contiguous_iterator
<_Iter
>
1649 && __is_byte
<iter_value_t
<_Iter
>>::__value
!= 0
1650 && !__gnu_cxx::__numeric_traits
<iter_value_t
<_Iter
>>::__is_signed
;
1652 // Return a struct with two members, initialized to the smaller of x and y
1653 // (or x if they compare equal) and the result of the comparison x <=> y.
1654 template<typename _Tp
>
1656 __min_cmp(_Tp __x
, _Tp __y
)
1660 decltype(__x
<=> __y
) _M_cmp
;
1662 auto __c
= __x
<=> __y
;
1664 return _Res
{__y
, __c
};
1665 return _Res
{__x
, __c
};
1669 * @brief Performs dictionary comparison on ranges.
1670 * @ingroup sorting_algorithms
1671 * @param __first1 An input iterator.
1672 * @param __last1 An input iterator.
1673 * @param __first2 An input iterator.
1674 * @param __last2 An input iterator.
1675 * @param __comp A @link comparison_functors comparison functor@endlink.
1676 * @return The comparison category that `__comp(*__first1, *__first2)`
1679 template<typename _InputIter1
, typename _InputIter2
, typename _Comp
>
1681 lexicographical_compare_three_way(_InputIter1 __first1
,
1682 _InputIter1 __last1
,
1683 _InputIter2 __first2
,
1684 _InputIter2 __last2
,
1686 -> decltype(__comp(*__first1
, *__first2
))
1688 // concept requirements
1689 __glibcxx_function_requires(_InputIteratorConcept
<_InputIter1
>)
1690 __glibcxx_function_requires(_InputIteratorConcept
<_InputIter2
>)
1691 __glibcxx_requires_valid_range(__first1
, __last1
);
1692 __glibcxx_requires_valid_range(__first2
, __last2
);
1694 #if __cpp_lib_is_constant_evaluated
1695 using _Cat
= decltype(__comp(*__first1
, *__first2
));
1696 static_assert(same_as
<common_comparison_category_t
<_Cat
>, _Cat
>);
1698 if (!std::is_constant_evaluated())
1699 if constexpr (same_as
<_Comp
, __detail::_Synth3way
>
1700 || same_as
<_Comp
, compare_three_way
>)
1701 if constexpr (__is_byte_iter
<_InputIter1
>)
1702 if constexpr (__is_byte_iter
<_InputIter2
>)
1704 const auto [__len
, __lencmp
]
1705 = std::__min_cmp(__last1
- __first1
, __last2
- __first2
);
1709 = __builtin_memcmp(&*__first1
, &*__first2
, __len
) <=> 0;
1715 #endif // is_constant_evaluated
1716 while (__first1
!= __last1
&& __first2
!= __last2
)
1718 if (auto __cmp
= __comp(*__first1
, *__first2
); __cmp
!= 0)
1723 return __first1
!= __last1
? strong_ordering::greater
1724 : __first2
!= __last2
? strong_ordering::less
: strong_ordering::equal
;
1727 template<typename _InputIter1
, typename _InputIter2
>
1729 lexicographical_compare_three_way(_InputIter1 __first1
,
1730 _InputIter1 __last1
,
1731 _InputIter2 __first2
,
1732 _InputIter2 __last2
)
1734 return std::lexicographical_compare_three_way(__first1
, __last1
,
1736 compare_three_way
{});
1738 #endif // three_way_comparison
1740 template<typename _InputIterator1
, typename _InputIterator2
,
1741 typename _BinaryPredicate
>
1742 _GLIBCXX20_CONSTEXPR
1743 pair
<_InputIterator1
, _InputIterator2
>
1744 __mismatch(_InputIterator1 __first1
, _InputIterator1 __last1
,
1745 _InputIterator2 __first2
, _BinaryPredicate __binary_pred
)
1747 while (__first1
!= __last1
&& __binary_pred(__first1
, __first2
))
1752 return pair
<_InputIterator1
, _InputIterator2
>(__first1
, __first2
);
1756 * @brief Finds the places in ranges which don't match.
1757 * @ingroup non_mutating_algorithms
1758 * @param __first1 An input iterator.
1759 * @param __last1 An input iterator.
1760 * @param __first2 An input iterator.
1761 * @return A pair of iterators pointing to the first mismatch.
1763 * This compares the elements of two ranges using @c == and returns a pair
1764 * of iterators. The first iterator points into the first range, the
1765 * second iterator points into the second range, and the elements pointed
1766 * to by the iterators are not equal.
1768 template<typename _InputIterator1
, typename _InputIterator2
>
1769 _GLIBCXX20_CONSTEXPR
1770 inline pair
<_InputIterator1
, _InputIterator2
>
1771 mismatch(_InputIterator1 __first1
, _InputIterator1 __last1
,
1772 _InputIterator2 __first2
)
1774 // concept requirements
1775 __glibcxx_function_requires(_InputIteratorConcept
<_InputIterator1
>)
1776 __glibcxx_function_requires(_InputIteratorConcept
<_InputIterator2
>)
1777 __glibcxx_function_requires(_EqualOpConcept
<
1778 typename iterator_traits
<_InputIterator1
>::value_type
,
1779 typename iterator_traits
<_InputIterator2
>::value_type
>)
1780 __glibcxx_requires_valid_range(__first1
, __last1
);
1782 return _GLIBCXX_STD_A::__mismatch(__first1
, __last1
, __first2
,
1783 __gnu_cxx::__ops::__iter_equal_to_iter());
1787 * @brief Finds the places in ranges which don't match.
1788 * @ingroup non_mutating_algorithms
1789 * @param __first1 An input iterator.
1790 * @param __last1 An input iterator.
1791 * @param __first2 An input iterator.
1792 * @param __binary_pred A binary predicate @link functors
1794 * @return A pair of iterators pointing to the first mismatch.
1796 * This compares the elements of two ranges using the binary_pred
1797 * parameter, and returns a pair
1798 * of iterators. The first iterator points into the first range, the
1799 * second iterator points into the second range, and the elements pointed
1800 * to by the iterators are not equal.
1802 template<typename _InputIterator1
, typename _InputIterator2
,
1803 typename _BinaryPredicate
>
1804 _GLIBCXX20_CONSTEXPR
1805 inline pair
<_InputIterator1
, _InputIterator2
>
1806 mismatch(_InputIterator1 __first1
, _InputIterator1 __last1
,
1807 _InputIterator2 __first2
, _BinaryPredicate __binary_pred
)
1809 // concept requirements
1810 __glibcxx_function_requires(_InputIteratorConcept
<_InputIterator1
>)
1811 __glibcxx_function_requires(_InputIteratorConcept
<_InputIterator2
>)
1812 __glibcxx_requires_valid_range(__first1
, __last1
);
1814 return _GLIBCXX_STD_A::__mismatch(__first1
, __last1
, __first2
,
1815 __gnu_cxx::__ops::__iter_comp_iter(__binary_pred
));
1818 #if __cplusplus > 201103L
1820 template<typename _InputIterator1
, typename _InputIterator2
,
1821 typename _BinaryPredicate
>
1822 _GLIBCXX20_CONSTEXPR
1823 pair
<_InputIterator1
, _InputIterator2
>
1824 __mismatch(_InputIterator1 __first1
, _InputIterator1 __last1
,
1825 _InputIterator2 __first2
, _InputIterator2 __last2
,
1826 _BinaryPredicate __binary_pred
)
1828 while (__first1
!= __last1
&& __first2
!= __last2
1829 && __binary_pred(__first1
, __first2
))
1834 return pair
<_InputIterator1
, _InputIterator2
>(__first1
, __first2
);
1838 * @brief Finds the places in ranges which don't match.
1839 * @ingroup non_mutating_algorithms
1840 * @param __first1 An input iterator.
1841 * @param __last1 An input iterator.
1842 * @param __first2 An input iterator.
1843 * @param __last2 An input iterator.
1844 * @return A pair of iterators pointing to the first mismatch.
1846 * This compares the elements of two ranges using @c == and returns a pair
1847 * of iterators. The first iterator points into the first range, the
1848 * second iterator points into the second range, and the elements pointed
1849 * to by the iterators are not equal.
1851 template<typename _InputIterator1
, typename _InputIterator2
>
1852 _GLIBCXX20_CONSTEXPR
1853 inline pair
<_InputIterator1
, _InputIterator2
>
1854 mismatch(_InputIterator1 __first1
, _InputIterator1 __last1
,
1855 _InputIterator2 __first2
, _InputIterator2 __last2
)
1857 // concept requirements
1858 __glibcxx_function_requires(_InputIteratorConcept
<_InputIterator1
>)
1859 __glibcxx_function_requires(_InputIteratorConcept
<_InputIterator2
>)
1860 __glibcxx_function_requires(_EqualOpConcept
<
1861 typename iterator_traits
<_InputIterator1
>::value_type
,
1862 typename iterator_traits
<_InputIterator2
>::value_type
>)
1863 __glibcxx_requires_valid_range(__first1
, __last1
);
1864 __glibcxx_requires_valid_range(__first2
, __last2
);
1866 return _GLIBCXX_STD_A::__mismatch(__first1
, __last1
, __first2
, __last2
,
1867 __gnu_cxx::__ops::__iter_equal_to_iter());
1871 * @brief Finds the places in ranges which don't match.
1872 * @ingroup non_mutating_algorithms
1873 * @param __first1 An input iterator.
1874 * @param __last1 An input iterator.
1875 * @param __first2 An input iterator.
1876 * @param __last2 An input iterator.
1877 * @param __binary_pred A binary predicate @link functors
1879 * @return A pair of iterators pointing to the first mismatch.
1881 * This compares the elements of two ranges using the binary_pred
1882 * parameter, and returns a pair
1883 * of iterators. The first iterator points into the first range, the
1884 * second iterator points into the second range, and the elements pointed
1885 * to by the iterators are not equal.
1887 template<typename _InputIterator1
, typename _InputIterator2
,
1888 typename _BinaryPredicate
>
1889 _GLIBCXX20_CONSTEXPR
1890 inline pair
<_InputIterator1
, _InputIterator2
>
1891 mismatch(_InputIterator1 __first1
, _InputIterator1 __last1
,
1892 _InputIterator2 __first2
, _InputIterator2 __last2
,
1893 _BinaryPredicate __binary_pred
)
1895 // concept requirements
1896 __glibcxx_function_requires(_InputIteratorConcept
<_InputIterator1
>)
1897 __glibcxx_function_requires(_InputIteratorConcept
<_InputIterator2
>)
1898 __glibcxx_requires_valid_range(__first1
, __last1
);
1899 __glibcxx_requires_valid_range(__first2
, __last2
);
1901 return _GLIBCXX_STD_A::__mismatch(__first1
, __last1
, __first2
, __last2
,
1902 __gnu_cxx::__ops::__iter_comp_iter(__binary_pred
));
1906 _GLIBCXX_END_NAMESPACE_ALGO
1907 _GLIBCXX_END_NAMESPACE_VERSION
1910 // NB: This file is included within many other C++ includes, as a way
1911 // of getting the base algorithms. So, make sure that parallel bits
1912 // come in too if requested.
1913 #ifdef _GLIBCXX_PARALLEL
1914 # include <parallel/algobase.h>