30 #ifndef _STLP_INTERNAL_ALGOBASE_H 31 #define _STLP_INTERNAL_ALGOBASE_H 33 #ifndef _STLP_INTERNAL_CSTDDEF 37 #ifndef _STLP_INTERNAL_CSTRING 45 #ifndef _STLP_INTERNAL_CSTDLIB 49 #ifndef _STLP_INTERNAL_PAIR_H 53 #ifndef _STLP_INTERNAL_ITERATOR_BASE_H 57 #ifndef _STLP_TYPE_TRAITS_H 63 #if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) 66 inline void __swap_aux(_Tp& __a, _Tp& __b,
const __true_type& ) {
67 __a._M_swap_workaround(__b);
71 inline void __swap_aux(_Tp& __a, _Tp& __b,
const __false_type& ) {
81 inline void swap(_Tp& __a, _Tp& __b) {
82 #if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) 83 # if !defined(__BORLANDC__) 84 typedef typename _SwapImplemented<_Tp>::_Ret _Implemented;
86 enum { _Is = _SwapImplemented<_Tp>::_Is };
89 _STLP_PRIV __swap_aux(__a, __b, _Implemented());
99 template <
class _ForwardIter1,
class _ForwardIter2,
class _Value>
106 template <
class _ForwardIter1,
class _ForwardIter2>
112 template <
class _ForwardIter1,
class _ForwardIter2>
119 template <
class _ForwardIter1,
class _ForwardIter2>
120 inline void iter_swap(_ForwardIter1 __i1, _ForwardIter2 __i2) {
129 #if !defined (__BORLANDC__) || defined (_STLP_USE_OWN_NAMESPACE) 130 # if (defined (__BORLANDC__) && (__BORLANDC__ < 0x580)) && !defined (__STDC__) 139 inline const _Tp& (
min)(
const _Tp& __a,
const _Tp& __b) {
return __b < __a ? __b : __a; }
141 inline const _Tp& (
max)(
const _Tp& __a,
const _Tp& __b) {
return __a < __b ? __b : __a; }
145 # if defined (__BORLANDC__) && defined (_STLP_USE_OWN_NAMESPACE) 146 inline unsigned long (
min) (
unsigned long __a,
unsigned long __b) {
return __b < __a ? __b : __a; }
147 inline unsigned long (
max) (
unsigned long __a,
unsigned long __b) {
return __a < __b ? __b : __a; }
150 # if !defined (__BORLANDC__) || (__BORLANDC__ < 0x590) 151 template <
class _Tp,
class _Compare>
152 inline const _Tp& (
min)(
const _Tp& __a,
const _Tp& __b, _Compare __comp) {
153 return __comp(__b, __a) ? __b : __a;
156 template <
class _Tp,
class _Compare>
157 inline const _Tp& (
max)(
const _Tp& __a,
const _Tp& __b, _Compare __comp) {
158 return __comp(__a, __b) ? __b : __a;
161 template <
class _Tp,
class _Compare>
162 inline const _Tp (
min)(
const _Tp __a,
const _Tp __b, _Compare __comp) {
163 return __comp(__b, __a) ? __b : __a;
166 template <
class _Tp,
class _Compare>
167 inline const _Tp (
max)(
const _Tp __a,
const _Tp __b, _Compare __comp) {
168 return __comp(__a, __b) ? __b : __a;
183 template <
class _InputIter,
class _OutputIter,
class _Distance>
186 for ( ; __first !=
__last; ++__result, ++__first)
187 *__result = *__first;
191 #if defined (_STLP_NONTEMPL_BASE_MATCH_BUG) 192 template <
class _InputIter,
class _OutputIter,
class _Distance>
193 inline _OutputIter
__copy(_InputIter __first, _InputIter
__last,
195 for ( ; __first !=
__last; ++__result, ++__first)
196 *__result = *__first;
200 template <
class _InputIter,
class _OutputIter,
class _Distance>
201 inline _OutputIter
__copy(_InputIter __first, _InputIter
__last,
203 for ( ; __first !=
__last; ++__result, ++__first)
204 *__result = *__first;
209 template <
class _RandomAccessIter,
class _OutputIter,
class _Distance>
214 *__result = *__first;
223 size_t __n = (
const char*)
__last - (
const char*)__first;
224 return __n ? (
void *)((
char*)
memmove(__result, __first,
__n) +
__n) : __result;
230 template <
class _BidirectionalIter1,
class _BidirectionalIter2,
233 _BidirectionalIter1
__last,
234 _BidirectionalIter2 __result,
242 template <
class _RandomAccessIter,
class _B
idirectionalIter,
class _Distance>
245 _BidirectionalIter __result,
256 return (_Num > 0) ?
memmove((
char*)__result - _Num, __first, _Num) : __result ;
259 template <
class _InputIter,
class _OutputIter>
264 template <
class _InputIter,
class _OutputIter>
272 template <
class _InputIter,
class _OutputIter>
280 template <
class _InputIter,
class _OutputIter>
290 template <
class _InputIter,
class _OutputIter>
291 inline _OutputIter
copy(_InputIter __first, _InputIter
__last, _OutputIter __result) {
298 template <
class _InputIter,
class _OutputIter>
305 template <
class _InputIter,
class _OutputIter>
311 template <
class _InputIter,
class _OutputIter>
318 template <
class _InputIter,
class _OutputIter>
327 template <
class _InputIter,
class _OutputIter>
333 #if !defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && !defined (_STLP_SIMULATE_PARTIAL_SPEC_FOR_TYPE_TRAITS) 334 # define _STLP_DECLARE_COPY_TRIVIAL(_Tp) \ 335 inline _Tp* copy(const _Tp* __first, const _Tp* __last, _Tp* __result) \ 336 { return (_Tp*)_STLP_PRIV __copy_trivial(__first, __last, __result); } \ 337 inline _Tp* copy_backward(const _Tp* __first, const _Tp* __last, _Tp* __result) \ 338 { return (_Tp*)_STLP_PRIV __copy_trivial_backward(__first, __last, __result); } 340 # if !defined (_STLP_NO_BOOL) 344 # if !defined (_STLP_NO_SIGNED_BUILTINS) 354 # if !defined(_STLP_NO_WCHAR_T) && !defined (_STLP_WCHAR_T_IS_USHORT) 357 # if defined (_STLP_LONG_LONG) 363 # if !defined (_STLP_NO_LONG_DOUBLE) 366 # undef _STLP_DECLARE_COPY_TRIVIAL 372 #if !defined (_STLP_NO_EXTENSIONS) 375 template <
class _InputIter,
class _Size,
class _OutputIter>
379 for ( ; __count > 0; --__count) {
380 *__result = *__first;
384 return _STLP_STD::pair<_InputIter, _OutputIter>(__first, __result);
387 template <
class _RAIter,
class _Size,
class _OutputIter>
388 inline _STLP_STD::pair<_RAIter, _OutputIter>
391 _RAIter
__last = __first + __count;
397 template <
class _InputIter,
class _Size,
class _OutputIter>
409 template <
class _ForwardIter,
class _Tp>
412 for ( ; __first !=
__last; ++__first)
416 template <
class _ForwardIter,
class _Tp,
class _Distance>
422 #if defined (_STLP_NONTEMPL_BASE_MATCH_BUG) 423 template <
class _ForwardIter,
class _Tp,
class _Distance>
430 template <
class _ForwardIter,
class _Tp,
class _Distance>
438 template <
class _RandomAccessIter,
class _Tp,
class _Distance>
448 template <
class _ForwardIter,
class _Tp>
457 inline void fill(
unsigned char* __first,
unsigned char*
__last,
458 const unsigned char&
__val) {
459 unsigned char __tmp =
__val;
462 #if !defined (_STLP_NO_SIGNED_BUILTINS) 464 const signed char&
__val) {
465 signed char __tmp =
__val;
476 template <
class _OutputIter,
class _Size,
class _Tp>
480 for ( ;
__n > 0; --
__n, ++__first)
485 #if defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) 486 template <
class _Size>
488 const unsigned char&
__val) {
490 return __first +
__n;
492 #if !defined (_STLP_NO_SIGNED_BUILTINS) 493 template <
class _Size>
495 const signed char&
__val) {
497 return __first +
__n;
500 template <
class _Size>
504 return __first +
__n;
510 template <
class _OutputIter,
class _Size,
class _Tp>
520 template <
class _InputIter1,
class _InputIter2>
522 _STLP_STD::pair<_InputIter1, _InputIter2>
mismatch(_InputIter1 __first1,
524 _InputIter2 __first2) {
527 while (__first1 != __last1 && *__first1 == *__first2) {
531 return _STLP_STD::pair<_InputIter1, _InputIter2>(__first1, __first2);
534 template <
class _InputIter1,
class _InputIter2,
class _BinaryPredicate>
536 _STLP_STD::pair<_InputIter1, _InputIter2>
mismatch(_InputIter1 __first1,
538 _InputIter2 __first2,
539 _BinaryPredicate __binary_pred) {
542 while (__first1 != __last1 && __binary_pred(*__first1, *__first2)) {
546 return _STLP_STD::pair<_InputIter1, _InputIter2>(__first1, __first2);
549 template <
class _InputIter1,
class _InputIter2>
551 bool equal(_InputIter1 __first1, _InputIter1 __last1,
552 _InputIter2 __first2) {
555 for ( ; __first1 != __last1; ++__first1, ++__first2)
556 if (!(*__first1 == *__first2))
561 template <
class _InputIter1,
class _InputIter2,
class _BinaryPredicate>
563 bool equal(_InputIter1 __first1, _InputIter1 __last1,
564 _InputIter2 __first2, _BinaryPredicate __binary_pred) {
567 for ( ; __first1 != __last1; ++__first1, ++__first2)
568 if (!__binary_pred(*__first1, *__first2))
577 template <
class _InputIter1,
class _InputIter2>
579 _InputIter2 __first2, _InputIter2 __last2);
581 template <
class _InputIter1,
class _InputIter2,
class _Compare>
583 _InputIter2 __first2, _InputIter2 __last2,
588 const unsigned char* __last1,
589 const unsigned char* __first2,
590 const unsigned char* __last2) {
591 const size_t __len1 = __last1 - __first1;
592 const size_t __len2 = __last2 - __first2;
596 const int __result =
memcmp(__first1, __first2, (
min) (__len1, __len2));
597 return __result != 0 ? (__result < 0) : (__len1 < __len2);
601 #if !(CHAR_MAX == SCHAR_MAX) 603 const char* __first2,
const char* __last2) {
608 (
const unsigned char*) __last1,
609 (
const unsigned char*) __first2,
610 (
const unsigned char*) __last2);
616 template <
class _InputIter1,
class _InputIter2>
618 _InputIter2 __first2, _InputIter2 __last2);
622 const unsigned char* __last1,
623 const unsigned char* __first2,
624 const unsigned char* __last2) {
625 const ptrdiff_t __len1 = __last1 - __first1;
626 const ptrdiff_t __len2 = __last2 - __first2;
627 const int __result =
memcmp(__first1, __first2, (
min) (__len1, __len2));
628 return __result != 0 ? __result
629 : (__len1 == __len2 ? 0 : (__len1 < __len2 ? -1 : 1));
633 #if !(CHAR_MAX == SCHAR_MAX) 636 const char* __first2,
const char* __last2) {
638 (
const unsigned char*) __last1,
639 (
const unsigned char*) __first2,
640 (
const unsigned char*) __last2);
646 #if !defined (_STLP_NO_EXTENSIONS) 647 template <
class _InputIter1,
class _InputIter2>
649 _InputIter2 __first2, _InputIter2 __last2);
654 template <
class _InputIter,
class _Tp>
659 for ( ; __first !=
__last; ++__first)
660 if (*__first ==
__val)
666 template <
class _InputIter,
class _Tp>
667 _InputIter
find(_InputIter __first, _InputIter
__last,
const _Tp&
__val);
669 template <
class _InputIter,
class _Predicate>
673 template <
class _ForwardIter1,
class _ForwardIter2,
class _BinaryPred>
674 _ForwardIter1
search(_ForwardIter1 __first1, _ForwardIter1 __last1,
675 _ForwardIter2 __first2, _ForwardIter2 __last2, _BinaryPred __predicate);
680 template <
class _InputIter,
class _ForwardIter>
682 _ForwardIter __first2, _ForwardIter __last2);
684 template <
class _InputIter,
class _ForwardIter,
class _BinaryPredicate>
686 _ForwardIter __first2, _ForwardIter __last2,
687 _BinaryPredicate __comp);
691 template <
class _ForwardIter1,
class _ForwardIter2,
692 class _BinaryPredicate>
694 find_end(_ForwardIter1 __first1, _ForwardIter1 __last1,
695 _ForwardIter2 __first2, _ForwardIter2 __last2,
696 _BinaryPredicate __comp);
699 template <
class _ForwardIter,
class _Tp>
702 const _Tp& __old_value,
const _Tp& __new_value) {
704 for ( ; __first !=
__last; ++__first)
705 if (*__first == __old_value)
706 *__first = __new_value;
711 template <
class _ForwardIter,
class _Tp,
class _Compare1,
class _Compare2,
class _Distance>
713 const _Tp&
__val, _Compare1 __comp1, _Compare2 __comp2, _Distance*);
719 #if !defined (_STLP_LINK_TIME_INSTANTIATION) #define memmove(s1, s2, n)
_STLP_MOVE_TO_PRIV_NAMESPACE void __iter_swap_aux_aux(_ForwardIter1 &__i1, _ForwardIter2 &__i2, _Value *)
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
_OKToSwap< _Tp1, _Tp2, _IsRef1, _IsRef2 > _IsOKToSwap(_Tp1 *, _Tp2 *, const _IsRef1 &, const _IsRef2 &)
_InputIter find_if(_InputIter __first, _InputIter __last, _Predicate __pred)
#define random_access_iterator_tag
#define __STATIC_CAST(__x, __y)
_STLP_BEGIN_NAMESPACE void swap(_Tp &__a, _Tp &__b)
GLuint GLuint GLsizei count
_STLP_INLINE_LOOP _InputIter _Predicate __pred
_STLP_MOVE_TO_PRIV_NAMESPACE _STLP_INLINE_LOOP _OutputIter __fill_n(_OutputIter __first, _Size __n, const _Tp &__val)
_BidirectionalIter2 __copy_backward(_BidirectionalIter1 __first, _BidirectionalIter1 __last, _BidirectionalIter2 __result, const bidirectional_iterator_tag &, _Distance *)
_STLP_MOVE_TO_PRIV_NAMESPACE _STLP_INLINE_LOOP _STLP_STD::pair< _InputIter, _OutputIter > __copy_n(_InputIter __first, _Size __count, _OutputIter __result, const input_iterator_tag &)
_STLP_MOVE_TO_STD_NAMESPACE _ForwardIter1 find_end(_ForwardIter1 __first1, _ForwardIter1 __last1, _ForwardIter2 __first2, _ForwardIter2 __last2, _BinaryPredicate __comp)
_STLP_MOVE_TO_PRIV_NAMESPACE _ForwardIter __lower_bound(_ForwardIter __first, _ForwardIter __last, const _Tp &__val, _Compare1 __comp1, _Compare2 __comp2, _Distance *)
#define _STLP_ITERATOR_CATEGORY(_It, _Tp)
#define _STLP_MOVE_TO_PRIV_NAMESPACE
#define _STLP_DECLARE_COPY_TRIVIAL(_Tp)
_STLP_INLINE_LOOP _STLP_STD::pair< _InputIter1, _InputIter2 > mismatch(_InputIter1 __first1, _InputIter1 __last1, _InputIter2 __first2)
_ForwardIter1 search(_ForwardIter1 __first1, _ForwardIter1 __last1, _ForwardIter2 __first2, _ForwardIter2 __last2, _BinaryPred __predicate)
#define _STLP_IS_REF_TYPE_REAL_REF(_It, _Tp)
_STLP_MOVE_TO_STD_NAMESPACE int lexicographical_compare_3way(_InputIter1 __first1, _InputIter1 __last1, _InputIter2 __first2, _InputIter2 __last2)
_STLP_MOVE_TO_PRIV_NAMESPACE int __lexicographical_compare_3way(_InputIter1 __first1, _InputIter1 __last1, _InputIter2 __first2, _InputIter2 __last2)
_STLP_MOVE_TO_PRIV_NAMESPACE _OutputIter __copy_backward_ptrs(_InputIter __first, _InputIter __last, _OutputIter __result, const __false_type &)
#define _STLP_MOVE_TO_STD_NAMESPACE
_STLP_MOVE_TO_STD_NAMESPACE void fill(_ForwardIter __first, _ForwardIter __last, const _Tp &__val)
_STLP_INLINE_LOOP _STLP_DIFFERENCE_TYPE(_InputIter) count(_InputIter __first
_STLP_INLINE_LOOP _InputIter const _Tp & __val
_STLP_MOVE_TO_PRIV_NAMESPACE _OutputIter __copy(_InputIter __first, _InputIter __last, _OutputIter __result, const input_iterator_tag &, _Distance *)
_STLP_MOVE_TO_STD_NAMESPACE pair< _InputIter, _OutputIter > copy_n(_InputIter __first, _Size __count, _OutputIter __result)
#define _STLP_INLINE_LOOP
#define _STLP_VALUE_TYPE(_It, _Tp)
_STLP_INLINE_LOOP void replace(_ForwardIter __first, _ForwardIter __last, const _Tp &__old_value, const _Tp &__new_value)
_STLP_MOVE_TO_PRIV_NAMESPACE _InputIter __find_first_of(_InputIter __first1, _InputIter __last1, _ForwardIter __first2, _ForwardIter __last2)
_OutputIter __copy_backward_aux(_InputIter __first, _InputIter __last, _OutputIter __result, const __false_type &)
_TrivialCopy< _Src, _Dst > _UseTrivialCopy(_Src *, _Dst *)
#define _STLP_DEBUG_CHECK(expr)
bool lexicographical_compare(_InputIter1 __first1, _InputIter1 __last1, _InputIter2 __first2, _InputIter2 __last2)
void * __copy_trivial_backward(const void *__first, const void *__last, void *__result)
const _Tp &() max(const _Tp &__a, const _Tp &__b)
_STLP_MOVE_TO_STD_NAMESPACE void fill_n(_OutputIter __first, _Size __n, const _Tp &__val)
_STLP_INLINE_LOOP _InputIter __last
_STLP_INLINE_LOOP bool equal(_InputIter1 __first1, _InputIter1 __last1, _InputIter2 __first2)
void __iter_swap_aux(_ForwardIter1 &__i1, _ForwardIter2 &__i2, const __true_type &)
#define _STLP_END_NAMESPACE
void * __copy_trivial(const void *__first, const void *__last, void *__result)
__kernel_ptrdiff_t ptrdiff_t
_STLP_MOVE_TO_STD_NAMESPACE void iter_swap(_ForwardIter1 __i1, _ForwardIter2 __i2)
#define _STLP_FIX_LITERAL_BUG(__x)
void __fill(_ForwardIter __first, _ForwardIter __last, const _Tp &__val, const input_iterator_tag &, _Distance *)
_Check_return_ _Ret_maybenull_ _In_ size_t _In_ size_t _Size
_InputIter find(_InputIter __first, _InputIter __last, const _Tp &__val)
#define _STLP_BEGIN_NAMESPACE
#define _STLP_DISTANCE_TYPE(_It, _Tp)
const _Tp &() min(const _Tp &__a, const _Tp &__b)
_STLP_MOVE_TO_STD_NAMESPACE _OutputIter copy_backward(_InputIter __first, _InputIter __last, _OutputIter __result)
_STLP_MOVE_TO_PRIV_NAMESPACE _STLP_INLINE_LOOP void __fill_fwd(_ForwardIter __first, _ForwardIter __last, const _Tp &__val)
_STLP_MOVE_TO_STD_NAMESPACE _OutputIter copy(_InputIter __first, _InputIter __last, _OutputIter __result)
_OutputIter __copy_ptrs(_InputIter __first, _InputIter __last, _OutputIter __result, const __false_type &)
_OutputIter __copy_aux(_InputIter __first, _InputIter __last, _OutputIter __result, const __true_type &)