57 #ifndef _STL_UNINITIALIZED_H
58 #define _STL_UNINITIALIZED_H 1
60 _GLIBCXX_BEGIN_NAMESPACE(
std)
63 struct __uninitialized_copy
65 template<
typename _InputIterator,
typename _ForwardIterator>
66 static _ForwardIterator
68 _ForwardIterator __result)
70 _ForwardIterator __cur = __result;
73 for (; __first != __last; ++__first, ++__cur)
74 ::
new(static_cast<void*>(&*__cur))
typename
75 iterator_traits<_ForwardIterator>::value_type(*__first);
81 __throw_exception_again;
87 struct __uninitialized_copy<true>
89 template<
typename _InputIterator,
typename _ForwardIterator>
90 static _ForwardIterator
92 _ForwardIterator __result)
93 {
return std::copy(__first, __last, __result); }
105 template<
typename _InputIterator,
typename _ForwardIterator>
106 inline _ForwardIterator
108 _ForwardIterator __result)
110 typedef typename iterator_traits<_InputIterator>::value_type
112 typedef typename iterator_traits<_ForwardIterator>::value_type
115 return std::__uninitialized_copy<(__is_pod(_ValueType1)
116 && __is_pod(_ValueType2))>::
122 struct __uninitialized_fill
124 template<
typename _ForwardIterator,
typename _Tp>
127 _ForwardIterator __last,
const _Tp& __x)
129 _ForwardIterator __cur = __first;
132 for (; __cur != __last; ++__cur)
138 __throw_exception_again;
144 struct __uninitialized_fill<true>
146 template<
typename _ForwardIterator,
typename _Tp>
149 _ForwardIterator __last,
const _Tp& __x)
150 { std::fill(__first, __last, __x); }
162 template<
typename _ForwardIterator,
typename _Tp>
167 typedef typename iterator_traits<_ForwardIterator>::value_type
170 std::__uninitialized_fill<__is_pod(_ValueType)>
::
176 struct __uninitialized_fill_n
178 template<
typename _ForwardIterator,
typename _Size,
typename _Tp>
183 _ForwardIterator __cur = __first;
186 for (; __n > 0; --__n, ++__cur)
192 __throw_exception_again;
198 struct __uninitialized_fill_n<true>
200 template<
typename _ForwardIterator,
typename _Size,
typename _Tp>
216 template<
typename _ForwardIterator,
typename _Size,
typename _Tp>
220 typedef typename iterator_traits<_ForwardIterator>::value_type
223 std::__uninitialized_fill_n<__is_pod(_ValueType)>
::
233 template<
typename _InputIterator,
typename _ForwardIterator,
236 __uninitialized_copy_a(_InputIterator __first, _InputIterator __last,
237 _ForwardIterator __result, _Allocator& __alloc)
239 _ForwardIterator __cur = __result;
242 for (; __first != __last; ++__first, ++__cur)
243 __alloc.construct(&*__cur, *__first);
249 __throw_exception_again;
253 template<
typename _InputIterator,
typename _ForwardIterator,
typename _Tp>
254 inline _ForwardIterator
255 __uninitialized_copy_a(_InputIterator __first, _InputIterator __last,
256 _ForwardIterator __result, allocator<_Tp>&)
259 template<
typename _InputIterator,
typename _ForwardIterator,
261 inline _ForwardIterator
262 __uninitialized_move_a(_InputIterator __first, _InputIterator __last,
263 _ForwardIterator __result, _Allocator& __alloc)
265 return std::__uninitialized_copy_a(_GLIBCXX_MAKE_MOVE_ITERATOR(__first),
266 _GLIBCXX_MAKE_MOVE_ITERATOR(__last),
270 template<
typename _ForwardIterator,
typename _Tp,
typename _Allocator>
272 __uninitialized_fill_a(_ForwardIterator __first, _ForwardIterator __last,
273 const _Tp& __x, _Allocator& __alloc)
275 _ForwardIterator __cur = __first;
278 for (; __cur != __last; ++__cur)
279 __alloc.construct(&*__cur, __x);
284 __throw_exception_again;
288 template<
typename _ForwardIterator,
typename _Tp,
typename _Tp2>
290 __uninitialized_fill_a(_ForwardIterator __first, _ForwardIterator __last,
291 const _Tp& __x, allocator<_Tp2>&)
294 template<
typename _ForwardIterator,
typename _Size,
typename _Tp,
297 __uninitialized_fill_n_a(_ForwardIterator __first, _Size __n,
298 const _Tp& __x, _Allocator& __alloc)
300 _ForwardIterator __cur = __first;
303 for (; __n > 0; --__n, ++__cur)
304 __alloc.construct(&*__cur, __x);
309 __throw_exception_again;
313 template<
typename _ForwardIterator,
typename _Size,
typename _Tp,
316 __uninitialized_fill_n_a(_ForwardIterator __first, _Size __n,
317 const _Tp& __x, allocator<_Tp2>&)
330 template<
typename _InputIterator1,
typename _InputIterator2,
331 typename _ForwardIterator,
typename _Allocator>
332 inline _ForwardIterator
333 __uninitialized_copy_move(_InputIterator1 __first1,
334 _InputIterator1 __last1,
335 _InputIterator2 __first2,
336 _InputIterator2 __last2,
337 _ForwardIterator __result,
340 _ForwardIterator __mid = std::__uninitialized_copy_a(__first1, __last1,
345 return std::__uninitialized_move_a(__first2, __last2, __mid, __alloc);
350 __throw_exception_again;
358 template<
typename _InputIterator1,
typename _InputIterator2,
359 typename _ForwardIterator,
typename _Allocator>
360 inline _ForwardIterator
361 __uninitialized_move_copy(_InputIterator1 __first1,
362 _InputIterator1 __last1,
363 _InputIterator2 __first2,
364 _InputIterator2 __last2,
365 _ForwardIterator __result,
368 _ForwardIterator __mid = std::__uninitialized_move_a(__first1, __last1,
373 return std::__uninitialized_copy_a(__first2, __last2, __mid, __alloc);
378 __throw_exception_again;
385 template<
typename _ForwardIterator,
typename _Tp,
typename _InputIterator,
387 inline _ForwardIterator
388 __uninitialized_fill_move(_ForwardIterator __result, _ForwardIterator __mid,
389 const _Tp& __x, _InputIterator __first,
390 _InputIterator __last, _Allocator& __alloc)
392 std::__uninitialized_fill_a(__result, __mid, __x, __alloc);
395 return std::__uninitialized_move_a(__first, __last, __mid, __alloc);
400 __throw_exception_again;
407 template<
typename _InputIterator,
typename _ForwardIterator,
typename _Tp,
410 __uninitialized_move_fill(_InputIterator __first1, _InputIterator __last1,
411 _ForwardIterator __first2,
412 _ForwardIterator __last2,
const _Tp& __x,
415 _ForwardIterator __mid2 = std::__uninitialized_move_a(__first1, __last1,
420 std::__uninitialized_fill_a(__mid2, __last2, __x, __alloc);
425 __throw_exception_again;
429 #ifdef __GXX_EXPERIMENTAL_CXX0X__
430 template<
typename _InputIterator,
typename _Size,
431 typename _ForwardIterator>
433 __uninitialized_copy_n(_InputIterator __first, _Size __n,
434 _ForwardIterator __result, input_iterator_tag)
436 _ForwardIterator __cur = __result;
439 for (; __n > 0; --__n, ++__first, ++__cur)
440 ::
new(static_cast<void*>(&*__cur))
typename
441 iterator_traits<_ForwardIterator>::value_type(*__first);
447 __throw_exception_again;
451 template<
typename _RandomAccessIterator,
typename _Size,
452 typename _ForwardIterator>
453 inline _ForwardIterator
454 __uninitialized_copy_n(_RandomAccessIterator __first, _Size __n,
455 _ForwardIterator __result,
456 random_access_iterator_tag)
468 template<
typename _InputIterator,
typename _Size,
typename _ForwardIterator>
469 inline _ForwardIterator
471 _ForwardIterator __result)
472 {
return std::__uninitialized_copy_n(__first, __n, __result,
476 _GLIBCXX_END_NAMESPACE
_OI fill_n(_OI __first, _Size __n, const _Tp &__value)
Fills the range [first,first+n) with copies of value.
void uninitialized_fill_n(_ForwardIterator __first, _Size __n, const _Tp &__x)
Copies the value x into the range [first,first+n).
void uninitialized_fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp &__x)
Copies the value x into the range [first,last).
ISO C++ entities toplevel namespace is std.
_ForwardIterator uninitialized_copy_n(_InputIterator __first, _Size __n, _ForwardIterator __result)
Copies the range [first,first+n) into result.
iterator_traits< _Iter >::iterator_category __iterator_category(const _Iter &)
void _Construct(_T1 *__p, const _T2 &__value)
void _Destroy(_Tp *__pointer)
_ForwardIterator uninitialized_copy(_InputIterator __first, _InputIterator __last, _ForwardIterator __result)
Copies the range [first,last) into result.