epoc32/include/stdapis/stlportv5/stl/_uninitialized.h
branchSymbian3
changeset 4 837f303aceeb
parent 3 e1b950c65cb4
     1.1 --- a/epoc32/include/stdapis/stlportv5/stl/_uninitialized.h	Wed Mar 31 12:27:01 2010 +0100
     1.2 +++ b/epoc32/include/stdapis/stlportv5/stl/_uninitialized.h	Wed Mar 31 12:33:34 2010 +0100
     1.3 @@ -1,4 +1,5 @@
     1.4  /*
     1.5 + * Portions Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
     1.6   *
     1.7   * Copyright (c) 1994
     1.8   * Hewlett-Packard Company
     1.9 @@ -9,13 +10,13 @@
    1.10   * Copyright (c) 1997
    1.11   * Moscow Center for SPARC Technology
    1.12   *
    1.13 - * Copyright (c) 1999 
    1.14 + * Copyright (c) 1999
    1.15   * Boris Fomitchev
    1.16   *
    1.17   * This material is provided "as is", with absolutely no warranty expressed
    1.18   * or implied. Any use is at your own risk.
    1.19   *
    1.20 - * Permission to use or copy this software for any purpose is hereby granted 
    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 @@ -30,258 +31,404 @@
    1.26  #ifndef _STLP_INTERNAL_UNINITIALIZED_H
    1.27  #define _STLP_INTERNAL_UNINITIALIZED_H
    1.28  
    1.29 -# ifndef _STLP_CSTRING
    1.30 -#  include <cstring>
    1.31 -# endif
    1.32 +#ifndef _STLP_INTERNAL_CSTRING
    1.33 +#  include <stl/_cstring.h>
    1.34 +#endif
    1.35  
    1.36 -# ifndef _STLP_INTERNAL_ALGOBASE_H
    1.37 +#ifndef _STLP_INTERNAL_ALGOBASE_H
    1.38  #  include <stl/_algobase.h>
    1.39 -# endif
    1.40 +#endif
    1.41  
    1.42 -# ifndef _STLP_INTERNAL_CONSTRUCT_H
    1.43 +#ifndef _STLP_INTERNAL_CONSTRUCT_H
    1.44  #  include <stl/_construct.h>
    1.45 -# endif
    1.46 +#endif
    1.47  
    1.48  _STLP_BEGIN_NAMESPACE
    1.49  
    1.50 +_STLP_MOVE_TO_PRIV_NAMESPACE
    1.51 +
    1.52  // uninitialized_copy
    1.53  
    1.54 -// Valid if copy construction is equivalent to assignment, and if the
    1.55 -//  destructor is trivial.
    1.56 -template <class _InputIter, class _ForwardIter>
    1.57 -inline _ForwardIter 
    1.58 -__uninitialized_copy(_InputIter __first, _InputIter __last, _ForwardIter __result,
    1.59 -                     const __true_type&) {
    1.60 -  return __copy_aux(__first, __last, __result, _BothPtrType< _InputIter, _ForwardIter> :: _Ret());
    1.61 +template <class _InputIter, class _OutputIter, class _Distance>
    1.62 +inline _OutputIter __ucopy(_InputIter __first, _InputIter __last,
    1.63 +                           _OutputIter __result, _Distance*) {
    1.64 +  _OutputIter __cur = __result;
    1.65 +  _STLP_TRY {
    1.66 +    for ( ; __first != __last; ++__first, ++__cur)
    1.67 +      _Param_Construct(&*__cur, *__first);
    1.68 +    return __cur;
    1.69 +  }
    1.70 +  _STLP_UNWIND(_STLP_STD::_Destroy_Range(__result, __cur))
    1.71 +  _STLP_RET_AFTER_THROW(__cur)
    1.72  }
    1.73  
    1.74 +template <class _InputIter, class _OutputIter, class _Distance>
    1.75 +inline _OutputIter __ucopy(_InputIter __first, _InputIter __last,
    1.76 +                           _OutputIter __result, const input_iterator_tag &, _Distance* __d)
    1.77 +{ return __ucopy(__first, __last, __result, __d); }
    1.78 +
    1.79 +#if defined (_STLP_NONTEMPL_BASE_MATCH_BUG)
    1.80 +template <class _InputIter, class _OutputIter, class _Distance>
    1.81 +inline _OutputIter __ucopy(_InputIter __first, _InputIter __last,
    1.82 +                           _OutputIter __result, const forward_iterator_tag &, _Distance* __d)
    1.83 +{ return __ucopy(__first, __last, __result, __d); }
    1.84 +
    1.85 +template <class _InputIter, class _OutputIter, class _Distance>
    1.86 +inline _OutputIter __ucopy(_InputIter __first, _InputIter __last,
    1.87 +                           _OutputIter __result, const bidirectional_iterator_tag &, _Distance* __d)
    1.88 +{ return __ucopy(__first, __last, __result, __d); }
    1.89 +#endif
    1.90 +
    1.91 +template <class _RandomAccessIter, class _OutputIter, class _Distance>
    1.92 +inline _OutputIter __ucopy(_RandomAccessIter __first, _RandomAccessIter __last,
    1.93 +                           _OutputIter __result, const random_access_iterator_tag &, _Distance*) {
    1.94 +  _OutputIter __cur = __result;
    1.95 +  _STLP_TRY {
    1.96 +    for (_Distance __n = __last - __first; __n > 0; --__n) {
    1.97 +      _Param_Construct(&*__cur, *__first);
    1.98 +      ++__first;
    1.99 +      ++__cur;
   1.100 +    }
   1.101 +    return __cur;
   1.102 +  }
   1.103 +  _STLP_UNWIND(_STLP_STD::_Destroy_Range(__result, __cur))
   1.104 +  _STLP_RET_AFTER_THROW(__cur)
   1.105 +}
   1.106 +
   1.107 +//Used internaly
   1.108 +template <class _RandomAccessIter, class _OutputIter>
   1.109 +inline _OutputIter __ucopy(_RandomAccessIter __first, _RandomAccessIter __last, _OutputIter __result)
   1.110 +{ return __ucopy(__first, __last, __result, random_access_iterator_tag(), (ptrdiff_t*)0); }
   1.111 +
   1.112 +inline void*
   1.113 +__ucopy_trivial(const void* __first, const void* __last, void* __result) {
   1.114 +  //dums: this version can use memcpy (__copy_trivial can't)
   1.115 +  return (__last == __first) ? __result :
   1.116 +    ((char*)memcpy(__result, __first, ((const char*)__last - (const char*)__first))) +
   1.117 +    ((const char*)__last - (const char*)__first);
   1.118 +}
   1.119 +
   1.120 +template <class _InputIter, class _OutputIter>
   1.121 +inline _OutputIter __ucopy_ptrs(_InputIter __first, _InputIter __last, _OutputIter __result,
   1.122 +                                const __false_type& /*TrivialUCopy*/)
   1.123 +{ return __ucopy(__first, __last, __result, random_access_iterator_tag(), (ptrdiff_t*)0); }
   1.124 +
   1.125 +template <class _InputIter, class _OutputIter>
   1.126 +inline _OutputIter __ucopy_ptrs(_InputIter __first, _InputIter __last, _OutputIter __result,
   1.127 +                                const __true_type& /*TrivialUCopy*/) {
   1.128 +  // we know they all pointers, so this cast is OK
   1.129 +  //  return (_OutputIter)__copy_trivial(&(*__first), &(*__last), &(*__result));
   1.130 +  return (_OutputIter)__ucopy_trivial(__first, __last, __result);
   1.131 +}
   1.132 +
   1.133 +template <class _InputIter, class _OutputIter>
   1.134 +inline _OutputIter __ucopy_aux(_InputIter __first, _InputIter __last, _OutputIter __result,
   1.135 +                               const __true_type& /*BothPtrType*/) {
   1.136 +  return __ucopy_ptrs(__first, __last, __result,
   1.137 +                      _UseTrivialUCopy(_STLP_VALUE_TYPE(__first, _InputIter),
   1.138 +                                       _STLP_VALUE_TYPE(__result, _OutputIter))._Answer());
   1.139 +}
   1.140 +
   1.141 +template <class _InputIter, class _OutputIter>
   1.142 +inline _OutputIter __ucopy_aux(_InputIter __first, _InputIter __last, _OutputIter __result,
   1.143 +                               const __false_type& /*BothPtrType*/) {
   1.144 +  return __ucopy(__first, __last, __result,
   1.145 +                 _STLP_ITERATOR_CATEGORY(__first, _InputIter),
   1.146 +                 _STLP_DISTANCE_TYPE(__first, _InputIter));
   1.147 +}
   1.148 +
   1.149 +_STLP_MOVE_TO_STD_NAMESPACE
   1.150 +
   1.151  template <class _InputIter, class _ForwardIter>
   1.152 -// _STLP_INLINE_LOOP
   1.153 -_ForwardIter 
   1.154 -__uninitialized_copy(_InputIter __first, _InputIter __last, _ForwardIter __result,
   1.155 -                     const __false_type&)
   1.156 -{
   1.157 -  _STLP_LEAVE_VOLATILE _ForwardIter __cur = __result;
   1.158 -  _STLP_TRY  {
   1.159 -    for ( ; __first != __last; ++__first, ++__cur)
   1.160 -      _Construct(&*__cur, *__first);
   1.161 -    //    return __cur;
   1.162 +inline _ForwardIter
   1.163 +uninitialized_copy(_InputIter __first, _InputIter __last, _ForwardIter __result)
   1.164 +{ return _STLP_PRIV __ucopy_aux(__first, __last, __result, _BothPtrType< _InputIter, _ForwardIter>::_Answer()); }
   1.165 +
   1.166 +inline char*
   1.167 +uninitialized_copy(const char* __first, const char* __last, char* __result)
   1.168 +{ return  (char*)_STLP_PRIV __ucopy_trivial(__first, __last, __result); }
   1.169 +
   1.170 +#  if defined (_STLP_HAS_WCHAR_T) // dwa 8/15/97
   1.171 +inline wchar_t*
   1.172 +uninitialized_copy(const wchar_t* __first, const wchar_t* __last, wchar_t* __result)
   1.173 +{ return  (wchar_t*)_STLP_PRIV __ucopy_trivial (__first, __last, __result); }
   1.174 +#  endif
   1.175 +
   1.176 +// uninitialized_copy_n (not part of the C++ standard)
   1.177 +_STLP_MOVE_TO_PRIV_NAMESPACE
   1.178 +
   1.179 +template <class _InputIter, class _Size, class _ForwardIter>
   1.180 +_STLP_INLINE_LOOP
   1.181 +pair<_InputIter, _ForwardIter>
   1.182 +__ucopy_n(_InputIter __first, _Size __count, _ForwardIter __result,
   1.183 +          const input_iterator_tag &) {
   1.184 +  _ForwardIter __cur = __result;
   1.185 +  _STLP_TRY {
   1.186 +    for ( ; __count > 0 ; --__count, ++__first, ++__cur)
   1.187 +      _Param_Construct(&*__cur, *__first);
   1.188 +    return pair<_InputIter, _ForwardIter>(__first, __cur);
   1.189    }
   1.190 -  _STLP_UNWIND (_STLP_STD::_Destroy(__result, __cur)); 
   1.191 +  _STLP_UNWIND(_STLP_STD::_Destroy_Range(__result, __cur))
   1.192 +  _STLP_RET_AFTER_THROW((pair<_InputIter, _ForwardIter>(__first, __cur)))
   1.193 +}
   1.194 +
   1.195 +#  if defined (_STLP_NONTEMPL_BASE_MATCH_BUG)
   1.196 +template <class _InputIter, class _Size, class _ForwardIterator>
   1.197 +inline pair<_InputIter, _ForwardIterator>
   1.198 +__ucopy_n(_InputIter __first, _Size __count,
   1.199 +                       _ForwardIterator __result,
   1.200 +                       const forward_iterator_tag &)
   1.201 +{ return __ucopy_n(__first, __count, __result, input_iterator_tag()); }
   1.202 +
   1.203 +template <class _InputIter, class _Size, class _ForwardIterator>
   1.204 +inline pair<_InputIter, _ForwardIterator>
   1.205 +__ucopy_n(_InputIter __first, _Size __count,
   1.206 +                       _ForwardIterator __result,
   1.207 +                       const bidirectional_iterator_tag &)
   1.208 +{ return __ucopy_n(__first, __count, __result, input_iterator_tag()); }
   1.209 +#  endif
   1.210 +
   1.211 +template <class _RandomAccessIter, class _Size, class _ForwardIter>
   1.212 +inline pair<_RandomAccessIter, _ForwardIter>
   1.213 +__ucopy_n(_RandomAccessIter __first, _Size __count, _ForwardIter __result,
   1.214 +                       const random_access_iterator_tag &) {
   1.215 +  _RandomAccessIter __last = __first + __count;
   1.216 +  return pair<_RandomAccessIter, _ForwardIter>(__last, uninitialized_copy(__first, __last, __result));
   1.217 +}
   1.218 +
   1.219 +// This is used internally in <rope> , which is extension itself.
   1.220 +template <class _InputIter, class _Size, class _ForwardIter>
   1.221 +inline pair<_InputIter, _ForwardIter>
   1.222 +__ucopy_n(_InputIter __first, _Size __count, _ForwardIter __result)
   1.223 +{ return _STLP_PRIV __ucopy_n(__first, __count, __result, _STLP_ITERATOR_CATEGORY(__first, _InputIter)); }
   1.224 +
   1.225 +#if !defined (_STLP_NO_EXTENSIONS)
   1.226 +
   1.227 +_STLP_MOVE_TO_STD_NAMESPACE
   1.228 +
   1.229 +template <class _InputIter, class _Size, class _ForwardIter>
   1.230 +inline pair<_InputIter, _ForwardIter>
   1.231 +uninitialized_copy_n(_InputIter __first, _Size __count, _ForwardIter __result)
   1.232 +{ return _STLP_PRIV __ucopy_n(__first, __count, __result); }
   1.233 +
   1.234 +_STLP_MOVE_TO_PRIV_NAMESPACE
   1.235 +
   1.236 +#endif
   1.237 +
   1.238 +template <class _ForwardIter, class _Tp, class _Distance>
   1.239 +inline void __ufill(_ForwardIter __first, _ForwardIter __last, const _Tp& __x, _Distance*) {
   1.240 +  _ForwardIter __cur = __first;
   1.241 +  _STLP_TRY {
   1.242 +    for ( ; __cur != __last; ++__cur)
   1.243 +      _Param_Construct(&*__cur, __x);
   1.244 +  }
   1.245 +  _STLP_UNWIND(_STLP_STD::_Destroy_Range(__first, __cur))
   1.246 +}
   1.247 +
   1.248 +template <class _ForwardIter, class _Tp, class _Distance>
   1.249 +inline void __ufill(_ForwardIter __first, _ForwardIter __last,
   1.250 +                    const _Tp& __x, const input_iterator_tag &, _Distance* __d)
   1.251 +{ __ufill(__first, __last, __x, __d); }
   1.252 +
   1.253 +#if defined (_STLP_NONTEMPL_BASE_MATCH_BUG)
   1.254 +template <class _ForwardIter, class _Tp, class _Distance>
   1.255 +inline void __ufill(_ForwardIter __first, _ForwardIter __last,
   1.256 +                    const _Tp& __x, const forward_iterator_tag &, _Distance* __d)
   1.257 +{ __ufill(__first, __last, __x, __d); }
   1.258 +
   1.259 +template <class _ForwardIter, class _Tp, class _Distance>
   1.260 +inline void __ufill(_ForwardIter __first, _ForwardIter __last,
   1.261 +                    const _Tp& __x, const bidirectional_iterator_tag &, _Distance* __d)
   1.262 +{ __ufill(__first, __last, __x, __d); }
   1.263 +#endif
   1.264 +
   1.265 +template <class _ForwardIter, class _Tp, class _Distance>
   1.266 +inline void __ufill(_ForwardIter __first, _ForwardIter __last,
   1.267 +                    const _Tp& __x, const random_access_iterator_tag &, _Distance*) {
   1.268 +  _ForwardIter __cur = __first;
   1.269 +  _STLP_TRY {
   1.270 +    for (_Distance __n = __last - __first; __n > 0; --__n, ++__cur)
   1.271 +      _Param_Construct(&*__cur, __x);
   1.272 +  }
   1.273 +  _STLP_UNWIND(_STLP_STD::_Destroy_Range(__first, __cur))
   1.274 +}
   1.275 +
   1.276 +_STLP_MOVE_TO_STD_NAMESPACE
   1.277 +
   1.278 +template <class _ForwardIter, class _Tp>
   1.279 +inline void uninitialized_fill(_ForwardIter __first, _ForwardIter __last,  const _Tp& __x) {
   1.280 +  _STLP_PRIV __ufill(__first, __last, __x,
   1.281 +                     _STLP_ITERATOR_CATEGORY(__first, _ForwardIter),
   1.282 +                     _STLP_DISTANCE_TYPE(__first, _ForwardIter));
   1.283 +}
   1.284 +
   1.285 +// Specialization: for one-byte types we can use memset.
   1.286 +inline void uninitialized_fill(unsigned char* __first, unsigned char* __last,
   1.287 +                               const unsigned char& __val) {
   1.288 +  unsigned char __tmp = __val;
   1.289 +  memset(__first, __tmp, __last - __first);
   1.290 +}
   1.291 +#if !defined (_STLP_NO_SIGNED_BUILTINS)
   1.292 +inline void uninitialized_fill(signed char* __first, signed char* __last,
   1.293 +                               const signed char& __val) {
   1.294 +  signed char __tmp = __val;
   1.295 +  memset(__first, __STATIC_CAST(unsigned char,__tmp), __last - __first);
   1.296 +}
   1.297 +#endif
   1.298 +inline void uninitialized_fill(char* __first, char* __last, const char& __val) {
   1.299 +  char __tmp = __val;
   1.300 +  memset(__first, __STATIC_CAST(unsigned char,__tmp), __last - __first);
   1.301 +}
   1.302 +
   1.303 +_STLP_MOVE_TO_PRIV_NAMESPACE
   1.304 +
   1.305 +template <class _ForwardIter, class _Size, class _Tp>
   1.306 +inline _ForwardIter __ufill_n(_ForwardIter __first, _Size __n, const _Tp& __x) {
   1.307 +  _ForwardIter __cur = __first;
   1.308 +  _STLP_TRY {
   1.309 +    for ( ; __n > 0; --__n, ++__cur)
   1.310 +      _Param_Construct(&*__cur, __x);
   1.311 +  }
   1.312 +  _STLP_UNWIND(_STLP_STD::_Destroy_Range(__first, __cur))
   1.313    return __cur;
   1.314  }
   1.315  
   1.316 -template <class _InputIter, class _ForwardIter>
   1.317 -inline _ForwardIter
   1.318 -uninitialized_copy(_InputIter __first, _InputIter __last, _ForwardIter __result) {
   1.319 -  return __uninitialized_copy(__first, __last, __result,  _IS_POD_ITER(__result, _ForwardIter));
   1.320 -}
   1.321 +template <class _ForwardIter, class _Size, class _Tp>
   1.322 +inline _ForwardIter __ufill_n(_ForwardIter __first, _Size __n, const _Tp& __x,
   1.323 +                              const input_iterator_tag &)
   1.324 +{ return __ufill_n(__first, __n, __x); }
   1.325  
   1.326 -inline char* 
   1.327 -uninitialized_copy(const char* __first, const char* __last, char* __result) {
   1.328 -  return  (char*)__copy_trivial (__first, __last, __result);
   1.329 -}
   1.330 +#if defined (_STLP_NONTEMPL_BASE_MATCH_BUG)
   1.331 +template <class _ForwardIter, class _Size, class _Tp>
   1.332 +inline _ForwardIter __ufill_n(_ForwardIter __first, _Size __n, const _Tp& __x,
   1.333 +                              const forward_iterator_tag &)
   1.334 +{ return __ufill_n(__first, __n, __x); }
   1.335  
   1.336 -#  ifdef _STLP_HAS_WCHAR_T // dwa 8/15/97
   1.337 -inline wchar_t* 
   1.338 -uninitialized_copy(const wchar_t* __first, const wchar_t* __last, wchar_t* __result) {
   1.339 -  return  (wchar_t*)__copy_trivial (__first, __last, __result);
   1.340 -}
   1.341 -#  endif /* _STLP_HAS_WCHAR_T */
   1.342 +template <class _ForwardIter, class _Size, class _Tp>
   1.343 +inline _ForwardIter __ufill_n(_ForwardIter __first, _Size __n, const _Tp& __x,
   1.344 +                              const bidirectional_iterator_tag &)
   1.345 +{ return __ufill_n(__first, __n, __x); }
   1.346 +#endif
   1.347  
   1.348 -# ifndef _STLP_NO_EXTENSIONS
   1.349 -// uninitialized_copy_n (not part of the C++ standard)
   1.350 -
   1.351 -template <class _InputIter, class _Size, class _ForwardIter>
   1.352 -// _STLP_INLINE_LOOP 
   1.353 -pair<_InputIter, _ForwardIter>
   1.354 -__uninitialized_copy_n(_InputIter __first, _Size __count,
   1.355 -                       _ForwardIter __result,
   1.356 -                       const input_iterator_tag &)
   1.357 -{
   1.358 -  _STLP_LEAVE_VOLATILE  _ForwardIter __cur = __result;
   1.359 -  _STLP_TRY {
   1.360 -    for ( ; __count > 0 ; --__count, ++__first, ++__cur) 
   1.361 -      _Construct(&*__cur, *__first);
   1.362 -    //    return pair<_InputIter, _ForwardIter>(__first, __cur);
   1.363 -  }
   1.364 -  _STLP_UNWIND(_STLP_STD::_Destroy(__result, __cur));
   1.365 -
   1.366 -  return pair<_InputIter, _ForwardIter>(__first, __cur);
   1.367 -
   1.368 -}
   1.369 -
   1.370 -# if defined(_STLP_NONTEMPL_BASE_MATCH_BUG) 
   1.371 -template <class _InputIterator, class _Size, class _ForwardIterator>
   1.372 -inline pair<_InputIterator, _ForwardIterator>
   1.373 -__uninitialized_copy_n(_InputIterator __first, _Size __count,
   1.374 -                       _ForwardIterator __result,
   1.375 -                       const forward_iterator_tag &) {
   1.376 -  return __uninitialized_copy_n(__first, __count, __result, input_iterator_tag());
   1.377 -}
   1.378 -
   1.379 -template <class _InputIterator, class _Size, class _ForwardIterator>
   1.380 -inline pair<_InputIterator, _ForwardIterator>
   1.381 -__uninitialized_copy_n(_InputIterator __first, _Size __count,
   1.382 -                       _ForwardIterator __result,
   1.383 -                       const bidirectional_iterator_tag &) {
   1.384 -  return __uninitialized_copy_n(__first, __count, __result, input_iterator_tag());
   1.385 -}
   1.386 -# endif
   1.387 -
   1.388 -
   1.389 -template <class _RandomAccessIter, class _Size, class _ForwardIter>
   1.390 -inline pair<_RandomAccessIter, _ForwardIter>
   1.391 -__uninitialized_copy_n(_RandomAccessIter __first, _Size __count, _ForwardIter __result, const random_access_iterator_tag &) {
   1.392 -  _RandomAccessIter __last = __first + __count;
   1.393 -  return pair<_RandomAccessIter, _ForwardIter>( __last, __uninitialized_copy(__first, __last, __result, 
   1.394 -                                                                             _IS_POD_ITER(__result, _ForwardIter)));
   1.395 -}
   1.396 -
   1.397 -// this is used internally in <rope> , which is extension itself.
   1.398 -template <class _InputIter, class _Size, class _ForwardIter>
   1.399 -inline pair<_InputIter, _ForwardIter>
   1.400 -uninitialized_copy_n(_InputIter __first, _Size __count,
   1.401 -                     _ForwardIter __result) {
   1.402 -  return __uninitialized_copy_n(__first, __count, __result, _STLP_ITERATOR_CATEGORY(__first, _InputIter));
   1.403 -}
   1.404 -# endif /* _STLP_NO_EXTENSIONS */
   1.405 -
   1.406 -// Valid if copy construction is equivalent to assignment, and if the
   1.407 -// destructor is trivial.
   1.408 -template <class _ForwardIter, class _Tp>
   1.409 -inline void
   1.410 -__uninitialized_fill(_ForwardIter __first, _ForwardIter __last, 
   1.411 -                     const _Tp& __x, const __true_type&) {
   1.412 -  _STLP_STD::fill(__first, __last, __x);
   1.413 -}
   1.414 -
   1.415 -template <class _ForwardIter, class _Tp>
   1.416 -// _STLP_INLINE_LOOP 
   1.417 -void
   1.418 -__uninitialized_fill(_ForwardIter __first, _ForwardIter __last, 
   1.419 -                     const _Tp& __x, const __false_type&)
   1.420 -{
   1.421 -  _STLP_LEAVE_VOLATILE  _ForwardIter __cur = __first;
   1.422 -  _STLP_TRY {
   1.423 -    for ( ; __cur != __last; ++__cur)
   1.424 -      _Construct(&*__cur, __x);
   1.425 -  }
   1.426 -  _STLP_UNWIND(_STLP_STD::_Destroy(__first, __cur));
   1.427 -}
   1.428 -
   1.429 -template <class _ForwardIter, class _Tp>
   1.430 -inline void uninitialized_fill(_ForwardIter __first, _ForwardIter __last,  const _Tp& __x) {
   1.431 -  __uninitialized_fill(__first, __last, __x, _IS_POD_ITER(__first, _ForwardIter));
   1.432 -}
   1.433 -
   1.434 -// Valid if copy construction is equivalent to assignment, and if the
   1.435 -//  destructor is trivial.
   1.436  template <class _ForwardIter, class _Size, class _Tp>
   1.437 -inline _ForwardIter
   1.438 -__uninitialized_fill_n(_ForwardIter __first, _Size __n,
   1.439 -                       const _Tp& __x, const __true_type&) {
   1.440 -  return _STLP_STD::fill_n(__first, __n, __x);
   1.441 +inline _ForwardIter __uninitialized_fill_n(_ForwardIter __first, _Size __n, const _Tp& __x) {
   1.442 +  _ForwardIter __last = __first + __n;
   1.443 +  __ufill(__first, __last, __x, random_access_iterator_tag(), (ptrdiff_t*)0);
   1.444 +  return __last;
   1.445  }
   1.446  
   1.447  template <class _ForwardIter, class _Size, class _Tp>
   1.448 -//_STLP_INLINE_LOOP 
   1.449 -_ForwardIter
   1.450 -__uninitialized_fill_n(_ForwardIter __first, _Size __n,
   1.451 -                       const _Tp& __x, const __false_type&)
   1.452 -{
   1.453 -  _STLP_LEAVE_VOLATILE  _ForwardIter __cur = __first;
   1.454 -  _STLP_TRY {
   1.455 -    for ( ; __n > 0; --__n, ++__cur)
   1.456 -      _Construct(&*__cur, __x);
   1.457 -    //    return __cur;
   1.458 -  }
   1.459 -  _STLP_UNWIND(_STLP_STD::_Destroy(__first, __cur));
   1.460 -  // # ifdef _STLP_THROW_RETURN_BUG
   1.461 -  return __cur;
   1.462 -  //# endif
   1.463 +inline _ForwardIter __ufill_n(_ForwardIter __first, _Size __n, const _Tp& __x,
   1.464 +                              const random_access_iterator_tag &)
   1.465 +{ return __uninitialized_fill_n(__first, __n, __x); }
   1.466 +
   1.467 +/* __uninitialized_init is an internal algo to init a range with a value
   1.468 + * built using default constructor. It is only called with pointer as
   1.469 + * iterator.
   1.470 + */
   1.471 +template <class _ForwardIter, class _Size, class _Tp>
   1.472 +inline _ForwardIter __uinit_aux_aux(_ForwardIter __first, _Size __n, const _Tp& __val,
   1.473 +                                    const __false_type& /*_HasDefaultZero*/)
   1.474 +{ return __uninitialized_fill_n(__first, __n, __val); }
   1.475 +
   1.476 +template <class _ForwardIter, class _Size, class _Tp>
   1.477 +inline _ForwardIter __uinit_aux_aux(_ForwardIter __first, _Size __n, const _Tp& /*__val */,
   1.478 +                                    const __true_type& /*_HasDefaultZero*/) { 	
   1.479 +  memset((unsigned char*)__first, 0, __n * sizeof(_Tp));
   1.480 +  return __first + __n;
   1.481  }
   1.482  
   1.483  template <class _ForwardIter, class _Size, class _Tp>
   1.484 -inline _ForwardIter 
   1.485 -uninitialized_fill_n(_ForwardIter __first, _Size __n, const _Tp& __x) {
   1.486 -  return __uninitialized_fill_n(__first, __n, __x, _IS_POD_ITER(__first, _ForwardIter));
   1.487 -}
   1.488 +inline _ForwardIter __uinit_aux(_ForwardIter __first, _Size __n, const _Tp&,
   1.489 +                                const __true_type& /*_TrivialInit*/)
   1.490 +{ return __first + __n; }
   1.491  
   1.492 -// Extensions: __uninitialized_copy_copy, __uninitialized_copy_fill, 
   1.493 +template <class _ForwardIter, class _Size, class _Tp>
   1.494 +inline _ForwardIter __uinit_aux(_ForwardIter __first, _Size __n, const _Tp& __val,
   1.495 +                                const __false_type& /*_TrivialInit*/)
   1.496 +{ return __uinit_aux_aux(__first, __n, __val, _HasDefaultZeroValue(__first)._Answer()); }
   1.497 +
   1.498 +template <class _ForwardIter, class _Size, class _Tp>
   1.499 +inline _ForwardIter __uninitialized_init(_ForwardIter __first, _Size __n, const _Tp& __val)
   1.500 +{ return __uinit_aux(__first, __n, __val, _UseTrivialInit(__first)._Answer()); }
   1.501 +
   1.502 +_STLP_MOVE_TO_STD_NAMESPACE
   1.503 +
   1.504 +template <class _ForwardIter, class _Size, class _Tp>
   1.505 +inline void
   1.506 +uninitialized_fill_n(_ForwardIter __first, _Size __n, const _Tp& __x)
   1.507 +{ _STLP_PRIV __ufill_n(__first, __n, __x, _STLP_ITERATOR_CATEGORY(__first, _ForwardIter)); }
   1.508 +
   1.509 +// Extensions: __uninitialized_copy_copy, __uninitialized_copy_fill,
   1.510  // __uninitialized_fill_copy.
   1.511  
   1.512  // __uninitialized_copy_copy
   1.513  // Copies [first1, last1) into [result, result + (last1 - first1)), and
   1.514  //  copies [first2, last2) into
   1.515 -//  [result, result + (last1 - first1) + (last2 - first2)).
   1.516 +//  [result + (last1 - first1), result + (last1 - first1) + (last2 - first2)).
   1.517 +
   1.518 +_STLP_MOVE_TO_PRIV_NAMESPACE
   1.519  
   1.520  template <class _InputIter1, class _InputIter2, class _ForwardIter>
   1.521  inline _ForwardIter
   1.522  __uninitialized_copy_copy(_InputIter1 __first1, _InputIter1 __last1,
   1.523                            _InputIter2 __first2, _InputIter2 __last2,
   1.524 -                          _ForwardIter __result, __true_type)
   1.525 -{
   1.526 -  return __uninitialized_copy(__first2, __last2, 
   1.527 -                              __uninitialized_copy(__first1, __last1, __result, __true_type()), __true_type());
   1.528 -}
   1.529 -
   1.530 -template <class _InputIter1, class _InputIter2, class _ForwardIter>
   1.531 -// inline 
   1.532 -_ForwardIter
   1.533 -__uninitialized_copy_copy(_InputIter1 __first1, _InputIter1 __last1,
   1.534 -                          _InputIter2 __first2, _InputIter2 __last2,
   1.535 -                          _ForwardIter __result, __false_type)
   1.536 -{
   1.537 -   _STLP_LEAVE_VOLATILE _ForwardIter __mid = __uninitialized_copy(__first1, __last1, __result, _IS_POD_ITER(__result, _ForwardIter));
   1.538 -
   1.539 -  _STLP_TRY {
   1.540 -    return __uninitialized_copy(__first2, __last2, __mid , _IS_POD_ITER(__result, _ForwardIter));
   1.541 -  }
   1.542 -  _STLP_UNWIND (_STLP_STD::_Destroy(__result, __mid));
   1.543 -# ifdef _STLP_THROW_RETURN_BUG
   1.544 -  return __mid;
   1.545 -# endif
   1.546 -}
   1.547 +                          _ForwardIter __result)
   1.548 +{ return uninitialized_copy(__first2, __last2, uninitialized_copy(__first1, __last1, __result)); }
   1.549  
   1.550  // __uninitialized_fill_copy
   1.551  // Fills [result, mid) with x, and copies [first, last) into
   1.552  //  [mid, mid + (last - first)).
   1.553  template <class _ForwardIter, class _Tp, class _InputIter>
   1.554 -// inline 
   1.555 -_ForwardIter 
   1.556 +inline _ForwardIter
   1.557  __uninitialized_fill_copy(_ForwardIter __result, _ForwardIter __mid, const _Tp& __x,
   1.558 -                          _InputIter __first, _InputIter __last)
   1.559 -{
   1.560 -  typedef typename __type_traits<_Tp>::is_POD_type _I_POD;
   1.561 -  __uninitialized_fill(__result, __mid, __x, _I_POD());
   1.562 +                          _InputIter __first, _InputIter __last) {
   1.563 +  uninitialized_fill(__result, __mid, __x);
   1.564    _STLP_TRY {
   1.565 -    return __uninitialized_copy(__first, __last, __mid, _I_POD());
   1.566 +    return uninitialized_copy(__first, __last, __mid);
   1.567    }
   1.568 -  _STLP_UNWIND (_STLP_STD::_Destroy(__result, __mid));
   1.569 -# ifdef _STLP_THROW_RETURN_BUG
   1.570 -  return __result;
   1.571 -# endif
   1.572 +  _STLP_UNWIND(_STLP_STD::_Destroy_Range(__result, __mid))
   1.573 +  _STLP_RET_AFTER_THROW(__result)
   1.574  }
   1.575  
   1.576  // __uninitialized_copy_fill
   1.577  // Copies [first1, last1) into [first2, first2 + (last1 - first1)), and
   1.578  //  fills [first2 + (last1 - first1), last2) with x.
   1.579 -template <class _InputIter, class _ForwardIter, class _Tp>
   1.580 -// inline 
   1.581 -void
   1.582 -__uninitialized_copy_fill(_InputIter __first1, _InputIter __last1,
   1.583 -                          _ForwardIter __first2, _ForwardIter __last2,
   1.584 -                          const _Tp& __x)
   1.585 -{
   1.586 -  typedef typename __type_traits<_Tp>::is_POD_type _I_POD;
   1.587 -  _ForwardIter __mid2 = __uninitialized_copy(__first1, __last1, __first2, _I_POD());
   1.588 +template <class _Iter, class _Tp>
   1.589 +inline void
   1.590 +__uninitialized_copy_fill(_Iter __first1, _Iter __last1, _Iter __first2, _Iter __last2,
   1.591 +                          const _Tp& __x) {
   1.592 +  _Iter __mid2 = uninitialized_copy(__first1, __last1, __first2);
   1.593    _STLP_TRY {
   1.594 -    __uninitialized_fill(__mid2, __last2, __x, _I_POD());
   1.595 +    uninitialized_fill(__mid2, __last2, __x);
   1.596    }
   1.597 -  _STLP_UNWIND(_STLP_STD::_Destroy(__first2, __mid2));
   1.598 +  _STLP_UNWIND(_STLP_STD::_Destroy_Range(__first2, __mid2))
   1.599  }
   1.600  
   1.601 +/* __uninitialized_move:
   1.602 + * This function is used internaly and only with pointers as iterators.
   1.603 + */
   1.604 +template <class _InputIter, class _ForwardIter, class _TrivialUCpy>
   1.605 +inline _ForwardIter
   1.606 +__uninitialized_move(_InputIter __first, _InputIter __last, _ForwardIter __result,
   1.607 +                     _TrivialUCpy __trivial_ucpy, const __false_type& /*_Movable*/)
   1.608 +{ return __ucopy_ptrs(__first, __last, __result, __trivial_ucpy); }
   1.609 +
   1.610 +template <class _InputIter, class _ForwardIter, class _TrivialUCpy>
   1.611 +_STLP_INLINE_LOOP
   1.612 +_ForwardIter
   1.613 +__uninitialized_move(_InputIter __first, _InputIter __last, _ForwardIter __result,
   1.614 +                     _TrivialUCpy , const __true_type& /*_Movable*/) {
   1.615 +  //Move constructor should not throw so we do not need to take care of exceptions here.
   1.616 +  for (ptrdiff_t __n = __last - __first ; __n > 0; --__n) {
   1.617 +    _Move_Construct(&*__result, *__first);
   1.618 +    ++__first; ++__result;
   1.619 +  }
   1.620 +  return __result;
   1.621 +}
   1.622 +
   1.623 +_STLP_MOVE_TO_STD_NAMESPACE
   1.624 +
   1.625  _STLP_END_NAMESPACE
   1.626  
   1.627  #endif /* _STLP_INTERNAL_UNINITIALIZED_H */