1.1 --- a/epoc32/include/stdapis/stlportv5/stl/_algobase.h Wed Mar 31 12:27:01 2010 +0100
1.2 +++ b/epoc32/include/stdapis/stlportv5/stl/_algobase.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 @@ -27,65 +27,128 @@
1.20 * You should not attempt to use it directly.
1.21 */
1.22
1.23 -
1.24 #ifndef _STLP_INTERNAL_ALGOBASE_H
1.25 #define _STLP_INTERNAL_ALGOBASE_H
1.26
1.27 -# if ! defined (_STLP_CSTDDEF)
1.28 -# include <cstddef>
1.29 -# endif
1.30 +#ifndef _STLP_INTERNAL_CSTDDEF
1.31 +# include <stl/_cstddef.h>
1.32 +#endif
1.33
1.34 -#ifndef _STLP_CSTRING
1.35 -# include <cstring>
1.36 +#ifndef _STLP_INTERNAL_CSTRING
1.37 +# include <stl/_cstring.h>
1.38 #endif
1.39
1.40 #ifndef _STLP_CLIMITS
1.41 -# include <climits>
1.42 +# include <climits>
1.43 #endif
1.44
1.45 -# if ! defined (_STLP_CSTDLIB)
1.46 -# include <cstdlib>
1.47 -# endif
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 +#ifndef _STLP_INTERNAL_PAIR_H
1.54 # include <stl/_pair.h>
1.55 -# endif
1.56 +#endif
1.57
1.58 #ifndef _STLP_INTERNAL_ITERATOR_BASE_H
1.59 -# include <stl/_iterator_base.h>
1.60 +# include <stl/_iterator_base.h>
1.61 +#endif
1.62 +
1.63 +#ifndef _STLP_TYPE_TRAITS_H
1.64 +# include <stl/type_traits.h>
1.65 #endif
1.66
1.67 _STLP_BEGIN_NAMESPACE
1.68 -// swap and iter_swap
1.69 +
1.70 +#if defined(_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined(_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
1.71 +_STLP_MOVE_TO_PRIV_NAMESPACE
1.72 template <class _Tp>
1.73 -inline void swap(_Tp& __a, _Tp& __b) {
1.74 +inline void __swap_aux(_Tp& __a, _Tp& __b, const __true_type& /*SwapImplemented*/) {
1.75 + __a.swap(__b);
1.76 +}
1.77 +
1.78 +template <class _Tp>
1.79 +inline void __swap_aux(_Tp& __a, _Tp& __b, const __false_type& /*SwapImplemented*/) {
1.80 _Tp __tmp = __a;
1.81 __a = __b;
1.82 __b = __tmp;
1.83 }
1.84 +_STLP_MOVE_TO_STD_NAMESPACE
1.85 +#endif /* _STLP_USE_PARTIAL_SPEC_WORKAROUND */
1.86 +
1.87 +// swap and iter_swap
1.88 +template <class _Tp>
1.89 +inline void swap(_Tp& __a, _Tp& __b) {
1.90 +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
1.91 +# if !defined(__BORLANDC__)
1.92 + typedef typename _SwapImplemented<_Tp>::_Ret _Implemented;
1.93 +# else
1.94 + enum { _Is = _SwapImplemented<_Tp>::_Is };
1.95 + typedef typename __bool2type<_Is>::_Ret _Implemented;
1.96 +# endif
1.97 + _STLP_PRIV __swap_aux(__a, __b, _Implemented());
1.98 +#else
1.99 + _Tp __tmp = __a;
1.100 + __a = __b;
1.101 + __b = __tmp;
1.102 +#endif /* _STLP_USE_PARTIAL_SPEC_WORKAROUND */
1.103 +}
1.104 +
1.105 +_STLP_MOVE_TO_PRIV_NAMESPACE
1.106 +
1.107 +template <class _ForwardIter1, class _ForwardIter2, class _Value>
1.108 +inline void __iter_swap_aux_aux(_ForwardIter1& __i1, _ForwardIter2& __i2, _Value *) {
1.109 + _Value tmp = *__i1;
1.110 + *__i1 = *__i2;
1.111 + *__i2 = tmp;
1.112 +}
1.113 +
1.114 +template <class _ForwardIter1, class _ForwardIter2>
1.115 +inline void __iter_swap_aux(_ForwardIter1& __i1, _ForwardIter2& __i2, const __true_type& /*OKToSwap*/) {
1.116 + swap(*__i1, *__i2);
1.117 +}
1.118 +
1.119 +template <class _ForwardIter1, class _ForwardIter2>
1.120 +inline void __iter_swap_aux(_ForwardIter1& __i1, _ForwardIter2& __i2, const __false_type& /*OKToSwap*/) {
1.121 + __iter_swap_aux_aux( __i1, __i2, _STLP_VALUE_TYPE(__i1,_ForwardIter1) );
1.122 +}
1.123 +
1.124 +_STLP_MOVE_TO_STD_NAMESPACE
1.125
1.126 template <class _ForwardIter1, class _ForwardIter2>
1.127 inline void iter_swap(_ForwardIter1 __i1, _ForwardIter2 __i2) {
1.128 - swap(*__i1, *__i2);
1.129 + // swap(*__i1, *__i2);
1.130 + _STLP_PRIV __iter_swap_aux( __i1, __i2, _IsOKToSwap(_STLP_VALUE_TYPE(__i1, _ForwardIter1), _STLP_VALUE_TYPE(__i2, _ForwardIter2),
1.131 + _STLP_IS_REF_TYPE_REAL_REF(__i1, _ForwardIter1),
1.132 + _STLP_IS_REF_TYPE_REAL_REF(__i2, _ForwardIter2))._Answer());
1.133 }
1.134
1.135 //--------------------------------------------------
1.136 // min and max
1.137
1.138 -# if !defined (__BORLANDC__) || defined (_STLP_USE_OWN_NAMESPACE)
1.139 +#if !defined (__BORLANDC__) || defined (_STLP_USE_OWN_NAMESPACE)
1.140 +# if (defined (__BORLANDC__) && (__BORLANDC__ < 0x580)) && !defined (__STDC__)
1.141 +//In not ANSI mode Borland import min/max in global namespace which conflict
1.142 +//with STLport min/max when user does a 'using namespace std' in its code
1.143 +//(see test/unit/alg_test.cpp). To avoid this clash we simply import Borland min/max
1.144 +//in STLport namespace.
1.145 +using _STLP_VENDOR_STD::min;
1.146 +using _STLP_VENDOR_STD::max;
1.147 +# else
1.148 template <class _Tp>
1.149 inline const _Tp& (min)(const _Tp& __a, const _Tp& __b) { return __b < __a ? __b : __a; }
1.150 template <class _Tp>
1.151 inline const _Tp& (max)(const _Tp& __a, const _Tp& __b) { return __a < __b ? __b : __a; }
1.152 -#endif /* __BORLANDC__ */
1.153 +# endif
1.154 +#endif
1.155
1.156 -# if defined (__BORLANDC__) && ( __BORLANDC__ < 0x530 || defined (_STLP_USE_OWN_NAMESPACE))
1.157 +# if defined (__BORLANDC__) && defined (_STLP_USE_OWN_NAMESPACE)
1.158 inline unsigned long (min) (unsigned long __a, unsigned long __b) { return __b < __a ? __b : __a; }
1.159 inline unsigned long (max) (unsigned long __a, unsigned long __b) { return __a < __b ? __b : __a; }
1.160 # endif
1.161
1.162 template <class _Tp, class _Compare>
1.163 -inline const _Tp& (min)(const _Tp& __a, const _Tp& __b, _Compare __comp) {
1.164 +inline const _Tp& (min)(const _Tp& __a, const _Tp& __b, _Compare __comp) {
1.165 return __comp(__b, __a) ? __b : __a;
1.166 }
1.167
1.168 @@ -103,33 +166,33 @@
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,
1.177 - const input_iterator_tag &, _Distance*) {
1.178 + _OutputIter __result, const input_iterator_tag &, _Distance*) {
1.179 for ( ; __first != __last; ++__result, ++__first)
1.180 *__result = *__first;
1.181 return __result;
1.182 }
1.183
1.184 -# if defined (_STLP_NONTEMPL_BASE_MATCH_BUG)
1.185 +#if defined (_STLP_NONTEMPL_BASE_MATCH_BUG)
1.186 template <class _InputIter, class _OutputIter, class _Distance>
1.187 inline _OutputIter __copy(_InputIter __first, _InputIter __last,
1.188 - _OutputIter __result, const forward_iterator_tag &, _Distance* ) {
1.189 + _OutputIter __result, const forward_iterator_tag &, _Distance* ) {
1.190 for ( ; __first != __last; ++__result, ++__first)
1.191 *__result = *__first;
1.192 return __result;
1.193 }
1.194
1.195 -
1.196 template <class _InputIter, class _OutputIter, class _Distance>
1.197 inline _OutputIter __copy(_InputIter __first, _InputIter __last,
1.198 - _OutputIter __result, const bidirectional_iterator_tag &, _Distance* __dis) {
1.199 + _OutputIter __result, const bidirectional_iterator_tag &, _Distance* ) {
1.200 for ( ; __first != __last; ++__result, ++__first)
1.201 *__result = *__first;
1.202 return __result;
1.203 }
1.204 -# endif
1.205 +#endif
1.206
1.207 template <class _RandomAccessIter, class _OutputIter, class _Distance>
1.208 inline _OutputIter
1.209 @@ -145,34 +208,31 @@
1.210
1.211 inline void*
1.212 __copy_trivial(const void* __first, const void* __last, void* __result) {
1.213 - return (__last == __first) ? __result :
1.214 - ((char*)memmove(__result, __first, ((const char*)__last - (const char*)__first))) +
1.215 - ((const char*)__last - (const char*)__first);
1.216 + size_t __n = (const char*)__last - (const char*)__first;
1.217 + return __n ? (void *)((char*)memmove(__result, __first, __n) + __n) : __result;
1.218 }
1.219
1.220 //--------------------------------------------------
1.221 // copy_backward auxiliary functions
1.222
1.223 -template <class _BidirectionalIter1, class _BidirectionalIter2,
1.224 +template <class _BidirectionalIter1, class _BidirectionalIter2,
1.225 class _Distance>
1.226 -inline _BidirectionalIter2 __copy_backward(_BidirectionalIter1 __first,
1.227 - _BidirectionalIter1 __last,
1.228 +inline _BidirectionalIter2 __copy_backward(_BidirectionalIter1 __first,
1.229 + _BidirectionalIter1 __last,
1.230 _BidirectionalIter2 __result,
1.231 const bidirectional_iterator_tag &,
1.232 - _Distance*)
1.233 -{
1.234 + _Distance*) {
1.235 while (__first != __last)
1.236 *--__result = *--__last;
1.237 return __result;
1.238 }
1.239
1.240 template <class _RandomAccessIter, class _BidirectionalIter, class _Distance>
1.241 -inline _BidirectionalIter __copy_backward(_RandomAccessIter __first,
1.242 - _RandomAccessIter __last,
1.243 +inline _BidirectionalIter __copy_backward(_RandomAccessIter __first,
1.244 + _RandomAccessIter __last,
1.245 _BidirectionalIter __result,
1.246 const random_access_iterator_tag &,
1.247 - _Distance*)
1.248 -{
1.249 + _Distance*) {
1.250 for (_Distance __n = __last - __first; __n > 0; --__n)
1.251 *--__result = *--__last;
1.252 return __result;
1.253 @@ -185,44 +245,53 @@
1.254 }
1.255
1.256 template <class _InputIter, class _OutputIter>
1.257 -inline _OutputIter __copy_ptrs(_InputIter __first, _InputIter __last, _OutputIter __result, const __false_type&) {
1.258 - return __copy(__first, __last, __result,
1.259 - _STLP_ITERATOR_CATEGORY(__first, _InputIter),
1.260 - _STLP_DISTANCE_TYPE(__first, _InputIter));
1.261 +inline _OutputIter __copy_ptrs(_InputIter __first, _InputIter __last, _OutputIter __result,
1.262 + const __false_type& /*IsOKToMemCpy*/) {
1.263 + return __copy(__first, __last, __result, random_access_iterator_tag(), (ptrdiff_t*)0);
1.264 }
1.265 template <class _InputIter, class _OutputIter>
1.266 -inline _OutputIter __copy_ptrs(_InputIter __first, _InputIter __last, _OutputIter __result, const __true_type&) {
1.267 -// we know they all pointers, so this cast is OK
1.268 +inline _OutputIter __copy_ptrs(_InputIter __first, _InputIter __last, _OutputIter __result,
1.269 + const __true_type& /*IsOKToMemCpy*/) {
1.270 + // we know they all pointers, so this cast is OK
1.271 // return (_OutputIter)__copy_trivial(&(*__first), &(*__last), &(*__result));
1.272 return (_OutputIter)__copy_trivial(__first, __last, __result);
1.273 }
1.274
1.275 template <class _InputIter, class _OutputIter>
1.276 -inline _OutputIter __copy_aux(_InputIter __first, _InputIter __last, _OutputIter __result, const __true_type&) {
1.277 - return __copy_ptrs(__first, __last, __result,
1.278 - _IsOKToMemCpy(_STLP_VALUE_TYPE(__first, _InputIter),
1.279 - _STLP_VALUE_TYPE(__result, _OutputIter))._Ret());
1.280 +inline _OutputIter __copy_aux(_InputIter __first, _InputIter __last, _OutputIter __result,
1.281 + const __true_type& /*BothPtrType*/) {
1.282 + return __copy_ptrs(__first, __last, __result,
1.283 + _UseTrivialCopy(_STLP_VALUE_TYPE(__first, _InputIter),
1.284 + _STLP_VALUE_TYPE(__result, _OutputIter))._Answer());
1.285 }
1.286
1.287 template <class _InputIter, class _OutputIter>
1.288 -inline _OutputIter __copy_aux(_InputIter __first, _InputIter __last, _OutputIter __result, const __false_type&) {
1.289 - return __copy(__first, __last, __result,
1.290 - _STLP_ITERATOR_CATEGORY(__first, _InputIter), _STLP_DISTANCE_TYPE(__first, _InputIter));
1.291 +inline _OutputIter __copy_aux(_InputIter __first, _InputIter __last, _OutputIter __result,
1.292 + const __false_type& /*BothPtrType*/) {
1.293 + return __copy(__first, __last, __result,
1.294 + _STLP_ITERATOR_CATEGORY(__first, _InputIter),
1.295 + _STLP_DISTANCE_TYPE(__first, _InputIter));
1.296 }
1.297
1.298 +_STLP_MOVE_TO_STD_NAMESPACE
1.299 +
1.300 template <class _InputIter, class _OutputIter>
1.301 inline _OutputIter copy(_InputIter __first, _InputIter __last, _OutputIter __result) {
1.302 - _STLP_DEBUG_CHECK(__check_range(__first, __last))
1.303 - return __copy_aux(__first, __last, __result, _BothPtrType< _InputIter, _OutputIter> :: _Ret());
1.304 + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
1.305 + return _STLP_PRIV __copy_aux(__first, __last, __result, _BothPtrType< _InputIter, _OutputIter>::_Answer());
1.306 }
1.307
1.308 +_STLP_MOVE_TO_PRIV_NAMESPACE
1.309 +
1.310 template <class _InputIter, class _OutputIter>
1.311 -inline _OutputIter __copy_backward_ptrs(_InputIter __first, _InputIter __last, _OutputIter __result, const __false_type&) {
1.312 +inline _OutputIter __copy_backward_ptrs(_InputIter __first, _InputIter __last,
1.313 + _OutputIter __result, const __false_type& /*TrivialAssignment*/) {
1.314 return __copy_backward(__first, __last, __result, _STLP_ITERATOR_CATEGORY(__first, _InputIter), _STLP_DISTANCE_TYPE(__first, _InputIter));
1.315 }
1.316 template <class _InputIter, class _OutputIter>
1.317 -inline _OutputIter __copy_backward_ptrs(_InputIter __first, _InputIter __last, _OutputIter __result, const __true_type&) {
1.318 - return (_OutputIter)__copy_trivial_backward(__first, __last, __result);
1.319 +inline _OutputIter __copy_backward_ptrs(_InputIter __first, _InputIter __last,
1.320 + _OutputIter __result, const __true_type& /*TrivialAssignment*/) {
1.321 + return (_OutputIter)__copy_trivial_backward(__first, __last, __result);
1.322 }
1.323
1.324 template <class _InputIter, class _OutputIter>
1.325 @@ -232,28 +301,30 @@
1.326
1.327 template <class _InputIter, class _OutputIter>
1.328 inline _OutputIter __copy_backward_aux(_InputIter __first, _InputIter __last, _OutputIter __result, const __true_type&) {
1.329 - return __copy_backward_ptrs(__first, __last, __result,
1.330 - _IsOKToMemCpy(_STLP_VALUE_TYPE(__first, _InputIter),
1.331 - _STLP_VALUE_TYPE(__result, _OutputIter))._Ret());
1.332 + return __copy_backward_ptrs(__first, __last, __result,
1.333 + _UseTrivialCopy(_STLP_VALUE_TYPE(__first, _InputIter),
1.334 + _STLP_VALUE_TYPE(__result, _OutputIter))._Answer());
1.335 }
1.336
1.337 +_STLP_MOVE_TO_STD_NAMESPACE
1.338 +
1.339 template <class _InputIter, class _OutputIter>
1.340 inline _OutputIter copy_backward(_InputIter __first, _InputIter __last, _OutputIter __result) {
1.341 - _STLP_DEBUG_CHECK(__check_range(__first, __last))
1.342 - return __copy_backward_aux(__first, __last, __result, _BothPtrType< _InputIter, _OutputIter> :: _Ret() );
1.343 + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
1.344 + return _STLP_PRIV __copy_backward_aux(__first, __last, __result, _BothPtrType< _InputIter, _OutputIter>::_Answer() );
1.345 }
1.346
1.347 -#if ! defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && ! defined ( _STLP_SIMULATE_PARTIAL_SPEC_FOR_TYPE_TRAITS )
1.348 -#define _STLP_DECLARE_COPY_TRIVIAL(_Tp) \
1.349 -inline _Tp* copy(const _Tp* __first, const _Tp* __last, _Tp* __result) \
1.350 -{ return (_Tp*)__copy_trivial(__first, __last, __result); } \
1.351 +#if !defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && !defined (_STLP_SIMULATE_PARTIAL_SPEC_FOR_TYPE_TRAITS)
1.352 +# define _STLP_DECLARE_COPY_TRIVIAL(_Tp) \
1.353 +inline _Tp* copy(const _Tp* __first, const _Tp* __last, _Tp* __result) \
1.354 +{ return (_Tp*)__copy_trivial(__first, __last, __result); } \
1.355 inline _Tp* copy_backward(const _Tp* __first, const _Tp* __last, _Tp* __result) \
1.356 { return (_Tp*)__copy_trivial_backward(__first, __last, __result); }
1.357
1.358 _STLP_DECLARE_COPY_TRIVIAL(char)
1.359 -# ifndef _STLP_NO_SIGNED_BUILTINS
1.360 +# if !defined (_STLP_NO_SIGNED_BUILTINS)
1.361 _STLP_DECLARE_COPY_TRIVIAL(signed char)
1.362 -# endif
1.363 +# endif
1.364 _STLP_DECLARE_COPY_TRIVIAL(unsigned char)
1.365 _STLP_DECLARE_COPY_TRIVIAL(short)
1.366 _STLP_DECLARE_COPY_TRIVIAL(unsigned short)
1.367 @@ -261,29 +332,32 @@
1.368 _STLP_DECLARE_COPY_TRIVIAL(unsigned int)
1.369 _STLP_DECLARE_COPY_TRIVIAL(long)
1.370 _STLP_DECLARE_COPY_TRIVIAL(unsigned long)
1.371 -#if !defined(_STLP_NO_WCHAR_T) && !defined (_STLP_WCHAR_T_IS_USHORT)
1.372 +# if !defined(_STLP_NO_WCHAR_T) && !defined (_STLP_WCHAR_T_IS_USHORT)
1.373 _STLP_DECLARE_COPY_TRIVIAL(wchar_t)
1.374 -#endif
1.375 -#ifdef _STLP_LONG_LONG
1.376 -_STLP_DECLARE_COPY_TRIVIAL(long long)
1.377 -_STLP_DECLARE_COPY_TRIVIAL(unsigned long long)
1.378 -#endif
1.379 +# endif
1.380 +# if defined (_STLP_LONG_LONG)
1.381 +_STLP_DECLARE_COPY_TRIVIAL(_STLP_LONG_LONG)
1.382 +_STLP_DECLARE_COPY_TRIVIAL(unsigned _STLP_LONG_LONG)
1.383 +# endif
1.384 _STLP_DECLARE_COPY_TRIVIAL(float)
1.385 _STLP_DECLARE_COPY_TRIVIAL(double)
1.386 -# ifndef _STLP_NO_LONG_DOUBLE
1.387 +# if !defined (_STLP_NO_LONG_DOUBLE)
1.388 _STLP_DECLARE_COPY_TRIVIAL(long double)
1.389 -# endif
1.390 -#undef _STLP_DECLARE_COPY_TRIVIAL
1.391 +# endif
1.392 +# undef _STLP_DECLARE_COPY_TRIVIAL
1.393 #endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */
1.394
1.395 //--------------------------------------------------
1.396 // copy_n (not part of the C++ standard)
1.397
1.398 +#if !defined (_STLP_NO_EXTENSIONS)
1.399 +_STLP_MOVE_TO_PRIV_NAMESPACE
1.400 +
1.401 template <class _InputIter, class _Size, class _OutputIter>
1.402 -_STLP_INLINE_LOOP
1.403 -pair<_InputIter, _OutputIter> __copy_n(_InputIter __first, _Size __count,
1.404 - _OutputIter __result,
1.405 - const input_iterator_tag &) {
1.406 +_STLP_INLINE_LOOP pair<_InputIter, _OutputIter>
1.407 +__copy_n(_InputIter __first, _Size __count,
1.408 + _OutputIter __result,
1.409 + const input_iterator_tag &) {
1.410 for ( ; __count > 0; --__count) {
1.411 *__result = *__first;
1.412 ++__first;
1.413 @@ -301,83 +375,88 @@
1.414 return pair<_RAIter, _OutputIter>(__last, copy(__first, __last, __result));
1.415 }
1.416
1.417 -template <class _InputIter, class _Size, class _OutputIter>
1.418 -inline pair<_InputIter, _OutputIter>
1.419 -__copy_n(_InputIter __first, _Size __count, _OutputIter __result) {
1.420 - _STLP_FIX_LITERAL_BUG(__first)
1.421 - return __copy_n(__first, __count, __result, _STLP_ITERATOR_CATEGORY(__first, _InputIter));
1.422 -}
1.423 +_STLP_MOVE_TO_STD_NAMESPACE
1.424
1.425 template <class _InputIter, class _Size, class _OutputIter>
1.426 inline pair<_InputIter, _OutputIter>
1.427 copy_n(_InputIter __first, _Size __count, _OutputIter __result) {
1.428 _STLP_FIX_LITERAL_BUG(__first)
1.429 - return __copy_n(__first, __count, __result, _STLP_ITERATOR_CATEGORY(__first, _InputIter));
1.430 + return _STLP_PRIV __copy_n(__first, __count, __result, _STLP_ITERATOR_CATEGORY(__first, _InputIter));
1.431 }
1.432 +#endif
1.433
1.434 //--------------------------------------------------
1.435 // fill and fill_n
1.436 -
1.437 -
1.438 template <class _ForwardIter, class _Tp>
1.439 _STLP_INLINE_LOOP
1.440 void fill(_ForwardIter __first, _ForwardIter __last, const _Tp& __val) {
1.441 - _STLP_DEBUG_CHECK(__check_range(__first, __last))
1.442 + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
1.443 for ( ; __first != __last; ++__first)
1.444 *__first = __val;
1.445 }
1.446
1.447 +_STLP_MOVE_TO_PRIV_NAMESPACE
1.448 +
1.449 template <class _OutputIter, class _Size, class _Tp>
1.450 _STLP_INLINE_LOOP
1.451 -_OutputIter fill_n(_OutputIter __first, _Size __n, const _Tp& __val) {
1.452 +_OutputIter __fill_n(_OutputIter __first, _Size __n, const _Tp& __val) {
1.453 _STLP_FIX_LITERAL_BUG(__first)
1.454 for ( ; __n > 0; --__n, ++__first)
1.455 *__first = __val;
1.456 return __first;
1.457 }
1.458
1.459 +_STLP_MOVE_TO_STD_NAMESPACE
1.460 +
1.461 +template <class _OutputIter, class _Size, class _Tp>
1.462 +_STLP_INLINE_LOOP
1.463 +void fill_n(_OutputIter __first, _Size __n, const _Tp& __val) {
1.464 + _STLP_FIX_LITERAL_BUG(__first)
1.465 + _STLP_PRIV __fill_n(__first, __n, __val);
1.466 +}
1.467
1.468 // Specialization: for one-byte types we can use memset.
1.469 -
1.470 inline void fill(unsigned char* __first, unsigned char* __last,
1.471 const unsigned char& __val) {
1.472 unsigned char __tmp = __val;
1.473 memset(__first, __tmp, __last - __first);
1.474 }
1.475 -# ifndef _STLP_NO_SIGNED_BUILTINS
1.476 +#if !defined (_STLP_NO_SIGNED_BUILTINS)
1.477 inline void fill(signed char* __first, signed char* __last,
1.478 const signed char& __val) {
1.479 signed char __tmp = __val;
1.480 memset(__first, __STATIC_CAST(unsigned char,__tmp), __last - __first);
1.481 }
1.482 -# endif
1.483 +#endif
1.484 inline void fill(char* __first, char* __last, const char& __val) {
1.485 char __tmp = __val;
1.486 memset(__first, __STATIC_CAST(unsigned char,__tmp), __last - __first);
1.487 }
1.488
1.489 -#ifdef _STLP_FUNCTION_TMPL_PARTIAL_ORDER
1.490 +#if defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
1.491 +_STLP_MOVE_TO_PRIV_NAMESPACE
1.492
1.493 template <class _Size>
1.494 -inline unsigned char* fill_n(unsigned char* __first, _Size __n,
1.495 +inline unsigned char* __fill_n(unsigned char* __first, _Size __n,
1.496 const unsigned char& __val) {
1.497 fill(__first, __first + __n, __val);
1.498 return __first + __n;
1.499 }
1.500
1.501 template <class _Size>
1.502 -inline signed char* fill_n(char* __first, _Size __n,
1.503 +inline signed char* __fill_n(char* __first, _Size __n,
1.504 const signed char& __val) {
1.505 fill(__first, __first + __n, __val);
1.506 return __first + __n;
1.507 }
1.508
1.509 template <class _Size>
1.510 -inline char* fill_n(char* __first, _Size __n, const char& __val) {
1.511 +inline char* __fill_n(char* __first, _Size __n, const char& __val) {
1.512 fill(__first, __first + __n, __val);
1.513 return __first + __n;
1.514 }
1.515
1.516 +_STLP_MOVE_TO_STD_NAMESPACE
1.517 #endif /* _STLP_FUNCTION_TMPL_PARTIAL_ORDER */
1.518
1.519
1.520 @@ -390,7 +469,7 @@
1.521 _InputIter1 __last1,
1.522 _InputIter2 __first2) {
1.523 _STLP_FIX_LITERAL_BUG(__first2)
1.524 - _STLP_DEBUG_CHECK(__check_range(__first1, __last1))
1.525 + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1))
1.526 while (__first1 != __last1 && *__first1 == *__first2) {
1.527 ++__first1;
1.528 ++__first2;
1.529 @@ -405,7 +484,7 @@
1.530 _InputIter2 __first2,
1.531 _BinaryPredicate __binary_pred) {
1.532 _STLP_FIX_LITERAL_BUG(__first2)
1.533 - _STLP_DEBUG_CHECK(__check_range(__first1, __last1))
1.534 + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1))
1.535 while (__first1 != __last1 && __binary_pred(*__first1, *__first2)) {
1.536 ++__first1;
1.537 ++__first2;
1.538 @@ -418,7 +497,7 @@
1.539 bool equal(_InputIter1 __first1, _InputIter1 __last1,
1.540 _InputIter2 __first2) {
1.541 _STLP_FIX_LITERAL_BUG(__first1) _STLP_FIX_LITERAL_BUG(__last1) _STLP_FIX_LITERAL_BUG(__first2)
1.542 - _STLP_DEBUG_CHECK(__check_range(__first1, __last1))
1.543 + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1))
1.544 for ( ; __first1 != __last1; ++__first1, ++__first2)
1.545 if (!(*__first1 == *__first2))
1.546 return false;
1.547 @@ -430,7 +509,7 @@
1.548 bool equal(_InputIter1 __first1, _InputIter1 __last1,
1.549 _InputIter2 __first2, _BinaryPredicate __binary_pred) {
1.550 _STLP_FIX_LITERAL_BUG(__first2)
1.551 - _STLP_DEBUG_CHECK(__check_range(__first1, __last1))
1.552 + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1))
1.553 for ( ; __first1 != __last1; ++__first1, ++__first2)
1.554 if (!__binary_pred(*__first1, *__first2))
1.555 return false;
1.556 @@ -450,28 +529,26 @@
1.557 _InputIter2 __first2, _InputIter2 __last2,
1.558 _Compare __comp);
1.559
1.560 -inline bool
1.561 +inline bool
1.562 lexicographical_compare(const unsigned char* __first1,
1.563 const unsigned char* __last1,
1.564 const unsigned char* __first2,
1.565 - const unsigned char* __last2)
1.566 -{
1.567 + const unsigned char* __last2) {
1.568 const size_t __len1 = __last1 - __first1;
1.569 const size_t __len2 = __last2 - __first2;
1.570 - _STLP_DEBUG_CHECK(__check_range(__first1, __last1))
1.571 - _STLP_DEBUG_CHECK(__check_range(__first2, __last2))
1.572 + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1))
1.573 + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first2, __last2))
1.574
1.575 const int __result = memcmp(__first1, __first2, (min) (__len1, __len2));
1.576 return __result != 0 ? (__result < 0) : (__len1 < __len2);
1.577 }
1.578
1.579
1.580 -# if !(CHAR_MAX == SCHAR_MAX)
1.581 +#if !(CHAR_MAX == SCHAR_MAX)
1.582 inline bool lexicographical_compare(const char* __first1, const char* __last1,
1.583 - const char* __first2, const char* __last2)
1.584 -{
1.585 - _STLP_DEBUG_CHECK(__check_range(__first1, __last1))
1.586 - _STLP_DEBUG_CHECK(__check_range(__first2, __last2))
1.587 + const char* __first2, const char* __last2) {
1.588 + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1))
1.589 + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first2, __last2))
1.590
1.591 return lexicographical_compare((const unsigned char*) __first1,
1.592 (const unsigned char*) __last1,
1.593 @@ -480,6 +557,8 @@
1.594 }
1.595 #endif /* CHAR_MAX == SCHAR_MAX */
1.596
1.597 +_STLP_MOVE_TO_PRIV_NAMESPACE
1.598 +
1.599 template <class _InputIter1, class _InputIter2>
1.600 int __lexicographical_compare_3way(_InputIter1 __first1, _InputIter1 __last1,
1.601 _InputIter2 __first2, _InputIter2 __last2);
1.602 @@ -488,41 +567,40 @@
1.603 __lexicographical_compare_3way(const unsigned char* __first1,
1.604 const unsigned char* __last1,
1.605 const unsigned char* __first2,
1.606 - const unsigned char* __last2)
1.607 -{
1.608 + const unsigned char* __last2) {
1.609 const ptrdiff_t __len1 = __last1 - __first1;
1.610 const ptrdiff_t __len2 = __last2 - __first2;
1.611 const int __result = memcmp(__first1, __first2, (min) (__len1, __len2));
1.612 - return __result != 0 ? __result
1.613 + return __result != 0 ? __result
1.614 : (__len1 == __len2 ? 0 : (__len1 < __len2 ? -1 : 1));
1.615 }
1.616
1.617
1.618 -# if !(CHAR_MAX == SCHAR_MAX)
1.619 -inline int
1.620 +#if !(CHAR_MAX == SCHAR_MAX)
1.621 +inline int
1.622 __lexicographical_compare_3way(const char* __first1, const char* __last1,
1.623 - const char* __first2, const char* __last2)
1.624 -{
1.625 + const char* __first2, const char* __last2) {
1.626 return __lexicographical_compare_3way((const unsigned char*) __first1,
1.627 (const unsigned char*) __last1,
1.628 (const unsigned char*) __first2,
1.629 (const unsigned char*) __last2);
1.630 }
1.631 -# endif
1.632 +#endif
1.633
1.634 -# ifndef _STLP_NO_EXTENSIONS
1.635 +_STLP_MOVE_TO_STD_NAMESPACE
1.636
1.637 +#if !defined (_STLP_NO_EXTENSIONS)
1.638 template <class _InputIter1, class _InputIter2>
1.639 int lexicographical_compare_3way(_InputIter1 __first1, _InputIter1 __last1,
1.640 _InputIter2 __first2, _InputIter2 __last2);
1.641
1.642 -# endif /* EXTENSIONS */
1.643 +#endif /* EXTENSIONS */
1.644
1.645 // count
1.646 template <class _InputIter, class _Tp>
1.647 _STLP_INLINE_LOOP _STLP_DIFFERENCE_TYPE(_InputIter)
1.648 count(_InputIter __first, _InputIter __last, const _Tp& __val) {
1.649 - _STLP_DEBUG_CHECK(__check_range(__first, __last))
1.650 + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
1.651 _STLP_DIFFERENCE_TYPE(_InputIter) __n = 0;
1.652 for ( ; __first != __last; ++__first)
1.653 if (*__first == __val)
1.654 @@ -533,6 +611,7 @@
1.655 // find and find_if. Note find may be expressed in terms of find_if if appropriate binder was available.
1.656 template <class _InputIter, class _Tp>
1.657 _InputIter find(_InputIter __first, _InputIter __last, const _Tp& __val);
1.658 +
1.659 template <class _InputIter, class _Predicate>
1.660 _InputIter find_if(_InputIter __first, _InputIter __last, _Predicate __pred);
1.661
1.662 @@ -541,39 +620,47 @@
1.663 _ForwardIter1 search(_ForwardIter1 __first1, _ForwardIter1 __last1,
1.664 _ForwardIter2 __first2, _ForwardIter2 __last2, _BinaryPred __predicate);
1.665
1.666 +_STLP_MOVE_TO_PRIV_NAMESPACE
1.667 +
1.668 // find_first_of
1.669 template <class _InputIter, class _ForwardIter, class _BinaryPredicate>
1.670 _InputIter __find_first_of(_InputIter __first1, _InputIter __last1,
1.671 _ForwardIter __first2, _ForwardIter __last2,
1.672 _BinaryPredicate __comp);
1.673
1.674 -template <class _ForwardIter1, class _ForwardIter2,
1.675 +_STLP_MOVE_TO_STD_NAMESPACE
1.676 +
1.677 +template <class _ForwardIter1, class _ForwardIter2,
1.678 class _BinaryPredicate>
1.679 -_ForwardIter1
1.680 -find_end(_ForwardIter1 __first1, _ForwardIter1 __last1,
1.681 +_ForwardIter1
1.682 +find_end(_ForwardIter1 __first1, _ForwardIter1 __last1,
1.683 _ForwardIter2 __first2, _ForwardIter2 __last2,
1.684 _BinaryPredicate __comp);
1.685
1.686 // replace
1.687 template <class _ForwardIter, class _Tp>
1.688 -_STLP_INLINE_LOOP void
1.689 +_STLP_INLINE_LOOP void
1.690 replace(_ForwardIter __first, _ForwardIter __last,
1.691 const _Tp& __old_value, const _Tp& __new_value) {
1.692 - _STLP_DEBUG_CHECK(__check_range(__first, __last))
1.693 + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
1.694 for ( ; __first != __last; ++__first)
1.695 if (*__first == __old_value)
1.696 *__first = __new_value;
1.697 }
1.698
1.699 -template <class _ForwardIter, class _Tp, class _Compare, class _Distance>
1.700 +_STLP_MOVE_TO_PRIV_NAMESPACE
1.701 +
1.702 +template <class _ForwardIter, class _Tp, class _Compare1, class _Compare2, class _Distance>
1.703 _ForwardIter __lower_bound(_ForwardIter __first, _ForwardIter __last,
1.704 - const _Tp& __val, _Compare __comp, _Distance*);
1.705 + const _Tp& __val, _Compare1 __comp1, _Compare2 __comp2, _Distance*);
1.706 +
1.707 +_STLP_MOVE_TO_STD_NAMESPACE
1.708
1.709 _STLP_END_NAMESPACE
1.710
1.711 -# if !defined (_STLP_LINK_TIME_INSTANTIATION)
1.712 +#if !defined (_STLP_LINK_TIME_INSTANTIATION)
1.713 # include <stl/_algobase.c>
1.714 -# endif
1.715 +#endif
1.716
1.717 #endif /* _STLP_INTERNAL_ALGOBASE_H */
1.718