epoc32/include/tools/stlport/stl/_algobase.h
branchSymbian3
changeset 4 837f303aceeb
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/tools/stlport/stl/_algobase.h	Wed Mar 31 12:33:34 2010 +0100
     1.3 @@ -0,0 +1,670 @@
     1.4 +/*
     1.5 + *
     1.6 + * Copyright (c) 1994
     1.7 + * Hewlett-Packard Company
     1.8 + *
     1.9 + * Copyright (c) 1996,1997
    1.10 + * Silicon Graphics Computer Systems, Inc.
    1.11 + *
    1.12 + * Copyright (c) 1997
    1.13 + * Moscow Center for SPARC Technology
    1.14 + *
    1.15 + * Copyright (c) 1999
    1.16 + * Boris Fomitchev
    1.17 + *
    1.18 + * This material is provided "as is", with absolutely no warranty expressed
    1.19 + * or implied. Any use is at your own risk.
    1.20 + *
    1.21 + * Permission to use or copy this software for any purpose is hereby granted
    1.22 + * without fee, provided the above notices are retained on all copies.
    1.23 + * Permission to modify the code and to distribute modified code is granted,
    1.24 + * provided the above notices are retained, and a notice that the code was
    1.25 + * modified is included with the above copyright notice.
    1.26 + *
    1.27 + */
    1.28 +
    1.29 +/* NOTE: This is an internal header file, included by other STL headers.
    1.30 + *   You should not attempt to use it directly.
    1.31 + */
    1.32 +
    1.33 +#ifndef _STLP_INTERNAL_ALGOBASE_H
    1.34 +#define _STLP_INTERNAL_ALGOBASE_H
    1.35 +
    1.36 +#ifndef _STLP_INTERNAL_CSTDDEF
    1.37 +#  include <stl/_cstddef.h>
    1.38 +#endif
    1.39 +
    1.40 +#ifndef _STLP_INTERNAL_CSTRING
    1.41 +#  include <stl/_cstring.h>
    1.42 +#endif
    1.43 +
    1.44 +#ifndef _STLP_CLIMITS
    1.45 +#  include <climits>
    1.46 +#endif
    1.47 +
    1.48 +#ifndef _STLP_INTERNAL_CSTDLIB
    1.49 +#  include <stl/_cstdlib.h>
    1.50 +#endif
    1.51 +
    1.52 +#ifndef _STLP_INTERNAL_PAIR_H
    1.53 +#  include <stl/_pair.h>
    1.54 +#endif
    1.55 +
    1.56 +#ifndef _STLP_INTERNAL_ITERATOR_BASE_H
    1.57 +#  include <stl/_iterator_base.h>
    1.58 +#endif
    1.59 +
    1.60 +#ifndef _STLP_TYPE_TRAITS_H
    1.61 +#  include <stl/type_traits.h>
    1.62 +#endif
    1.63 +
    1.64 +_STLP_BEGIN_NAMESPACE
    1.65 +
    1.66 +#if defined(_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined(_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
    1.67 +_STLP_MOVE_TO_PRIV_NAMESPACE
    1.68 +template <class _Tp>
    1.69 +inline void __swap_aux(_Tp& __a, _Tp& __b, const __true_type& /*SwapImplemented*/) {
    1.70 +  __a.swap(__b);
    1.71 +}
    1.72 +
    1.73 +template <class _Tp>
    1.74 +inline void __swap_aux(_Tp& __a, _Tp& __b, const __false_type& /*SwapImplemented*/) {
    1.75 +  _Tp __tmp = __a;
    1.76 +  __a = __b;
    1.77 +  __b = __tmp;
    1.78 +}
    1.79 +_STLP_MOVE_TO_STD_NAMESPACE
    1.80 +#endif /* _STLP_USE_PARTIAL_SPEC_WORKAROUND */
    1.81 +
    1.82 +// swap and iter_swap
    1.83 +template <class _Tp>
    1.84 +inline void swap(_Tp& __a, _Tp& __b) {
    1.85 +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
    1.86 +#  if !defined(__BORLANDC__)
    1.87 +  typedef typename _SwapImplemented<_Tp>::_Ret _Implemented;
    1.88 +#  else
    1.89 +  enum { _Is = _SwapImplemented<_Tp>::_Is };
    1.90 +  typedef typename __bool2type<_Is>::_Ret _Implemented;
    1.91 +#  endif
    1.92 +  _STLP_PRIV __swap_aux(__a, __b, _Implemented());
    1.93 +#else
    1.94 +  _Tp __tmp = __a;
    1.95 +  __a = __b;
    1.96 +  __b = __tmp;
    1.97 +#endif /* _STLP_USE_PARTIAL_SPEC_WORKAROUND */
    1.98 +}
    1.99 +
   1.100 +_STLP_MOVE_TO_PRIV_NAMESPACE
   1.101 +
   1.102 +template <class _ForwardIter1, class _ForwardIter2, class _Value>
   1.103 +inline void __iter_swap_aux_aux(_ForwardIter1& __i1, _ForwardIter2& __i2, _Value *) {
   1.104 +  _Value tmp = *__i1;
   1.105 +  *__i1 = *__i2;
   1.106 +  *__i2 = tmp;
   1.107 +}
   1.108 +
   1.109 +template <class _ForwardIter1, class _ForwardIter2>
   1.110 +inline void __iter_swap_aux(_ForwardIter1& __i1, _ForwardIter2& __i2, const __true_type& /*OKToSwap*/) {
   1.111 +  swap(*__i1, *__i2);
   1.112 +}
   1.113 +
   1.114 +template <class _ForwardIter1, class _ForwardIter2>
   1.115 +inline void __iter_swap_aux(_ForwardIter1& __i1, _ForwardIter2& __i2, const __false_type& /*OKToSwap*/) {
   1.116 +  __iter_swap_aux_aux( __i1, __i2, _STLP_VALUE_TYPE(__i1,_ForwardIter1) );
   1.117 +}
   1.118 +
   1.119 +_STLP_MOVE_TO_STD_NAMESPACE
   1.120 +
   1.121 +template <class _ForwardIter1, class _ForwardIter2>
   1.122 +inline void iter_swap(_ForwardIter1 __i1, _ForwardIter2 __i2) {
   1.123 +  // swap(*__i1, *__i2);
   1.124 +  _STLP_PRIV __iter_swap_aux( __i1, __i2, _IsOKToSwap(_STLP_VALUE_TYPE(__i1, _ForwardIter1), _STLP_VALUE_TYPE(__i2, _ForwardIter2),
   1.125 +                                                      _STLP_IS_REF_TYPE_REAL_REF(__i1, _ForwardIter1),
   1.126 +                                                      _STLP_IS_REF_TYPE_REAL_REF(__i2, _ForwardIter2))._Answer());
   1.127 +}
   1.128 +
   1.129 +//--------------------------------------------------
   1.130 +// min and max
   1.131 +
   1.132 +#if !defined (__BORLANDC__) || defined (_STLP_USE_OWN_NAMESPACE)
   1.133 +#  if (defined (__BORLANDC__) && (__BORLANDC__ < 0x580)) && !defined (__STDC__)
   1.134 +//In not ANSI mode Borland import min/max in global namespace which conflict
   1.135 +//with STLport min/max when user does a 'using namespace std' in its code
   1.136 +//(see test/unit/alg_test.cpp). To avoid this clash we simply import Borland min/max
   1.137 +//in STLport namespace.
   1.138 +using _STLP_VENDOR_STD::min;
   1.139 +using _STLP_VENDOR_STD::max;
   1.140 +#  else
   1.141 +template <class _Tp>
   1.142 +inline const _Tp& (min)(const _Tp& __a, const _Tp& __b) { return __b < __a ? __b : __a; }
   1.143 +template <class _Tp>
   1.144 +inline const _Tp& (max)(const _Tp& __a, const _Tp& __b) {  return  __a < __b ? __b : __a; }
   1.145 +#  endif
   1.146 +#endif
   1.147 +
   1.148 +# if defined (__BORLANDC__) && defined (_STLP_USE_OWN_NAMESPACE)
   1.149 +inline unsigned long (min) (unsigned long __a, unsigned long __b) { return __b < __a ? __b : __a; }
   1.150 +inline unsigned long (max) (unsigned long __a, unsigned long __b) {  return  __a < __b ? __b : __a; }
   1.151 +# endif
   1.152 +
   1.153 +template <class _Tp, class _Compare>
   1.154 +inline const _Tp& (min)(const _Tp& __a, const _Tp& __b, _Compare __comp) {
   1.155 +  return __comp(__b, __a) ? __b : __a;
   1.156 +}
   1.157 +
   1.158 +template <class _Tp, class _Compare>
   1.159 +inline const _Tp& (max)(const _Tp& __a, const _Tp& __b, _Compare __comp) {
   1.160 +  return __comp(__a, __b) ? __b : __a;
   1.161 +}
   1.162 +
   1.163 +//--------------------------------------------------
   1.164 +// copy
   1.165 +
   1.166 +// All of these auxiliary functions serve two purposes.  (1) Replace
   1.167 +// calls to copy with memmove whenever possible.  (Memmove, not memcpy,
   1.168 +// because the input and output ranges are permitted to overlap.)
   1.169 +// (2) If we're using random access iterators, then write the loop as
   1.170 +// a for loop with an explicit count.
   1.171 +
   1.172 +_STLP_MOVE_TO_PRIV_NAMESPACE
   1.173 +
   1.174 +template <class _InputIter, class _OutputIter, class _Distance>
   1.175 +inline _OutputIter __copy(_InputIter __first, _InputIter __last,
   1.176 +                          _OutputIter __result, const input_iterator_tag &, _Distance*) {
   1.177 +  for ( ; __first != __last; ++__result, ++__first)
   1.178 +    *__result = *__first;
   1.179 +  return __result;
   1.180 +}
   1.181 +
   1.182 +#if defined (_STLP_NONTEMPL_BASE_MATCH_BUG)
   1.183 +template <class _InputIter, class _OutputIter, class _Distance>
   1.184 +inline _OutputIter __copy(_InputIter __first, _InputIter __last,
   1.185 +                          _OutputIter __result, const forward_iterator_tag &, _Distance* ) {
   1.186 +  for ( ; __first != __last; ++__result, ++__first)
   1.187 +    *__result = *__first;
   1.188 +  return __result;
   1.189 +}
   1.190 +
   1.191 +template <class _InputIter, class _OutputIter, class _Distance>
   1.192 +inline _OutputIter __copy(_InputIter __first, _InputIter __last,
   1.193 +                          _OutputIter __result, const bidirectional_iterator_tag &, _Distance* ) {
   1.194 +  for ( ; __first != __last; ++__result, ++__first)
   1.195 +    *__result = *__first;
   1.196 +  return __result;
   1.197 +}
   1.198 +#endif
   1.199 +
   1.200 +template <class _RandomAccessIter, class _OutputIter, class _Distance>
   1.201 +inline _OutputIter
   1.202 +__copy(_RandomAccessIter __first, _RandomAccessIter __last,
   1.203 +       _OutputIter __result, const random_access_iterator_tag &, _Distance*) {
   1.204 +  for (_Distance __n = __last - __first; __n > 0; --__n) {
   1.205 +    *__result = *__first;
   1.206 +    ++__first;
   1.207 +    ++__result;
   1.208 +  }
   1.209 +  return __result;
   1.210 +}
   1.211 +
   1.212 +inline void*
   1.213 +__copy_trivial(const void* __first, const void* __last, void* __result) {
   1.214 +  size_t __n = (const char*)__last - (const char*)__first;
   1.215 +  return __n ? (void *)((char*)memmove(__result, __first, __n) + __n) : __result;
   1.216 +}
   1.217 +
   1.218 +//--------------------------------------------------
   1.219 +// copy_backward auxiliary functions
   1.220 +
   1.221 +template <class _BidirectionalIter1, class _BidirectionalIter2,
   1.222 +          class _Distance>
   1.223 +inline _BidirectionalIter2 __copy_backward(_BidirectionalIter1 __first,
   1.224 +                                           _BidirectionalIter1 __last,
   1.225 +                                           _BidirectionalIter2 __result,
   1.226 +                                           const bidirectional_iterator_tag &,
   1.227 +                                           _Distance*) {
   1.228 +  while (__first != __last)
   1.229 +    *--__result = *--__last;
   1.230 +  return __result;
   1.231 +}
   1.232 +
   1.233 +template <class _RandomAccessIter, class _BidirectionalIter, class _Distance>
   1.234 +inline _BidirectionalIter __copy_backward(_RandomAccessIter __first,
   1.235 +                                          _RandomAccessIter __last,
   1.236 +                                          _BidirectionalIter __result,
   1.237 +                                          const random_access_iterator_tag &,
   1.238 +                                          _Distance*) {
   1.239 +  for (_Distance __n = __last - __first; __n > 0; --__n)
   1.240 +    *--__result = *--__last;
   1.241 +  return __result;
   1.242 +}
   1.243 +
   1.244 +inline void*
   1.245 +__copy_trivial_backward(const void* __first, const void* __last, void* __result) {
   1.246 +  const ptrdiff_t _Num = (const char*)__last - (const char*)__first;
   1.247 +  return (_Num > 0) ? memmove((char*)__result - _Num, __first, _Num) : __result ;
   1.248 +}
   1.249 +
   1.250 +template <class _InputIter, class _OutputIter>
   1.251 +inline _OutputIter __copy_ptrs(_InputIter __first, _InputIter __last, _OutputIter __result,
   1.252 +                               const __false_type& /*IsOKToMemCpy*/) {
   1.253 +  return __copy(__first, __last, __result, random_access_iterator_tag(), (ptrdiff_t*)0);
   1.254 +}
   1.255 +template <class _InputIter, class _OutputIter>
   1.256 +inline _OutputIter __copy_ptrs(_InputIter __first, _InputIter __last, _OutputIter __result,
   1.257 +                               const __true_type& /*IsOKToMemCpy*/) {
   1.258 +  // we know they all pointers, so this cast is OK
   1.259 +  //  return (_OutputIter)__copy_trivial(&(*__first), &(*__last), &(*__result));
   1.260 +  return (_OutputIter)__copy_trivial(__first, __last, __result);
   1.261 +}
   1.262 +
   1.263 +template <class _InputIter, class _OutputIter>
   1.264 +inline _OutputIter __copy_aux(_InputIter __first, _InputIter __last, _OutputIter __result,
   1.265 +                              const __true_type& /*BothPtrType*/) {
   1.266 +  return __copy_ptrs(__first, __last, __result,
   1.267 +                     _UseTrivialCopy(_STLP_VALUE_TYPE(__first, _InputIter),
   1.268 +                                     _STLP_VALUE_TYPE(__result, _OutputIter))._Answer());
   1.269 +}
   1.270 +
   1.271 +template <class _InputIter, class _OutputIter>
   1.272 +inline _OutputIter __copy_aux(_InputIter __first, _InputIter __last, _OutputIter __result,
   1.273 +                              const __false_type& /*BothPtrType*/) {
   1.274 +  return __copy(__first, __last, __result,
   1.275 +                _STLP_ITERATOR_CATEGORY(__first, _InputIter),
   1.276 +                _STLP_DISTANCE_TYPE(__first, _InputIter));
   1.277 +}
   1.278 +
   1.279 +_STLP_MOVE_TO_STD_NAMESPACE
   1.280 +
   1.281 +template <class _InputIter, class _OutputIter>
   1.282 +inline _OutputIter copy(_InputIter __first, _InputIter __last, _OutputIter __result) {
   1.283 +  _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
   1.284 +  return _STLP_PRIV __copy_aux(__first, __last, __result, _BothPtrType< _InputIter, _OutputIter>::_Answer());
   1.285 +}
   1.286 +
   1.287 +_STLP_MOVE_TO_PRIV_NAMESPACE
   1.288 +
   1.289 +template <class _InputIter, class _OutputIter>
   1.290 +inline _OutputIter __copy_backward_ptrs(_InputIter __first, _InputIter __last,
   1.291 +                                        _OutputIter __result, const __false_type& /*TrivialAssignment*/) {
   1.292 +  return __copy_backward(__first, __last, __result, _STLP_ITERATOR_CATEGORY(__first, _InputIter), _STLP_DISTANCE_TYPE(__first, _InputIter));
   1.293 +}
   1.294 +template <class _InputIter, class _OutputIter>
   1.295 +inline _OutputIter __copy_backward_ptrs(_InputIter __first, _InputIter __last,
   1.296 +                                        _OutputIter __result, const __true_type& /*TrivialAssignment*/) {
   1.297 +  return (_OutputIter)__copy_trivial_backward(__first, __last, __result);
   1.298 +}
   1.299 +
   1.300 +template <class _InputIter, class _OutputIter>
   1.301 +inline _OutputIter __copy_backward_aux(_InputIter __first, _InputIter __last, _OutputIter __result, const __false_type&) {
   1.302 +  return __copy_backward(__first, __last, __result, _STLP_ITERATOR_CATEGORY(__first,_InputIter), _STLP_DISTANCE_TYPE(__first, _InputIter));
   1.303 +}
   1.304 +
   1.305 +template <class _InputIter, class _OutputIter>
   1.306 +inline _OutputIter __copy_backward_aux(_InputIter __first, _InputIter __last, _OutputIter __result, const __true_type&) {
   1.307 +  return __copy_backward_ptrs(__first, __last, __result,
   1.308 +                              _UseTrivialCopy(_STLP_VALUE_TYPE(__first, _InputIter),
   1.309 +                                              _STLP_VALUE_TYPE(__result, _OutputIter))._Answer());
   1.310 +}
   1.311 +
   1.312 +_STLP_MOVE_TO_STD_NAMESPACE
   1.313 +
   1.314 +template <class _InputIter, class _OutputIter>
   1.315 +inline _OutputIter copy_backward(_InputIter __first, _InputIter __last, _OutputIter __result) {
   1.316 +  _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
   1.317 +  return _STLP_PRIV __copy_backward_aux(__first, __last, __result, _BothPtrType< _InputIter, _OutputIter>::_Answer() );
   1.318 +}
   1.319 +
   1.320 +#if !defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && !defined (_STLP_SIMULATE_PARTIAL_SPEC_FOR_TYPE_TRAITS)
   1.321 +#  define _STLP_DECLARE_COPY_TRIVIAL(_Tp)                                       \
   1.322 +inline _Tp* copy(const _Tp* __first, const _Tp* __last, _Tp* __result)          \
   1.323 +{ return (_Tp*)__copy_trivial(__first, __last, __result); }                     \
   1.324 +inline _Tp* copy_backward(const _Tp* __first, const _Tp* __last, _Tp* __result) \
   1.325 +{ return (_Tp*)__copy_trivial_backward(__first, __last, __result); }
   1.326 +
   1.327 +_STLP_DECLARE_COPY_TRIVIAL(char)
   1.328 +#  if !defined (_STLP_NO_SIGNED_BUILTINS)
   1.329 +_STLP_DECLARE_COPY_TRIVIAL(signed char)
   1.330 +#  endif
   1.331 +_STLP_DECLARE_COPY_TRIVIAL(unsigned char)
   1.332 +_STLP_DECLARE_COPY_TRIVIAL(short)
   1.333 +_STLP_DECLARE_COPY_TRIVIAL(unsigned short)
   1.334 +_STLP_DECLARE_COPY_TRIVIAL(int)
   1.335 +_STLP_DECLARE_COPY_TRIVIAL(unsigned int)
   1.336 +_STLP_DECLARE_COPY_TRIVIAL(long)
   1.337 +_STLP_DECLARE_COPY_TRIVIAL(unsigned long)
   1.338 +#  if !defined(_STLP_NO_WCHAR_T) && !defined (_STLP_WCHAR_T_IS_USHORT)
   1.339 +_STLP_DECLARE_COPY_TRIVIAL(wchar_t)
   1.340 +#  endif
   1.341 +#  if defined (_STLP_LONG_LONG)
   1.342 +_STLP_DECLARE_COPY_TRIVIAL(_STLP_LONG_LONG)
   1.343 +_STLP_DECLARE_COPY_TRIVIAL(unsigned _STLP_LONG_LONG)
   1.344 +#  endif
   1.345 +_STLP_DECLARE_COPY_TRIVIAL(float)
   1.346 +_STLP_DECLARE_COPY_TRIVIAL(double)
   1.347 +#  if !defined (_STLP_NO_LONG_DOUBLE)
   1.348 +_STLP_DECLARE_COPY_TRIVIAL(long double)
   1.349 +#  endif
   1.350 +#  undef _STLP_DECLARE_COPY_TRIVIAL
   1.351 +#endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */
   1.352 +
   1.353 +//--------------------------------------------------
   1.354 +// copy_n (not part of the C++ standard)
   1.355 +
   1.356 +#if !defined (_STLP_NO_EXTENSIONS)
   1.357 +_STLP_MOVE_TO_PRIV_NAMESPACE
   1.358 +
   1.359 +template <class _InputIter, class _Size, class _OutputIter>
   1.360 +_STLP_INLINE_LOOP pair<_InputIter, _OutputIter>
   1.361 +__copy_n(_InputIter __first, _Size __count,
   1.362 +         _OutputIter __result,
   1.363 +         const input_iterator_tag &) {
   1.364 +  for ( ; __count > 0; --__count) {
   1.365 +    *__result = *__first;
   1.366 +    ++__first;
   1.367 +    ++__result;
   1.368 +  }
   1.369 +  return pair<_InputIter, _OutputIter>(__first, __result);
   1.370 +}
   1.371 +
   1.372 +template <class _RAIter, class _Size, class _OutputIter>
   1.373 +inline pair<_RAIter, _OutputIter>
   1.374 +__copy_n(_RAIter __first, _Size __count,
   1.375 +         _OutputIter __result,
   1.376 +         const random_access_iterator_tag &) {
   1.377 +  _RAIter __last = __first + __count;
   1.378 +  return pair<_RAIter, _OutputIter>(__last, copy(__first, __last, __result));
   1.379 +}
   1.380 +
   1.381 +_STLP_MOVE_TO_STD_NAMESPACE
   1.382 +
   1.383 +template <class _InputIter, class _Size, class _OutputIter>
   1.384 +inline pair<_InputIter, _OutputIter>
   1.385 +copy_n(_InputIter __first, _Size __count, _OutputIter __result) {
   1.386 +  _STLP_FIX_LITERAL_BUG(__first)
   1.387 +  return _STLP_PRIV __copy_n(__first, __count, __result, _STLP_ITERATOR_CATEGORY(__first, _InputIter));
   1.388 +}
   1.389 +#endif
   1.390 +
   1.391 +//--------------------------------------------------
   1.392 +// fill and fill_n
   1.393 +template <class _ForwardIter, class _Tp>
   1.394 +_STLP_INLINE_LOOP
   1.395 +void fill(_ForwardIter __first, _ForwardIter __last, const _Tp& __val) {
   1.396 +  _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
   1.397 +  for ( ; __first != __last; ++__first)
   1.398 +    *__first = __val;
   1.399 +}
   1.400 +
   1.401 +_STLP_MOVE_TO_PRIV_NAMESPACE
   1.402 +
   1.403 +template <class _OutputIter, class _Size, class _Tp>
   1.404 +_STLP_INLINE_LOOP
   1.405 +_OutputIter __fill_n(_OutputIter __first, _Size __n, const _Tp& __val) {
   1.406 +  _STLP_FIX_LITERAL_BUG(__first)
   1.407 +  for ( ; __n > 0; --__n, ++__first)
   1.408 +    *__first = __val;
   1.409 +  return __first;
   1.410 +}
   1.411 +
   1.412 +_STLP_MOVE_TO_STD_NAMESPACE
   1.413 +
   1.414 +template <class _OutputIter, class _Size, class _Tp>
   1.415 +_STLP_INLINE_LOOP
   1.416 +void fill_n(_OutputIter __first, _Size __n, const _Tp& __val) {
   1.417 +  _STLP_FIX_LITERAL_BUG(__first)
   1.418 +  _STLP_PRIV __fill_n(__first, __n, __val);
   1.419 +}
   1.420 +
   1.421 +// Specialization: for one-byte types we can use memset.
   1.422 +inline void fill(unsigned char* __first, unsigned char* __last,
   1.423 +                 const unsigned char& __val) {
   1.424 +  unsigned char __tmp = __val;
   1.425 +  memset(__first, __tmp, __last - __first);
   1.426 +}
   1.427 +#if !defined (_STLP_NO_SIGNED_BUILTINS)
   1.428 +inline void fill(signed char* __first, signed char* __last,
   1.429 +                 const signed char& __val) {
   1.430 +  signed char __tmp = __val;
   1.431 +  memset(__first, __STATIC_CAST(unsigned char,__tmp), __last - __first);
   1.432 +}
   1.433 +#endif
   1.434 +inline void fill(char* __first, char* __last, const char& __val) {
   1.435 +  char __tmp = __val;
   1.436 +  memset(__first, __STATIC_CAST(unsigned char,__tmp), __last - __first);
   1.437 +}
   1.438 +
   1.439 +#if defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
   1.440 +_STLP_MOVE_TO_PRIV_NAMESPACE
   1.441 +
   1.442 +template <class _Size>
   1.443 +inline unsigned char* __fill_n(unsigned char* __first, _Size __n,
   1.444 +                             const unsigned char& __val) {
   1.445 +  fill(__first, __first + __n, __val);
   1.446 +  return __first + __n;
   1.447 +}
   1.448 +
   1.449 +template <class _Size>
   1.450 +inline signed char* __fill_n(char* __first, _Size __n,
   1.451 +                           const signed char& __val) {
   1.452 +  fill(__first, __first + __n, __val);
   1.453 +  return __first + __n;
   1.454 +}
   1.455 +
   1.456 +template <class _Size>
   1.457 +inline char* __fill_n(char* __first, _Size __n, const char& __val) {
   1.458 +  fill(__first, __first + __n, __val);
   1.459 +  return __first + __n;
   1.460 +}
   1.461 +
   1.462 +_STLP_MOVE_TO_STD_NAMESPACE
   1.463 +#endif /* _STLP_FUNCTION_TMPL_PARTIAL_ORDER */
   1.464 +
   1.465 +
   1.466 +//--------------------------------------------------
   1.467 +// equal and mismatch
   1.468 +
   1.469 +template <class _InputIter1, class _InputIter2>
   1.470 +_STLP_INLINE_LOOP
   1.471 +pair<_InputIter1, _InputIter2> mismatch(_InputIter1 __first1,
   1.472 +                                        _InputIter1 __last1,
   1.473 +                                        _InputIter2 __first2) {
   1.474 +  _STLP_FIX_LITERAL_BUG(__first2)
   1.475 +  _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1))
   1.476 +  while (__first1 != __last1 && *__first1 == *__first2) {
   1.477 +    ++__first1;
   1.478 +    ++__first2;
   1.479 +  }
   1.480 +  return pair<_InputIter1, _InputIter2>(__first1, __first2);
   1.481 +}
   1.482 +
   1.483 +template <class _InputIter1, class _InputIter2, class _BinaryPredicate>
   1.484 +_STLP_INLINE_LOOP
   1.485 +pair<_InputIter1, _InputIter2> mismatch(_InputIter1 __first1,
   1.486 +                                        _InputIter1 __last1,
   1.487 +                                        _InputIter2 __first2,
   1.488 +                                        _BinaryPredicate __binary_pred) {
   1.489 +  _STLP_FIX_LITERAL_BUG(__first2)
   1.490 +  _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1))
   1.491 +  while (__first1 != __last1 && __binary_pred(*__first1, *__first2)) {
   1.492 +    ++__first1;
   1.493 +    ++__first2;
   1.494 +  }
   1.495 +  return pair<_InputIter1, _InputIter2>(__first1, __first2);
   1.496 +}
   1.497 +
   1.498 +template <class _InputIter1, class _InputIter2>
   1.499 +_STLP_INLINE_LOOP
   1.500 +bool equal(_InputIter1 __first1, _InputIter1 __last1,
   1.501 +                  _InputIter2 __first2) {
   1.502 +  _STLP_FIX_LITERAL_BUG(__first1) _STLP_FIX_LITERAL_BUG(__last1)  _STLP_FIX_LITERAL_BUG(__first2)
   1.503 +  _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1))
   1.504 +  for ( ; __first1 != __last1; ++__first1, ++__first2)
   1.505 +    if (!(*__first1 == *__first2))
   1.506 +      return false;
   1.507 +  return true;
   1.508 +}
   1.509 +
   1.510 +template <class _InputIter1, class _InputIter2, class _BinaryPredicate>
   1.511 +_STLP_INLINE_LOOP
   1.512 +bool equal(_InputIter1 __first1, _InputIter1 __last1,
   1.513 +                  _InputIter2 __first2, _BinaryPredicate __binary_pred) {
   1.514 +  _STLP_FIX_LITERAL_BUG(__first2)
   1.515 +  _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1))
   1.516 +  for ( ; __first1 != __last1; ++__first1, ++__first2)
   1.517 +    if (!__binary_pred(*__first1, *__first2))
   1.518 +      return false;
   1.519 +  return true;
   1.520 +}
   1.521 +
   1.522 +//--------------------------------------------------
   1.523 +// lexicographical_compare and lexicographical_compare_3way.
   1.524 +// (the latter is not part of the C++ standard.)
   1.525 +
   1.526 +template <class _InputIter1, class _InputIter2>
   1.527 +bool lexicographical_compare(_InputIter1 __first1, _InputIter1 __last1,
   1.528 +                             _InputIter2 __first2, _InputIter2 __last2);
   1.529 +
   1.530 +template <class _InputIter1, class _InputIter2, class _Compare>
   1.531 +bool lexicographical_compare(_InputIter1 __first1, _InputIter1 __last1,
   1.532 +                             _InputIter2 __first2, _InputIter2 __last2,
   1.533 +                             _Compare __comp);
   1.534 +
   1.535 +inline bool
   1.536 +lexicographical_compare(const unsigned char* __first1,
   1.537 +                        const unsigned char* __last1,
   1.538 +                        const unsigned char* __first2,
   1.539 +                        const unsigned char* __last2) {
   1.540 +  const size_t __len1 = __last1 - __first1;
   1.541 +  const size_t __len2 = __last2 - __first2;
   1.542 +  _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1))
   1.543 +  _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first2, __last2))
   1.544 +
   1.545 +  const int __result = memcmp(__first1, __first2, (min) (__len1, __len2));
   1.546 +  return __result != 0 ? (__result < 0) : (__len1 < __len2);
   1.547 +}
   1.548 +
   1.549 +
   1.550 +#if !(CHAR_MAX == SCHAR_MAX)
   1.551 +inline bool lexicographical_compare(const char* __first1, const char* __last1,
   1.552 +                                    const char* __first2, const char* __last2) {
   1.553 +  _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1))
   1.554 +  _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first2, __last2))
   1.555 +
   1.556 +  return lexicographical_compare((const unsigned char*) __first1,
   1.557 +                                 (const unsigned char*) __last1,
   1.558 +                                 (const unsigned char*) __first2,
   1.559 +                                 (const unsigned char*) __last2);
   1.560 +}
   1.561 +#endif /* CHAR_MAX == SCHAR_MAX */
   1.562 +
   1.563 +_STLP_MOVE_TO_PRIV_NAMESPACE
   1.564 +
   1.565 +template <class _InputIter1, class _InputIter2>
   1.566 +int __lexicographical_compare_3way(_InputIter1 __first1, _InputIter1 __last1,
   1.567 +                                   _InputIter2 __first2, _InputIter2 __last2);
   1.568 +
   1.569 +inline int
   1.570 +__lexicographical_compare_3way(const unsigned char* __first1,
   1.571 +                               const unsigned char* __last1,
   1.572 +                               const unsigned char* __first2,
   1.573 +                               const unsigned char* __last2) {
   1.574 +  const ptrdiff_t __len1 = __last1 - __first1;
   1.575 +  const ptrdiff_t __len2 = __last2 - __first2;
   1.576 +  const int __result = memcmp(__first1, __first2, (min) (__len1, __len2));
   1.577 +  return __result != 0 ? __result
   1.578 +                       : (__len1 == __len2 ? 0 : (__len1 < __len2 ? -1 : 1));
   1.579 +}
   1.580 +
   1.581 +
   1.582 +#if !(CHAR_MAX == SCHAR_MAX)
   1.583 +inline int
   1.584 +__lexicographical_compare_3way(const char* __first1, const char* __last1,
   1.585 +                               const char* __first2, const char* __last2) {
   1.586 +  return __lexicographical_compare_3way((const unsigned char*) __first1,
   1.587 +                                        (const unsigned char*) __last1,
   1.588 +                                        (const unsigned char*) __first2,
   1.589 +                                        (const unsigned char*) __last2);
   1.590 +}
   1.591 +#endif
   1.592 +
   1.593 +_STLP_MOVE_TO_STD_NAMESPACE
   1.594 +
   1.595 +#if !defined (_STLP_NO_EXTENSIONS)
   1.596 +template <class _InputIter1, class _InputIter2>
   1.597 +int lexicographical_compare_3way(_InputIter1 __first1, _InputIter1 __last1,
   1.598 +                                 _InputIter2 __first2, _InputIter2 __last2);
   1.599 +
   1.600 +#endif /* EXTENSIONS */
   1.601 +
   1.602 +// count
   1.603 +template <class _InputIter, class _Tp>
   1.604 +_STLP_INLINE_LOOP _STLP_DIFFERENCE_TYPE(_InputIter)
   1.605 +count(_InputIter __first, _InputIter __last, const _Tp& __val) {
   1.606 +  _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
   1.607 +  _STLP_DIFFERENCE_TYPE(_InputIter) __n = 0;
   1.608 +  for ( ; __first != __last; ++__first)
   1.609 +    if (*__first == __val)
   1.610 +      ++__n;
   1.611 +  return __n;
   1.612 +}
   1.613 +
   1.614 +// find and find_if. Note find may be expressed in terms of find_if if appropriate binder was available.
   1.615 +template <class _InputIter, class _Tp>
   1.616 +_InputIter find(_InputIter __first, _InputIter __last, const _Tp& __val);
   1.617 +
   1.618 +template <class _InputIter, class _Predicate>
   1.619 +_InputIter find_if(_InputIter __first, _InputIter __last, _Predicate __pred);
   1.620 +
   1.621 +// search.
   1.622 +template <class _ForwardIter1, class _ForwardIter2, class _BinaryPred>
   1.623 +_ForwardIter1 search(_ForwardIter1 __first1, _ForwardIter1 __last1,
   1.624 +                     _ForwardIter2 __first2, _ForwardIter2 __last2, _BinaryPred  __predicate);
   1.625 +
   1.626 +_STLP_MOVE_TO_PRIV_NAMESPACE
   1.627 +
   1.628 +// find_first_of
   1.629 +template <class _InputIter, class _ForwardIter, class _BinaryPredicate>
   1.630 +_InputIter __find_first_of(_InputIter __first1, _InputIter __last1,
   1.631 +                           _ForwardIter __first2, _ForwardIter __last2,
   1.632 +                           _BinaryPredicate __comp);
   1.633 +
   1.634 +_STLP_MOVE_TO_STD_NAMESPACE
   1.635 +
   1.636 +template <class _ForwardIter1, class _ForwardIter2,
   1.637 +          class _BinaryPredicate>
   1.638 +_ForwardIter1
   1.639 +find_end(_ForwardIter1 __first1, _ForwardIter1 __last1,
   1.640 +         _ForwardIter2 __first2, _ForwardIter2 __last2,
   1.641 +         _BinaryPredicate __comp);
   1.642 +
   1.643 +// replace
   1.644 +template <class _ForwardIter, class _Tp>
   1.645 +_STLP_INLINE_LOOP void
   1.646 +replace(_ForwardIter __first, _ForwardIter __last,
   1.647 +        const _Tp& __old_value, const _Tp& __new_value) {
   1.648 +  _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
   1.649 +  for ( ; __first != __last; ++__first)
   1.650 +    if (*__first == __old_value)
   1.651 +      *__first = __new_value;
   1.652 +}
   1.653 +
   1.654 +_STLP_MOVE_TO_PRIV_NAMESPACE
   1.655 +
   1.656 +template <class _ForwardIter, class _Tp, class _Compare1, class _Compare2, class _Distance>
   1.657 +_ForwardIter __lower_bound(_ForwardIter __first, _ForwardIter __last,
   1.658 +                           const _Tp& __val, _Compare1 __comp1, _Compare2 __comp2, _Distance*);
   1.659 +
   1.660 +_STLP_MOVE_TO_STD_NAMESPACE
   1.661 +
   1.662 +_STLP_END_NAMESPACE
   1.663 +
   1.664 +#if !defined (_STLP_LINK_TIME_INSTANTIATION)
   1.665 +#  include <stl/_algobase.c>
   1.666 +#endif
   1.667 +
   1.668 +#endif /* _STLP_INTERNAL_ALGOBASE_H */
   1.669 +
   1.670 +// Local Variables:
   1.671 +// mode:C++
   1.672 +// End:
   1.673 +