1.1 --- a/epoc32/include/stdapis/stlport/stl/_uninitialized.h Tue Nov 24 13:55:44 2009 +0000
1.2 +++ b/epoc32/include/stdapis/stlport/stl/_uninitialized.h Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -1,1 +1,291 @@
1.4 -_uninitialized.h
1.5 +/*
1.6 + *
1.7 + * Copyright (c) 1994
1.8 + * Hewlett-Packard Company
1.9 + *
1.10 + * Copyright (c) 1996,1997
1.11 + * Silicon Graphics Computer Systems, Inc.
1.12 + *
1.13 + * Copyright (c) 1997
1.14 + * Moscow Center for SPARC Technology
1.15 + *
1.16 + * Copyright (c) 1999
1.17 + * Boris Fomitchev
1.18 + *
1.19 + * This material is provided "as is", with absolutely no warranty expressed
1.20 + * or implied. Any use is at your own risk.
1.21 + *
1.22 + * Permission to use or copy this software for any purpose is hereby granted
1.23 + * without fee, provided the above notices are retained on all copies.
1.24 + * Permission to modify the code and to distribute modified code is granted,
1.25 + * provided the above notices are retained, and a notice that the code was
1.26 + * modified is included with the above copyright notice.
1.27 + *
1.28 + */
1.29 +
1.30 +/* NOTE: This is an internal header file, included by other STL headers.
1.31 + * You should not attempt to use it directly.
1.32 + */
1.33 +
1.34 +#ifndef _STLP_INTERNAL_UNINITIALIZED_H
1.35 +#define _STLP_INTERNAL_UNINITIALIZED_H
1.36 +
1.37 +# ifndef _STLP_CSTRING
1.38 +# include <cstring>
1.39 +# endif
1.40 +
1.41 +# ifndef _STLP_INTERNAL_ALGOBASE_H
1.42 +# include <stl/_algobase.h>
1.43 +# endif
1.44 +
1.45 +# ifndef _STLP_INTERNAL_CONSTRUCT_H
1.46 +# include <stl/_construct.h>
1.47 +# endif
1.48 +
1.49 +_STLP_BEGIN_NAMESPACE
1.50 +
1.51 +// uninitialized_copy
1.52 +
1.53 +// Valid if copy construction is equivalent to assignment, and if the
1.54 +// destructor is trivial.
1.55 +template <class _InputIter, class _ForwardIter>
1.56 +inline _ForwardIter
1.57 +__uninitialized_copy(_InputIter __first, _InputIter __last, _ForwardIter __result,
1.58 + const __true_type&) {
1.59 + return __copy_aux(__first, __last, __result, _BothPtrType< _InputIter, _ForwardIter> :: _Ret());
1.60 +}
1.61 +
1.62 +template <class _InputIter, class _ForwardIter>
1.63 +// _STLP_INLINE_LOOP
1.64 +_ForwardIter
1.65 +__uninitialized_copy(_InputIter __first, _InputIter __last, _ForwardIter __result,
1.66 + const __false_type&)
1.67 +{
1.68 + _STLP_LEAVE_VOLATILE _ForwardIter __cur = __result;
1.69 + _STLP_TRY {
1.70 + for ( ; __first != __last; ++__first, ++__cur)
1.71 + _Construct(&*__cur, *__first);
1.72 + // return __cur;
1.73 + }
1.74 + _STLP_UNWIND (_STLP_STD::_Destroy(__result, __cur));
1.75 + return __cur;
1.76 +}
1.77 +
1.78 +template <class _InputIter, class _ForwardIter>
1.79 +inline _ForwardIter
1.80 +uninitialized_copy(_InputIter __first, _InputIter __last, _ForwardIter __result) {
1.81 + return __uninitialized_copy(__first, __last, __result, _IS_POD_ITER(__result, _ForwardIter));
1.82 +}
1.83 +
1.84 +inline char*
1.85 +uninitialized_copy(const char* __first, const char* __last, char* __result) {
1.86 + return (char*)__copy_trivial (__first, __last, __result);
1.87 +}
1.88 +
1.89 +# ifdef _STLP_HAS_WCHAR_T // dwa 8/15/97
1.90 +inline wchar_t*
1.91 +uninitialized_copy(const wchar_t* __first, const wchar_t* __last, wchar_t* __result) {
1.92 + return (wchar_t*)__copy_trivial (__first, __last, __result);
1.93 +}
1.94 +# endif /* _STLP_HAS_WCHAR_T */
1.95 +
1.96 +# ifndef _STLP_NO_EXTENSIONS
1.97 +// uninitialized_copy_n (not part of the C++ standard)
1.98 +
1.99 +template <class _InputIter, class _Size, class _ForwardIter>
1.100 +// _STLP_INLINE_LOOP
1.101 +pair<_InputIter, _ForwardIter>
1.102 +__uninitialized_copy_n(_InputIter __first, _Size __count,
1.103 + _ForwardIter __result,
1.104 + const input_iterator_tag &)
1.105 +{
1.106 + _STLP_LEAVE_VOLATILE _ForwardIter __cur = __result;
1.107 + _STLP_TRY {
1.108 + for ( ; __count > 0 ; --__count, ++__first, ++__cur)
1.109 + _Construct(&*__cur, *__first);
1.110 + // return pair<_InputIter, _ForwardIter>(__first, __cur);
1.111 + }
1.112 + _STLP_UNWIND(_STLP_STD::_Destroy(__result, __cur));
1.113 +
1.114 + return pair<_InputIter, _ForwardIter>(__first, __cur);
1.115 +
1.116 +}
1.117 +
1.118 +# if defined(_STLP_NONTEMPL_BASE_MATCH_BUG)
1.119 +template <class _InputIterator, class _Size, class _ForwardIterator>
1.120 +inline pair<_InputIterator, _ForwardIterator>
1.121 +__uninitialized_copy_n(_InputIterator __first, _Size __count,
1.122 + _ForwardIterator __result,
1.123 + const forward_iterator_tag &) {
1.124 + return __uninitialized_copy_n(__first, __count, __result, input_iterator_tag());
1.125 +}
1.126 +
1.127 +template <class _InputIterator, class _Size, class _ForwardIterator>
1.128 +inline pair<_InputIterator, _ForwardIterator>
1.129 +__uninitialized_copy_n(_InputIterator __first, _Size __count,
1.130 + _ForwardIterator __result,
1.131 + const bidirectional_iterator_tag &) {
1.132 + return __uninitialized_copy_n(__first, __count, __result, input_iterator_tag());
1.133 +}
1.134 +# endif
1.135 +
1.136 +
1.137 +template <class _RandomAccessIter, class _Size, class _ForwardIter>
1.138 +inline pair<_RandomAccessIter, _ForwardIter>
1.139 +__uninitialized_copy_n(_RandomAccessIter __first, _Size __count, _ForwardIter __result, const random_access_iterator_tag &) {
1.140 + _RandomAccessIter __last = __first + __count;
1.141 + return pair<_RandomAccessIter, _ForwardIter>( __last, __uninitialized_copy(__first, __last, __result,
1.142 + _IS_POD_ITER(__result, _ForwardIter)));
1.143 +}
1.144 +
1.145 +// this is used internally in <rope> , which is extension itself.
1.146 +template <class _InputIter, class _Size, class _ForwardIter>
1.147 +inline pair<_InputIter, _ForwardIter>
1.148 +uninitialized_copy_n(_InputIter __first, _Size __count,
1.149 + _ForwardIter __result) {
1.150 + return __uninitialized_copy_n(__first, __count, __result, _STLP_ITERATOR_CATEGORY(__first, _InputIter));
1.151 +}
1.152 +# endif /* _STLP_NO_EXTENSIONS */
1.153 +
1.154 +// Valid if copy construction is equivalent to assignment, and if the
1.155 +// destructor is trivial.
1.156 +template <class _ForwardIter, class _Tp>
1.157 +inline void
1.158 +__uninitialized_fill(_ForwardIter __first, _ForwardIter __last,
1.159 + const _Tp& __x, const __true_type&) {
1.160 + _STLP_STD::fill(__first, __last, __x);
1.161 +}
1.162 +
1.163 +template <class _ForwardIter, class _Tp>
1.164 +// _STLP_INLINE_LOOP
1.165 +void
1.166 +__uninitialized_fill(_ForwardIter __first, _ForwardIter __last,
1.167 + const _Tp& __x, const __false_type&)
1.168 +{
1.169 + _STLP_LEAVE_VOLATILE _ForwardIter __cur = __first;
1.170 + _STLP_TRY {
1.171 + for ( ; __cur != __last; ++__cur)
1.172 + _Construct(&*__cur, __x);
1.173 + }
1.174 + _STLP_UNWIND(_STLP_STD::_Destroy(__first, __cur));
1.175 +}
1.176 +
1.177 +template <class _ForwardIter, class _Tp>
1.178 +inline void uninitialized_fill(_ForwardIter __first, _ForwardIter __last, const _Tp& __x) {
1.179 + __uninitialized_fill(__first, __last, __x, _IS_POD_ITER(__first, _ForwardIter));
1.180 +}
1.181 +
1.182 +// Valid if copy construction is equivalent to assignment, and if the
1.183 +// destructor is trivial.
1.184 +template <class _ForwardIter, class _Size, class _Tp>
1.185 +inline _ForwardIter
1.186 +__uninitialized_fill_n(_ForwardIter __first, _Size __n,
1.187 + const _Tp& __x, const __true_type&) {
1.188 + return _STLP_STD::fill_n(__first, __n, __x);
1.189 +}
1.190 +
1.191 +template <class _ForwardIter, class _Size, class _Tp>
1.192 +//_STLP_INLINE_LOOP
1.193 +_ForwardIter
1.194 +__uninitialized_fill_n(_ForwardIter __first, _Size __n,
1.195 + const _Tp& __x, const __false_type&)
1.196 +{
1.197 + _STLP_LEAVE_VOLATILE _ForwardIter __cur = __first;
1.198 + _STLP_TRY {
1.199 + for ( ; __n > 0; --__n, ++__cur)
1.200 + _Construct(&*__cur, __x);
1.201 + // return __cur;
1.202 + }
1.203 + _STLP_UNWIND(_STLP_STD::_Destroy(__first, __cur));
1.204 + // # ifdef _STLP_THROW_RETURN_BUG
1.205 + return __cur;
1.206 + //# endif
1.207 +}
1.208 +
1.209 +template <class _ForwardIter, class _Size, class _Tp>
1.210 +inline _ForwardIter
1.211 +uninitialized_fill_n(_ForwardIter __first, _Size __n, const _Tp& __x) {
1.212 + return __uninitialized_fill_n(__first, __n, __x, _IS_POD_ITER(__first, _ForwardIter));
1.213 +}
1.214 +
1.215 +// Extensions: __uninitialized_copy_copy, __uninitialized_copy_fill,
1.216 +// __uninitialized_fill_copy.
1.217 +
1.218 +// __uninitialized_copy_copy
1.219 +// Copies [first1, last1) into [result, result + (last1 - first1)), and
1.220 +// copies [first2, last2) into
1.221 +// [result, result + (last1 - first1) + (last2 - first2)).
1.222 +
1.223 +template <class _InputIter1, class _InputIter2, class _ForwardIter>
1.224 +inline _ForwardIter
1.225 +__uninitialized_copy_copy(_InputIter1 __first1, _InputIter1 __last1,
1.226 + _InputIter2 __first2, _InputIter2 __last2,
1.227 + _ForwardIter __result, __true_type)
1.228 +{
1.229 + return __uninitialized_copy(__first2, __last2,
1.230 + __uninitialized_copy(__first1, __last1, __result, __true_type()), __true_type());
1.231 +}
1.232 +
1.233 +template <class _InputIter1, class _InputIter2, class _ForwardIter>
1.234 +// inline
1.235 +_ForwardIter
1.236 +__uninitialized_copy_copy(_InputIter1 __first1, _InputIter1 __last1,
1.237 + _InputIter2 __first2, _InputIter2 __last2,
1.238 + _ForwardIter __result, __false_type)
1.239 +{
1.240 + _STLP_LEAVE_VOLATILE _ForwardIter __mid = __uninitialized_copy(__first1, __last1, __result, _IS_POD_ITER(__result, _ForwardIter));
1.241 +
1.242 + _STLP_TRY {
1.243 + return __uninitialized_copy(__first2, __last2, __mid , _IS_POD_ITER(__result, _ForwardIter));
1.244 + }
1.245 + _STLP_UNWIND (_STLP_STD::_Destroy(__result, __mid));
1.246 +# ifdef _STLP_THROW_RETURN_BUG
1.247 + return __mid;
1.248 +# endif
1.249 +}
1.250 +
1.251 +// __uninitialized_fill_copy
1.252 +// Fills [result, mid) with x, and copies [first, last) into
1.253 +// [mid, mid + (last - first)).
1.254 +template <class _ForwardIter, class _Tp, class _InputIter>
1.255 +// inline
1.256 +_ForwardIter
1.257 +__uninitialized_fill_copy(_ForwardIter __result, _ForwardIter __mid, const _Tp& __x,
1.258 + _InputIter __first, _InputIter __last)
1.259 +{
1.260 + typedef typename __type_traits<_Tp>::is_POD_type _I_POD;
1.261 + __uninitialized_fill(__result, __mid, __x, _I_POD());
1.262 + _STLP_TRY {
1.263 + return __uninitialized_copy(__first, __last, __mid, _I_POD());
1.264 + }
1.265 + _STLP_UNWIND (_STLP_STD::_Destroy(__result, __mid));
1.266 +# ifdef _STLP_THROW_RETURN_BUG
1.267 + return __result;
1.268 +# endif
1.269 +}
1.270 +
1.271 +// __uninitialized_copy_fill
1.272 +// Copies [first1, last1) into [first2, first2 + (last1 - first1)), and
1.273 +// fills [first2 + (last1 - first1), last2) with x.
1.274 +template <class _InputIter, class _ForwardIter, class _Tp>
1.275 +// inline
1.276 +void
1.277 +__uninitialized_copy_fill(_InputIter __first1, _InputIter __last1,
1.278 + _ForwardIter __first2, _ForwardIter __last2,
1.279 + const _Tp& __x)
1.280 +{
1.281 + typedef typename __type_traits<_Tp>::is_POD_type _I_POD;
1.282 + _ForwardIter __mid2 = __uninitialized_copy(__first1, __last1, __first2, _I_POD());
1.283 + _STLP_TRY {
1.284 + __uninitialized_fill(__mid2, __last2, __x, _I_POD());
1.285 + }
1.286 + _STLP_UNWIND(_STLP_STD::_Destroy(__first2, __mid2));
1.287 +}
1.288 +
1.289 +_STLP_END_NAMESPACE
1.290 +
1.291 +#endif /* _STLP_INTERNAL_UNINITIALIZED_H */
1.292 +
1.293 +// Local Variables:
1.294 +// mode:C++
1.295 +// End: