epoc32/include/stdapis/stlportv5/stl/_algo.h
branchSymbian3
changeset 4 837f303aceeb
parent 3 e1b950c65cb4
     1.1 --- a/epoc32/include/stdapis/stlportv5/stl/_algo.h	Wed Mar 31 12:27:01 2010 +0100
     1.2 +++ b/epoc32/include/stdapis/stlportv5/stl/_algo.h	Wed Mar 31 12:33:34 2010 +0100
     1.3 @@ -9,13 +9,13 @@
     1.4   * Copyright (c) 1997
     1.5   * Moscow Center for SPARC Technology
     1.6   *
     1.7 - * Copyright (c) 1999 
     1.8 + * Copyright (c) 1999
     1.9   * Boris Fomitchev
    1.10   *
    1.11   * This material is provided "as is", with absolutely no warranty expressed
    1.12   * or implied. Any use is at your own risk.
    1.13   *
    1.14 - * Permission to use or copy this software for any purpose is hereby granted 
    1.15 + * Permission to use or copy this software for any purpose is hereby granted
    1.16   * without fee, provided the above notices are retained on all copies.
    1.17   * Permission to modify the code and to distribute modified code is granted,
    1.18   * provided the above notices are retained, and a notice that the code was
    1.19 @@ -30,36 +30,32 @@
    1.20  #ifndef _STLP_INTERNAL_ALGO_H
    1.21  #define _STLP_INTERNAL_ALGO_H
    1.22  
    1.23 -# ifndef _STLP_INTERNAL_ALGOBASE_H
    1.24 +#ifndef _STLP_INTERNAL_ALGOBASE_H
    1.25  #  include <stl/_algobase.h>
    1.26 -# endif
    1.27 +#endif
    1.28  
    1.29 -# ifndef _STLP_INTERNAL_TEMPBUF_H
    1.30 -#  include <stl/_tempbuf.h>
    1.31 -# endif
    1.32 +#ifndef _STLP_INTERNAL_HEAP_H
    1.33 +#  include <stl/_heap.h>
    1.34 +#endif
    1.35  
    1.36 -# ifndef _STLP_INTERNAL_HEAP_H
    1.37 -#  include <stl/_heap.h>
    1.38 -# endif
    1.39 +#ifndef _STLP_INTERNAL_ITERATOR_H
    1.40 +#  include <stl/_iterator.h>
    1.41 +#endif
    1.42  
    1.43 -# ifndef _STLP_INTERNAL_ITERATOR_H
    1.44 -#  include <stl/_iterator.h>
    1.45 -# endif
    1.46 +#ifndef _STLP_INTERNAL_FUNCTION_BASE_H
    1.47 +#  include <stl/_function_base.h>
    1.48 +#endif
    1.49  
    1.50 -# ifndef _STLP_INTERNAL_FUNCTION_BASE_H
    1.51 -#  include <stl/_function_base.h>
    1.52 -# endif
    1.53 -
    1.54 -# ifdef __SUNPRO_CC
    1.55 +#if defined (__SUNPRO_CC) && !defined (_STLP_INTERNAL_CSTDIO)
    1.56  // remove() conflict
    1.57 -#  include <cstdio>
    1.58 -# endif
    1.59 +#  include <stl/_cstdio.h>
    1.60 +#endif
    1.61  
    1.62  _STLP_BEGIN_NAMESPACE
    1.63  
    1.64  // for_each.  Apply a function to every element of a range.
    1.65  template <class _InputIter, class _Function>
    1.66 -_STLP_INLINE_LOOP _Function 
    1.67 +_STLP_INLINE_LOOP _Function
    1.68  for_each(_InputIter __first, _InputIter __last, _Function __f) {
    1.69    for ( ; __first != __last; ++__first)
    1.70      __f(*__first);
    1.71 @@ -70,21 +66,22 @@
    1.72  template <class _InputIter, class _Predicate>
    1.73  _STLP_INLINE_LOOP _STLP_DIFFERENCE_TYPE(_InputIter)
    1.74  count_if(_InputIter __first, _InputIter __last, _Predicate __pred) {
    1.75 -  _STLP_DEBUG_CHECK(__check_range(__first, __last))
    1.76 -_STLP_DIFFERENCE_TYPE(_InputIter) __n = 0;
    1.77 -  for ( ; __first != __last; ++__first)
    1.78 +  _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
    1.79 +  _STLP_DIFFERENCE_TYPE(_InputIter) __n = 0;
    1.80 +  for ( ; __first != __last; ++__first) {
    1.81      if (__pred(*__first))
    1.82        ++__n;
    1.83 +  }
    1.84    return __n;
    1.85  }
    1.86  
    1.87  // adjacent_find.
    1.88  
    1.89  template <class _ForwardIter, class _BinaryPredicate>
    1.90 -_STLP_INLINE_LOOP _ForwardIter 
    1.91 +_STLP_INLINE_LOOP _ForwardIter
    1.92  adjacent_find(_ForwardIter __first, _ForwardIter __last,
    1.93                _BinaryPredicate __binary_pred) {
    1.94 -  _STLP_DEBUG_CHECK(__check_range(__first, __last))
    1.95 +  _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
    1.96    if (__first == __last)
    1.97      return __last;
    1.98    _ForwardIter __next = __first;
    1.99 @@ -97,31 +94,31 @@
   1.100  }
   1.101  
   1.102  template <class _ForwardIter>
   1.103 -_STLP_INLINE_LOOP _ForwardIter 
   1.104 +_STLP_INLINE_LOOP _ForwardIter
   1.105  adjacent_find(_ForwardIter __first, _ForwardIter __last) {
   1.106    return adjacent_find(__first, __last,
   1.107 -		       __equal_to(_STLP_VALUE_TYPE(__first, _ForwardIter)));
   1.108 +                       _STLP_PRIV __equal_to(_STLP_VALUE_TYPE(__first, _ForwardIter)));
   1.109  }
   1.110  
   1.111 -# ifndef _STLP_NO_ANACHRONISMS
   1.112 +#if !defined (_STLP_NO_ANACHRONISMS)
   1.113  template <class _InputIter, class _Tp, class _Size>
   1.114 -_STLP_INLINE_LOOP void 
   1.115 +_STLP_INLINE_LOOP void
   1.116  count(_InputIter __first, _InputIter __last, const _Tp& __val, _Size& __n) {
   1.117 -  _STLP_DEBUG_CHECK(__check_range(__first, __last))
   1.118 +  _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
   1.119      for ( ; __first != __last; ++__first)
   1.120        if (*__first == __val)
   1.121          ++__n;
   1.122  }
   1.123  
   1.124  template <class _InputIter, class _Predicate, class _Size>
   1.125 -_STLP_INLINE_LOOP void 
   1.126 +_STLP_INLINE_LOOP void
   1.127  count_if(_InputIter __first, _InputIter __last, _Predicate __pred, _Size& __n) {
   1.128 -  _STLP_DEBUG_CHECK(__check_range(__first, __last))
   1.129 +  _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
   1.130    for ( ; __first != __last; ++__first)
   1.131      if (__pred(*__first))
   1.132        ++__n;
   1.133  }
   1.134 -# endif
   1.135 +#endif
   1.136  
   1.137  template <class _ForwardIter1, class _ForwardIter2>
   1.138  _ForwardIter1 search(_ForwardIter1 __first1, _ForwardIter1 __last1,
   1.139 @@ -138,30 +135,31 @@
   1.140  template <class _InputIter, class _ForwardIter>
   1.141  inline _InputIter find_first_of(_InputIter __first1, _InputIter __last1,
   1.142                                  _ForwardIter __first2, _ForwardIter __last2) {
   1.143 -  _STLP_DEBUG_CHECK(__check_range(__first1, __last1))
   1.144 -  _STLP_DEBUG_CHECK(__check_range(__first2, __last2))
   1.145 -  return __find_first_of(__first1, __last1, __first2, __last2,__equal_to(_STLP_VALUE_TYPE(__first1, _InputIter)));
   1.146 +  _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1))
   1.147 +  _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first2, __last2))
   1.148 +  return _STLP_PRIV __find_first_of(__first1, __last1, __first2, __last2,
   1.149 +                                    _STLP_PRIV __equal_to(_STLP_VALUE_TYPE(__first1, _InputIter)));
   1.150  }
   1.151  
   1.152  template <class _InputIter, class _ForwardIter, class _BinaryPredicate>
   1.153 -inline _InputIter 
   1.154 +inline _InputIter
   1.155  find_first_of(_InputIter __first1, _InputIter __last1,
   1.156 -              _ForwardIter __first2, _ForwardIter __last2,_BinaryPredicate __comp) {
   1.157 -  _STLP_DEBUG_CHECK(__check_range(__first1, __last1))
   1.158 -  _STLP_DEBUG_CHECK(__check_range(__first2, __last2))
   1.159 -  return __find_first_of(__first1, __last1, __first2, __last2,__comp);
   1.160 +              _ForwardIter __first2, _ForwardIter __last2, _BinaryPredicate __comp) {
   1.161 +  _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1))
   1.162 +  _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first2, __last2))
   1.163 +  return _STLP_PRIV __find_first_of(__first1, __last1, __first2, __last2, __comp);
   1.164  }
   1.165  
   1.166  template <class _ForwardIter1, class _ForwardIter2>
   1.167 -_ForwardIter1 
   1.168 -find_end(_ForwardIter1 __first1, _ForwardIter1 __last1, 
   1.169 +_ForwardIter1
   1.170 +find_end(_ForwardIter1 __first1, _ForwardIter1 __last1,
   1.171           _ForwardIter2 __first2, _ForwardIter2 __last2);
   1.172  
   1.173  // swap_ranges
   1.174  template <class _ForwardIter1, class _ForwardIter2>
   1.175 -_STLP_INLINE_LOOP _ForwardIter2 
   1.176 +_STLP_INLINE_LOOP _ForwardIter2
   1.177  swap_ranges(_ForwardIter1 __first1, _ForwardIter1 __last1, _ForwardIter2 __first2) {
   1.178 -  _STLP_DEBUG_CHECK(__check_range(__first1, __last1))
   1.179 +  _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1))
   1.180    for ( ; __first1 != __last1; ++__first1, ++__first2)
   1.181      iter_swap(__first1, __first2);
   1.182    return __first2;
   1.183 @@ -169,18 +167,18 @@
   1.184  
   1.185  // transform
   1.186  template <class _InputIter, class _OutputIter, class _UnaryOperation>
   1.187 -_STLP_INLINE_LOOP _OutputIter 
   1.188 +_STLP_INLINE_LOOP _OutputIter
   1.189  transform(_InputIter __first, _InputIter __last, _OutputIter __result, _UnaryOperation __opr) {
   1.190 -  _STLP_DEBUG_CHECK(__check_range(__first, __last))
   1.191 +  _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
   1.192    for ( ; __first != __last; ++__first, ++__result)
   1.193      *__result = __opr(*__first);
   1.194    return __result;
   1.195  }
   1.196  template <class _InputIter1, class _InputIter2, class _OutputIter, class _BinaryOperation>
   1.197 -_STLP_INLINE_LOOP _OutputIter 
   1.198 -transform(_InputIter1 __first1, _InputIter1 __last1, 
   1.199 +_STLP_INLINE_LOOP _OutputIter
   1.200 +transform(_InputIter1 __first1, _InputIter1 __last1,
   1.201            _InputIter2 __first2, _OutputIter __result,_BinaryOperation __binary_op) {
   1.202 -  _STLP_DEBUG_CHECK(__check_range(__first1, __last1))
   1.203 +  _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1))
   1.204    for ( ; __first1 != __last1; ++__first1, ++__first2, ++__result)
   1.205      *__result = __binary_op(*__first1, *__first2);
   1.206    return __result;
   1.207 @@ -189,30 +187,30 @@
   1.208  // replace_if, replace_copy, replace_copy_if
   1.209  
   1.210  template <class _ForwardIter, class _Predicate, class _Tp>
   1.211 -_STLP_INLINE_LOOP void 
   1.212 +_STLP_INLINE_LOOP void
   1.213  replace_if(_ForwardIter __first, _ForwardIter __last, _Predicate __pred, const _Tp& __new_value) {
   1.214 -  _STLP_DEBUG_CHECK(__check_range(__first, __last))
   1.215 +  _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
   1.216    for ( ; __first != __last; ++__first)
   1.217      if (__pred(*__first))
   1.218        *__first = __new_value;
   1.219  }
   1.220  
   1.221  template <class _InputIter, class _OutputIter, class _Tp>
   1.222 -_STLP_INLINE_LOOP  _OutputIter 
   1.223 +_STLP_INLINE_LOOP  _OutputIter
   1.224  replace_copy(_InputIter __first, _InputIter __last,_OutputIter __result,
   1.225               const _Tp& __old_value, const _Tp& __new_value) {
   1.226 -  _STLP_DEBUG_CHECK(__check_range(__first, __last))
   1.227 +  _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
   1.228    for ( ; __first != __last; ++__first, ++__result)
   1.229      *__result = *__first == __old_value ? __new_value : *__first;
   1.230    return __result;
   1.231  }
   1.232  
   1.233  template <class _Iterator, class _OutputIter, class _Predicate, class _Tp>
   1.234 -_STLP_INLINE_LOOP _OutputIter 
   1.235 +_STLP_INLINE_LOOP _OutputIter
   1.236  replace_copy_if(_Iterator __first, _Iterator __last,
   1.237                  _OutputIter __result,
   1.238                  _Predicate __pred, const _Tp& __new_value) {
   1.239 -  _STLP_DEBUG_CHECK(__check_range(__first, __last))
   1.240 +  _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
   1.241    for ( ; __first != __last; ++__first, ++__result)
   1.242      *__result = __pred(*__first) ? __new_value : *__first;
   1.243    return __result;
   1.244 @@ -221,64 +219,65 @@
   1.245  // generate and generate_n
   1.246  
   1.247  template <class _ForwardIter, class _Generator>
   1.248 -_STLP_INLINE_LOOP void 
   1.249 +_STLP_INLINE_LOOP void
   1.250  generate(_ForwardIter __first, _ForwardIter __last, _Generator __gen) {
   1.251 -  _STLP_DEBUG_CHECK(__check_range(__first, __last))
   1.252 +  _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
   1.253    for ( ; __first != __last; ++__first)
   1.254      *__first = __gen();
   1.255  }
   1.256  
   1.257  template <class _OutputIter, class _Size, class _Generator>
   1.258 -_STLP_INLINE_LOOP _OutputIter 
   1.259 +_STLP_INLINE_LOOP void
   1.260  generate_n(_OutputIter __first, _Size __n, _Generator __gen) {
   1.261    for ( ; __n > 0; --__n, ++__first)
   1.262      *__first = __gen();
   1.263 -  return __first;
   1.264  }
   1.265  
   1.266  // remove, remove_if, remove_copy, remove_copy_if
   1.267  
   1.268  template <class _InputIter, class _OutputIter, class _Tp>
   1.269 -_STLP_INLINE_LOOP _OutputIter 
   1.270 +_STLP_INLINE_LOOP _OutputIter
   1.271  remove_copy(_InputIter __first, _InputIter __last,_OutputIter __result, const _Tp& __val) {
   1.272 -  _STLP_DEBUG_CHECK(__check_range(__first, __last))
   1.273 -  for ( ; __first != __last; ++__first)
   1.274 +  _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
   1.275 +  for ( ; __first != __last; ++__first) {
   1.276      if (!(*__first == __val)) {
   1.277        *__result = *__first;
   1.278        ++__result;
   1.279      }
   1.280 +  }
   1.281    return __result;
   1.282  }
   1.283  
   1.284  template <class _InputIter, class _OutputIter, class _Predicate>
   1.285 -_STLP_INLINE_LOOP _OutputIter 
   1.286 +_STLP_INLINE_LOOP _OutputIter
   1.287  remove_copy_if(_InputIter __first, _InputIter __last, _OutputIter __result, _Predicate __pred) {
   1.288 -  _STLP_DEBUG_CHECK(__check_range(__first, __last))
   1.289 -  for ( ; __first != __last; ++__first)
   1.290 +  _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
   1.291 +  for ( ; __first != __last; ++__first) {
   1.292      if (!__pred(*__first)) {
   1.293        *__result = *__first;
   1.294        ++__result;
   1.295      }
   1.296 +  }
   1.297    return __result;
   1.298  }
   1.299  
   1.300  template <class _ForwardIter, class _Tp>
   1.301 -_STLP_INLINE_LOOP _ForwardIter 
   1.302 +_STLP_INLINE_LOOP _ForwardIter
   1.303  remove(_ForwardIter __first, _ForwardIter __last, const _Tp& __val) {
   1.304 -  _STLP_DEBUG_CHECK(__check_range(__first, __last))
   1.305 +  _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
   1.306    __first = find(__first, __last, __val);
   1.307    if (__first == __last)
   1.308      return __first;
   1.309 -  else { 
   1.310 +  else {
   1.311      _ForwardIter __next = __first;
   1.312      return remove_copy(++__next, __last, __first, __val);
   1.313    }
   1.314  }
   1.315  
   1.316  template <class _ForwardIter, class _Predicate>
   1.317 -_STLP_INLINE_LOOP _ForwardIter 
   1.318 +_STLP_INLINE_LOOP _ForwardIter
   1.319  remove_if(_ForwardIter __first, _ForwardIter __last, _Predicate __pred) {
   1.320 -  _STLP_DEBUG_CHECK(__check_range(__first, __last))
   1.321 +  _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
   1.322    __first = find_if(__first, __last, __pred);
   1.323    if ( __first == __last )
   1.324      return __first;
   1.325 @@ -304,7 +303,7 @@
   1.326  
   1.327  template <class _ForwardIter, class _BinaryPredicate>
   1.328  inline _ForwardIter unique(_ForwardIter __first, _ForwardIter __last,
   1.329 -                    _BinaryPredicate __binary_pred) {
   1.330 +                           _BinaryPredicate __binary_pred) {
   1.331    __first = adjacent_find(__first, __last, __binary_pred);
   1.332    return unique_copy(__first, __last, __first, __binary_pred);
   1.333  }
   1.334 @@ -312,32 +311,33 @@
   1.335  // reverse and reverse_copy, and their auxiliary functions
   1.336  
   1.337  template <class _BidirectionalIter>
   1.338 -_STLP_INLINE_LOOP void 
   1.339 +_STLP_INLINE_LOOP void
   1.340  __reverse(_BidirectionalIter __first, _BidirectionalIter __last, const bidirectional_iterator_tag &) {
   1.341 -  for(; __first != __last && __first != --__last; ++__first)
   1.342 +  for (; __first != __last && __first != --__last; ++__first)
   1.343      iter_swap(__first,__last);
   1.344  }
   1.345  
   1.346  
   1.347  template <class _RandomAccessIter>
   1.348 -_STLP_INLINE_LOOP void 
   1.349 +_STLP_INLINE_LOOP void
   1.350  __reverse(_RandomAccessIter __first, _RandomAccessIter __last, const random_access_iterator_tag &) {
   1.351 -  for (; __first < __last; ++__first) iter_swap(__first, --__last);
   1.352 +  for (; __first < __last; ++__first)
   1.353 +    iter_swap(__first, --__last);
   1.354  }
   1.355  
   1.356  template <class _BidirectionalIter>
   1.357 -inline void 
   1.358 +inline void
   1.359  reverse(_BidirectionalIter __first, _BidirectionalIter __last) {
   1.360 -  _STLP_DEBUG_CHECK(__check_range(__first, __last))
   1.361 +  _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
   1.362    __reverse(__first, __last, _STLP_ITERATOR_CATEGORY(__first, _BidirectionalIter));
   1.363  }
   1.364  
   1.365  template <class _BidirectionalIter, class _OutputIter>
   1.366  _STLP_INLINE_LOOP
   1.367  _OutputIter reverse_copy(_BidirectionalIter __first,
   1.368 -                            _BidirectionalIter __last,
   1.369 -                            _OutputIter __result) {
   1.370 -  _STLP_DEBUG_CHECK(__check_range(__first, __last))
   1.371 +                         _BidirectionalIter __last,
   1.372 +                         _OutputIter __result) {
   1.373 +  _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
   1.374    while (__first != __last) {
   1.375      --__last;
   1.376      *__result = *__last;
   1.377 @@ -346,13 +346,13 @@
   1.378    return __result;
   1.379  }
   1.380  
   1.381 +_STLP_MOVE_TO_PRIV_NAMESPACE
   1.382 +
   1.383  // rotate and rotate_copy, and their auxiliary functions
   1.384 -
   1.385  template <class _EuclideanRingElement>
   1.386  _STLP_INLINE_LOOP
   1.387  _EuclideanRingElement __gcd(_EuclideanRingElement __m,
   1.388 -                            _EuclideanRingElement __n)
   1.389 -{
   1.390 +                            _EuclideanRingElement __n) {
   1.391    while (__n != 0) {
   1.392      _EuclideanRingElement __t = __m % __n;
   1.393      __m = __n;
   1.394 @@ -361,9 +361,10 @@
   1.395    return __m;
   1.396  }
   1.397  
   1.398 +_STLP_MOVE_TO_STD_NAMESPACE
   1.399 +
   1.400  template <class _ForwardIter>
   1.401 -_ForwardIter 
   1.402 -rotate(_ForwardIter __first, _ForwardIter __middle, _ForwardIter __last);
   1.403 +void rotate(_ForwardIter __first, _ForwardIter __middle, _ForwardIter __last);
   1.404  
   1.405  template <class _ForwardIter, class _OutputIter>
   1.406  inline _OutputIter rotate_copy(_ForwardIter __first, _ForwardIter __middle,
   1.407 @@ -380,17 +381,17 @@
   1.408  void random_shuffle(_RandomAccessIter __first, _RandomAccessIter __last,
   1.409                      _RandomNumberGenerator& __rand);
   1.410  
   1.411 -# ifndef _STLP_NO_EXTENSIONS
   1.412 +#if !defined (_STLP_NO_EXTENSIONS)
   1.413  // random_sample and random_sample_n (extensions, not part of the standard).
   1.414  
   1.415  template <class _ForwardIter, class _OutputIter, class _Distance>
   1.416  _OutputIter random_sample_n(_ForwardIter __first, _ForwardIter __last,
   1.417 -                            _OutputIter __stl_out, const _Distance __n);
   1.418 +                            _OutputIter __out_ite, const _Distance __n);
   1.419  
   1.420  template <class _ForwardIter, class _OutputIter, class _Distance,
   1.421            class _RandomNumberGenerator>
   1.422  _OutputIter random_sample_n(_ForwardIter __first, _ForwardIter __last,
   1.423 -                            _OutputIter __stl_out, const _Distance __n,
   1.424 +                            _OutputIter __out_ite, const _Distance __n,
   1.425                              _RandomNumberGenerator& __rand);
   1.426  
   1.427  template <class _InputIter, class _RandomAccessIter>
   1.428 @@ -398,26 +399,26 @@
   1.429  random_sample(_InputIter __first, _InputIter __last,
   1.430                _RandomAccessIter __out_first, _RandomAccessIter __out_last);
   1.431  
   1.432 -template <class _InputIter, class _RandomAccessIter, 
   1.433 +template <class _InputIter, class _RandomAccessIter,
   1.434            class _RandomNumberGenerator>
   1.435  _RandomAccessIter
   1.436  random_sample(_InputIter __first, _InputIter __last,
   1.437                _RandomAccessIter __out_first, _RandomAccessIter __out_last,
   1.438                _RandomNumberGenerator& __rand);
   1.439  
   1.440 -# endif /* _STLP_NO_EXTENSIONS */
   1.441 +#endif /* _STLP_NO_EXTENSIONS */
   1.442  
   1.443  // partition, stable_partition, and their auxiliary functions
   1.444  
   1.445  template <class _ForwardIter, class _Predicate>
   1.446  _ForwardIter partition(_ForwardIter __first, _ForwardIter __last, _Predicate   __pred);
   1.447  
   1.448 -
   1.449  template <class _ForwardIter, class _Predicate>
   1.450 -_ForwardIter 
   1.451 +_ForwardIter
   1.452  stable_partition(_ForwardIter __first, _ForwardIter __last, _Predicate __pred);
   1.453  
   1.454 -// sort() and its auxiliary functions. 
   1.455 +// sort() and its auxiliary functions.
   1.456 +_STLP_MOVE_TO_PRIV_NAMESPACE
   1.457  
   1.458  template <class _Size>
   1.459  inline _Size __lg(_Size __n) {
   1.460 @@ -426,6 +427,8 @@
   1.461    return __k;
   1.462  }
   1.463  
   1.464 +_STLP_MOVE_TO_STD_NAMESPACE
   1.465 +
   1.466  template <class _RandomAccessIter>
   1.467  void sort(_RandomAccessIter __first, _RandomAccessIter __last);
   1.468  template <class _RandomAccessIter, class _Compare>
   1.469 @@ -434,22 +437,21 @@
   1.470  // stable_sort() and its auxiliary functions.
   1.471  template <class _RandomAccessIter>
   1.472  void stable_sort(_RandomAccessIter __first,
   1.473 -		 _RandomAccessIter __last);
   1.474 +                 _RandomAccessIter __last);
   1.475  
   1.476  template <class _RandomAccessIter, class _Compare>
   1.477  void stable_sort(_RandomAccessIter __first,
   1.478 -		 _RandomAccessIter __last, _Compare __comp);
   1.479 +                 _RandomAccessIter __last, _Compare __comp);
   1.480  
   1.481  // partial_sort, partial_sort_copy, and auxiliary functions.
   1.482  
   1.483  template <class _RandomAccessIter>
   1.484 -void 
   1.485 -partial_sort(_RandomAccessIter __first,_RandomAccessIter __middle, _RandomAccessIter __last);
   1.486 +void partial_sort(_RandomAccessIter __first, _RandomAccessIter __middle,
   1.487 +                  _RandomAccessIter __last);
   1.488  
   1.489  template <class _RandomAccessIter, class _Compare>
   1.490 -void 
   1.491 -partial_sort(_RandomAccessIter __first,_RandomAccessIter __middle, 
   1.492 -             _RandomAccessIter __last, _Compare __comp);
   1.493 +void partial_sort(_RandomAccessIter __first,_RandomAccessIter __middle,
   1.494 +                  _RandomAccessIter __last, _Compare __comp);
   1.495  
   1.496  template <class _InputIter, class _RandomAccessIter>
   1.497  _RandomAccessIter
   1.498 @@ -462,8 +464,7 @@
   1.499                    _RandomAccessIter __result_first,
   1.500                    _RandomAccessIter __result_last, _Compare __comp);
   1.501  
   1.502 -// nth_element() and its auxiliary functions.  
   1.503 -
   1.504 +// nth_element() and its auxiliary functions.
   1.505  template <class _RandomAccessIter>
   1.506  void nth_element(_RandomAccessIter __first, _RandomAccessIter __nth,
   1.507                   _RandomAccessIter __last);
   1.508 @@ -473,97 +474,114 @@
   1.509                   _RandomAccessIter __last, _Compare __comp);
   1.510  
   1.511  // auxiliary class for lower_bound, etc.
   1.512 +_STLP_MOVE_TO_PRIV_NAMESPACE
   1.513 +
   1.514  template <class _T1, class _T2>
   1.515  struct __less_2 {
   1.516 -  bool operator() (const _T1& __x, const _T2 __y) const { return __x < __y ; } 
   1.517 +  bool operator() (const _T1& __x, const _T2& __y) const { return __x < __y ; }
   1.518  };
   1.519  
   1.520  template <class _T1, class _T2>
   1.521  __less_2<_T1,_T2> __less2(_T1*, _T2* ) { return __less_2<_T1, _T2>(); }
   1.522  
   1.523 -#ifdef _STLP_FUNCTION_PARTIAL_ORDER
   1.524 +#if defined (_STLP_FUNCTION_PARTIAL_ORDER)
   1.525  template <class _Tp>
   1.526  less<_Tp> __less2(_Tp*, _Tp* ) { return less<_Tp>(); }
   1.527  #endif
   1.528  
   1.529 +_STLP_MOVE_TO_STD_NAMESPACE
   1.530 +
   1.531  // Binary search (lower_bound, upper_bound, equal_range, binary_search).
   1.532 -
   1.533  template <class _ForwardIter, class _Tp>
   1.534  inline _ForwardIter lower_bound(_ForwardIter __first, _ForwardIter __last,
   1.535                                     const _Tp& __val) {
   1.536 -  _STLP_DEBUG_CHECK(__check_range(__first, __last))
   1.537 -    return __lower_bound(__first, __last, __val, 
   1.538 -			 __less2(_STLP_VALUE_TYPE(__first, _ForwardIter), (_Tp*)0),
   1.539 -			 _STLP_DISTANCE_TYPE(__first, _ForwardIter));
   1.540 +  _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
   1.541 +  return _STLP_PRIV __lower_bound(__first, __last, __val,
   1.542 +                                  _STLP_PRIV __less2(_STLP_VALUE_TYPE(__first, _ForwardIter), (_Tp*)0),
   1.543 +                                  _STLP_PRIV __less2((_Tp*)0, _STLP_VALUE_TYPE(__first, _ForwardIter)),
   1.544 +                                  _STLP_DISTANCE_TYPE(__first, _ForwardIter));
   1.545  }
   1.546  
   1.547  template <class _ForwardIter, class _Tp, class _Compare>
   1.548  inline _ForwardIter lower_bound(_ForwardIter __first, _ForwardIter __last,
   1.549                                  const _Tp& __val, _Compare __comp) {
   1.550 -  _STLP_DEBUG_CHECK(__check_range(__first, __last))
   1.551 -  return __lower_bound(__first, __last, __val, __comp, _STLP_DISTANCE_TYPE(__first, _ForwardIter));
   1.552 +  _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
   1.553 +  return _STLP_PRIV __lower_bound(__first, __last, __val, __comp, __comp,
   1.554 +                                  _STLP_DISTANCE_TYPE(__first, _ForwardIter));
   1.555  }
   1.556  
   1.557 -template <class _ForwardIter, class _Tp, class _Compare, class _Distance>
   1.558 -_ForwardIter __upper_bound(_ForwardIter __first, _ForwardIter __last,
   1.559 -                           const _Tp& __val, _Compare __comp, _Distance*);
   1.560 +_STLP_MOVE_TO_PRIV_NAMESPACE
   1.561 +
   1.562 +template <class _ForwardIter, class _Tp, class _Compare1, class _Compare2, class _Distance>
   1.563 +_ForwardIter __upper_bound(_ForwardIter __first, _ForwardIter __last, const _Tp& __val,
   1.564 +                           _Compare1 __comp1, _Compare2 __comp2, _Distance*);
   1.565 +
   1.566 +_STLP_MOVE_TO_STD_NAMESPACE
   1.567  
   1.568  template <class _ForwardIter, class _Tp>
   1.569  inline _ForwardIter upper_bound(_ForwardIter __first, _ForwardIter __last,
   1.570                                  const _Tp& __val) {
   1.571 -  _STLP_DEBUG_CHECK(__check_range(__first, __last))
   1.572 -  return __upper_bound(__first, __last, __val, 
   1.573 -		       __less2(_STLP_VALUE_TYPE(__first, _ForwardIter), (_Tp*)0),
   1.574 -                       _STLP_DISTANCE_TYPE(__first, _ForwardIter));
   1.575 +  _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
   1.576 +  return _STLP_PRIV __upper_bound(__first, __last, __val,
   1.577 +                                  _STLP_PRIV __less2(_STLP_VALUE_TYPE(__first, _ForwardIter), (_Tp*)0),
   1.578 +                                  _STLP_PRIV __less2((_Tp*)0, _STLP_VALUE_TYPE(__first, _ForwardIter)),
   1.579 +                                  _STLP_DISTANCE_TYPE(__first, _ForwardIter));
   1.580  }
   1.581  
   1.582  template <class _ForwardIter, class _Tp, class _Compare>
   1.583  inline _ForwardIter upper_bound(_ForwardIter __first, _ForwardIter __last,
   1.584                                  const _Tp& __val, _Compare __comp) {
   1.585 -  _STLP_DEBUG_CHECK(__check_range(__first, __last))
   1.586 -  return __upper_bound(__first, __last, __val, __comp,
   1.587 -                       _STLP_DISTANCE_TYPE(__first, _ForwardIter));
   1.588 +  _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
   1.589 +  return _STLP_PRIV __upper_bound(__first, __last, __val, __comp, __comp,
   1.590 +                                  _STLP_DISTANCE_TYPE(__first, _ForwardIter));
   1.591  }
   1.592  
   1.593 -template <class _ForwardIter, class _Tp, class _Compare, class _Distance>
   1.594 +_STLP_MOVE_TO_PRIV_NAMESPACE
   1.595 +
   1.596 +template <class _ForwardIter, class _Tp, class _Compare1, class _Compare2, class _Distance>
   1.597  pair<_ForwardIter, _ForwardIter>
   1.598  __equal_range(_ForwardIter __first, _ForwardIter __last, const _Tp& __val,
   1.599 -              _Compare __comp, _Distance*);
   1.600 +              _Compare1 __comp1, _Compare2 __comp2, _Distance*);
   1.601 +
   1.602 +_STLP_MOVE_TO_STD_NAMESPACE
   1.603  
   1.604  template <class _ForwardIter, class _Tp>
   1.605  inline pair<_ForwardIter, _ForwardIter>
   1.606  equal_range(_ForwardIter __first, _ForwardIter __last, const _Tp& __val) {
   1.607 -  _STLP_DEBUG_CHECK(__check_range(__first, __last))
   1.608 -  return __equal_range(__first, __last, __val,  
   1.609 -		       __less2(_STLP_VALUE_TYPE(__first, _ForwardIter), (_Tp*)0),
   1.610 -                       _STLP_DISTANCE_TYPE(__first, _ForwardIter));
   1.611 +  _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
   1.612 +  return _STLP_PRIV __equal_range(__first, __last, __val,
   1.613 +                                  _STLP_PRIV __less2(_STLP_VALUE_TYPE(__first, _ForwardIter), (_Tp*)0),
   1.614 +                                  _STLP_PRIV __less2((_Tp*)0, _STLP_VALUE_TYPE(__first, _ForwardIter)),
   1.615 +                                  _STLP_DISTANCE_TYPE(__first, _ForwardIter));
   1.616  }
   1.617  
   1.618  template <class _ForwardIter, class _Tp, class _Compare>
   1.619  inline pair<_ForwardIter, _ForwardIter>
   1.620  equal_range(_ForwardIter __first, _ForwardIter __last, const _Tp& __val,
   1.621              _Compare __comp) {
   1.622 -  _STLP_DEBUG_CHECK(__check_range(__first, __last))
   1.623 -  return __equal_range(__first, __last, __val, __comp,
   1.624 -                       _STLP_DISTANCE_TYPE(__first, _ForwardIter));
   1.625 -} 
   1.626 +  _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
   1.627 +  return _STLP_PRIV __equal_range(__first, __last, __val, __comp, __comp,
   1.628 +                                  _STLP_DISTANCE_TYPE(__first, _ForwardIter));
   1.629 +}
   1.630  
   1.631  template <class _ForwardIter, class _Tp>
   1.632  inline bool binary_search(_ForwardIter __first, _ForwardIter __last,
   1.633                     const _Tp& __val) {
   1.634 -  _STLP_DEBUG_CHECK(__check_range(__first, __last))
   1.635 -  _ForwardIter __i = __lower_bound(__first, __last, __val, 
   1.636 -                                   __less2(_STLP_VALUE_TYPE(__first, _ForwardIter), (_Tp*)0),
   1.637 -                                   _STLP_DISTANCE_TYPE(__first, _ForwardIter));
   1.638 +  _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
   1.639 +  _ForwardIter __i = _STLP_PRIV __lower_bound(__first, __last, __val,
   1.640 +                                              _STLP_PRIV __less2(_STLP_VALUE_TYPE(__first, _ForwardIter), (_Tp*)0),
   1.641 +                                              _STLP_PRIV __less2((_Tp*)0, _STLP_VALUE_TYPE(__first, _ForwardIter)),
   1.642 +                                              _STLP_DISTANCE_TYPE(__first, _ForwardIter));
   1.643    return __i != __last && !(__val < *__i);
   1.644  }
   1.645  
   1.646  template <class _ForwardIter, class _Tp, class _Compare>
   1.647  inline bool binary_search(_ForwardIter __first, _ForwardIter __last,
   1.648 -                   const _Tp& __val,
   1.649 -                   _Compare __comp) {
   1.650 -  _STLP_DEBUG_CHECK(__check_range(__first, __last))
   1.651 -  _ForwardIter __i = __lower_bound(__first, __last, __val, __comp, _STLP_DISTANCE_TYPE(__first, _ForwardIter));
   1.652 +                          const _Tp& __val,
   1.653 +                          _Compare __comp) {
   1.654 +  _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
   1.655 +  _ForwardIter __i = _STLP_PRIV __lower_bound(__first, __last, __val, __comp, __comp,
   1.656 +                                              _STLP_DISTANCE_TYPE(__first, _ForwardIter));
   1.657    return __i != __last && !__comp(__val, *__i);
   1.658  }
   1.659  
   1.660 @@ -573,7 +591,7 @@
   1.661  _OutputIter merge(_InputIter1 __first1, _InputIter1 __last1,
   1.662                    _InputIter2 __first2, _InputIter2 __last2,
   1.663                    _OutputIter __result);
   1.664 - 
   1.665 +
   1.666  template <class _InputIter1, class _InputIter2, class _OutputIter,
   1.667            class _Compare>
   1.668  _OutputIter merge(_InputIter1 __first1, _InputIter1 __last1,
   1.669 @@ -581,18 +599,18 @@
   1.670                    _OutputIter __result, _Compare __comp);
   1.671  
   1.672  
   1.673 -// inplace_merge and its auxiliary functions. 
   1.674 +// inplace_merge and its auxiliary functions.
   1.675  
   1.676  
   1.677  template <class _BidirectionalIter>
   1.678  void inplace_merge(_BidirectionalIter __first,
   1.679 -		   _BidirectionalIter __middle,
   1.680 -		   _BidirectionalIter __last) ;
   1.681 +                   _BidirectionalIter __middle,
   1.682 +                   _BidirectionalIter __last) ;
   1.683  
   1.684  template <class _BidirectionalIter, class _Compare>
   1.685  void inplace_merge(_BidirectionalIter __first,
   1.686 -		   _BidirectionalIter __middle,
   1.687 -		   _BidirectionalIter __last, _Compare __comp);
   1.688 +                   _BidirectionalIter __middle,
   1.689 +                   _BidirectionalIter __last, _Compare __comp);
   1.690  
   1.691  // Set algorithms: includes, set_union, set_intersection, set_difference,
   1.692  // set_symmetric_difference.  All of these algorithms have the precondition
   1.693 @@ -606,7 +624,7 @@
   1.694  template <class _InputIter1, class _InputIter2, class _Compare>
   1.695  bool includes(_InputIter1 __first1, _InputIter1 __last1,
   1.696                _InputIter2 __first2, _InputIter2 __last2, _Compare __comp);
   1.697 - 
   1.698 +
   1.699  template <class _InputIter1, class _InputIter2, class _OutputIter>
   1.700  _OutputIter set_union(_InputIter1 __first1, _InputIter1 __last1,
   1.701                        _InputIter2 __first2, _InputIter2 __last2,
   1.702 @@ -636,14 +654,14 @@
   1.703                             _InputIter2 __first2, _InputIter2 __last2,
   1.704                             _OutputIter __result);
   1.705  
   1.706 -template <class _InputIter1, class _InputIter2, class _OutputIter, 
   1.707 +template <class _InputIter1, class _InputIter2, class _OutputIter,
   1.708            class _Compare>
   1.709  _OutputIter set_difference(_InputIter1 __first1, _InputIter1 __last1,
   1.710 -                           _InputIter2 __first2, _InputIter2 __last2, 
   1.711 +                           _InputIter2 __first2, _InputIter2 __last2,
   1.712                             _OutputIter __result, _Compare __comp);
   1.713  
   1.714  template <class _InputIter1, class _InputIter2, class _OutputIter>
   1.715 -_OutputIter 
   1.716 +_OutputIter
   1.717  set_symmetric_difference(_InputIter1 __first1, _InputIter1 __last1,
   1.718                           _InputIter2 __first2, _InputIter2 __last2,
   1.719                           _OutputIter __result);
   1.720 @@ -651,7 +669,7 @@
   1.721  
   1.722  template <class _InputIter1, class _InputIter2, class _OutputIter,
   1.723            class _Compare>
   1.724 -_OutputIter 
   1.725 +_OutputIter
   1.726  set_symmetric_difference(_InputIter1 __first1, _InputIter1 __last1,
   1.727                           _InputIter2 __first2, _InputIter2 __last2,
   1.728                           _OutputIter __result,
   1.729 @@ -674,7 +692,7 @@
   1.730  _ForwardIter min_element(_ForwardIter __first, _ForwardIter __last,
   1.731                              _Compare __comp);
   1.732  
   1.733 -// next_permutation and prev_permutation, with and without an explicitly 
   1.734 +// next_permutation and prev_permutation, with and without an explicitly
   1.735  // supplied comparison function.
   1.736  
   1.737  template <class _BidirectionalIter>
   1.738 @@ -693,8 +711,7 @@
   1.739  bool prev_permutation(_BidirectionalIter __first, _BidirectionalIter __last,
   1.740                        _Compare __comp);
   1.741  
   1.742 -# ifndef _STLP_NO_EXTENSIONS
   1.743 -
   1.744 +#if !defined (_STLP_NO_EXTENSIONS)
   1.745  // is_heap, a predicate testing whether or not a range is
   1.746  // a heap.  This function is an extension, not part of the C++
   1.747  // standard.
   1.748 @@ -704,33 +721,36 @@
   1.749  
   1.750  template <class _RandomAccessIter, class _StrictWeakOrdering>
   1.751  bool is_heap(_RandomAccessIter __first, _RandomAccessIter __last,
   1.752 -	     _StrictWeakOrdering __comp);
   1.753 -
   1.754 +             _StrictWeakOrdering __comp);
   1.755  
   1.756  // is_sorted, a predicated testing whether a range is sorted in
   1.757  // nondescending order.  This is an extension, not part of the C++
   1.758  // standard.
   1.759 +_STLP_MOVE_TO_PRIV_NAMESPACE
   1.760 +
   1.761  template <class _ForwardIter, class _StrictWeakOrdering>
   1.762  bool __is_sorted(_ForwardIter __first, _ForwardIter __last,
   1.763                   _StrictWeakOrdering __comp);
   1.764  
   1.765 +_STLP_MOVE_TO_STD_NAMESPACE
   1.766  template <class _ForwardIter>
   1.767  inline bool is_sorted(_ForwardIter __first, _ForwardIter __last) {
   1.768 -  return __is_sorted(__first, __last, __less(_STLP_VALUE_TYPE(__first, _ForwardIter)));
   1.769 +  return _STLP_PRIV __is_sorted(__first, __last,
   1.770 +                                _STLP_PRIV __less(_STLP_VALUE_TYPE(__first, _ForwardIter)));
   1.771  }
   1.772  
   1.773  template <class _ForwardIter, class _StrictWeakOrdering>
   1.774  inline bool is_sorted(_ForwardIter __first, _ForwardIter __last,
   1.775                        _StrictWeakOrdering __comp) {
   1.776 -  return __is_sorted(__first, __last, __comp);
   1.777 +  return _STLP_PRIV __is_sorted(__first, __last, __comp);
   1.778  }
   1.779 -# endif
   1.780 +#endif
   1.781  
   1.782  _STLP_END_NAMESPACE
   1.783  
   1.784 -# if !defined (_STLP_LINK_TIME_INSTANTIATION)
   1.785 +#if !defined (_STLP_LINK_TIME_INSTANTIATION)
   1.786  #  include <stl/_algo.c>
   1.787 -# endif
   1.788 +#endif
   1.789  
   1.790  #endif /* _STLP_INTERNAL_ALGO_H */
   1.791