56 #ifndef _STL_UNINITIALIZED_H
57 #define _STL_UNINITIALIZED_H 1
59 namespace std _GLIBCXX_VISIBILITY(default)
61 _GLIBCXX_BEGIN_NAMESPACE_VERSION
63 template<
bool _TrivialValueTypes>
64 struct __uninitialized_copy
66 template<
typename _InputIterator,
typename _ForwardIterator>
67 static _ForwardIterator
68 __uninit_copy(_InputIterator __first, _InputIterator __last,
69 _ForwardIterator __result)
71 _ForwardIterator __cur = __result;
74 for (; __first != __last; ++__first, ++__cur)
81 __throw_exception_again;
87 struct __uninitialized_copy<true>
89 template<
typename _InputIterator,
typename _ForwardIterator>
90 static _ForwardIterator
91 __uninit_copy(_InputIterator __first, _InputIterator __last,
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_trivial(_ValueType1)
116 && __is_trivial(_ValueType2))>::
117 __uninit_copy(__first, __last, __result);
121 template<
bool _TrivialValueType>
122 struct __uninitialized_fill
124 template<
typename _ForwardIterator,
typename _Tp>
126 __uninit_fill(_ForwardIterator __first, _ForwardIterator __last,
129 _ForwardIterator __cur = __first;
132 for (; __cur != __last; ++__cur)
138 __throw_exception_again;
144 struct __uninitialized_fill<true>
146 template<
typename _ForwardIterator,
typename _Tp>
148 __uninit_fill(_ForwardIterator __first, _ForwardIterator __last,
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_trivial(_ValueType)>::
171 __uninit_fill(__first, __last, __x);
175 template<
bool _TrivialValueType>
176 struct __uninitialized_fill_n
178 template<
typename _ForwardIterator,
typename _Size,
typename _Tp>
180 __uninit_fill_n(_ForwardIterator __first, _Size __n,
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>
202 __uninit_fill_n(_ForwardIterator __first, _Size __n,
216 template<
typename _ForwardIterator,
typename _Size,
typename _Tp>
220 typedef typename iterator_traits<_ForwardIterator>::value_type
223 std::__uninitialized_fill_n<__is_trivial(_ValueType)>::
224 __uninit_fill_n(__first, __n, __x);
233 template<
typename _InputIterator,
typename _ForwardIterator,
236 __uninitialized_copy_a(_InputIterator __first, _InputIterator __last,
237 _ForwardIterator __result, _Allocator& __alloc)
239 _ForwardIterator __cur = __result;
243 for (; __first != __last; ++__first, ++__cur)
250 __throw_exception_again;
254 template<
typename _InputIterator,
typename _ForwardIterator,
typename _Tp>
255 inline _ForwardIterator
256 __uninitialized_copy_a(_InputIterator __first, _InputIterator __last,
257 _ForwardIterator __result, allocator<_Tp>&)
260 template<
typename _InputIterator,
typename _ForwardIterator,
262 inline _ForwardIterator
263 __uninitialized_move_a(_InputIterator __first, _InputIterator __last,
264 _ForwardIterator __result, _Allocator& __alloc)
266 return std::__uninitialized_copy_a(_GLIBCXX_MAKE_MOVE_ITERATOR(__first),
267 _GLIBCXX_MAKE_MOVE_ITERATOR(__last),
271 template<
typename _InputIterator,
typename _ForwardIterator,
273 inline _ForwardIterator
274 __uninitialized_move_if_noexcept_a(_InputIterator __first,
275 _InputIterator __last,
276 _ForwardIterator __result,
279 return std::__uninitialized_copy_a
280 (_GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(__first),
281 _GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(__last), __result, __alloc);
284 template<
typename _ForwardIterator,
typename _Tp,
typename _Allocator>
286 __uninitialized_fill_a(_ForwardIterator __first, _ForwardIterator __last,
287 const _Tp& __x, _Allocator& __alloc)
289 _ForwardIterator __cur = __first;
293 for (; __cur != __last; ++__cur)
299 __throw_exception_again;
303 template<
typename _ForwardIterator,
typename _Tp,
typename _Tp2>
305 __uninitialized_fill_a(_ForwardIterator __first, _ForwardIterator __last,
306 const _Tp& __x, allocator<_Tp2>&)
309 template<
typename _ForwardIterator,
typename _Size,
typename _Tp,
312 __uninitialized_fill_n_a(_ForwardIterator __first, _Size __n,
313 const _Tp& __x, _Allocator& __alloc)
315 _ForwardIterator __cur = __first;
319 for (; __n > 0; --__n, ++__cur)
325 __throw_exception_again;
329 template<
typename _ForwardIterator,
typename _Size,
typename _Tp,
332 __uninitialized_fill_n_a(_ForwardIterator __first, _Size __n,
333 const _Tp& __x, allocator<_Tp2>&)
346 template<
typename _InputIterator1,
typename _InputIterator2,
347 typename _ForwardIterator,
typename _Allocator>
348 inline _ForwardIterator
349 __uninitialized_copy_move(_InputIterator1 __first1,
350 _InputIterator1 __last1,
351 _InputIterator2 __first2,
352 _InputIterator2 __last2,
353 _ForwardIterator __result,
356 _ForwardIterator __mid = std::__uninitialized_copy_a(__first1, __last1,
361 return std::__uninitialized_move_a(__first2, __last2, __mid, __alloc);
366 __throw_exception_again;
374 template<
typename _InputIterator1,
typename _InputIterator2,
375 typename _ForwardIterator,
typename _Allocator>
376 inline _ForwardIterator
377 __uninitialized_move_copy(_InputIterator1 __first1,
378 _InputIterator1 __last1,
379 _InputIterator2 __first2,
380 _InputIterator2 __last2,
381 _ForwardIterator __result,
384 _ForwardIterator __mid = std::__uninitialized_move_a(__first1, __last1,
389 return std::__uninitialized_copy_a(__first2, __last2, __mid, __alloc);
394 __throw_exception_again;
401 template<
typename _ForwardIterator,
typename _Tp,
typename _InputIterator,
403 inline _ForwardIterator
404 __uninitialized_fill_move(_ForwardIterator __result, _ForwardIterator __mid,
405 const _Tp& __x, _InputIterator __first,
406 _InputIterator __last, _Allocator& __alloc)
408 std::__uninitialized_fill_a(__result, __mid, __x, __alloc);
411 return std::__uninitialized_move_a(__first, __last, __mid, __alloc);
416 __throw_exception_again;
423 template<
typename _InputIterator,
typename _ForwardIterator,
typename _Tp,
426 __uninitialized_move_fill(_InputIterator __first1, _InputIterator __last1,
427 _ForwardIterator __first2,
428 _ForwardIterator __last2,
const _Tp& __x,
431 _ForwardIterator __mid2 = std::__uninitialized_move_a(__first1, __last1,
436 std::__uninitialized_fill_a(__mid2, __last2, __x, __alloc);
441 __throw_exception_again;
445 #if __cplusplus >= 201103L
449 template<
bool _TrivialValueType>
450 struct __uninitialized_default_1
452 template<
typename _ForwardIterator>
454 __uninit_default(_ForwardIterator __first, _ForwardIterator __last)
456 _ForwardIterator __cur = __first;
459 for (; __cur != __last; ++__cur)
465 __throw_exception_again;
471 struct __uninitialized_default_1<true>
473 template<
typename _ForwardIterator>
475 __uninit_default(_ForwardIterator __first, _ForwardIterator __last)
477 typedef typename iterator_traits<_ForwardIterator>::value_type
480 std::fill(__first, __last, _ValueType());
484 template<
bool _TrivialValueType>
485 struct __uninitialized_default_n_1
487 template<
typename _ForwardIterator,
typename _Size>
489 __uninit_default_n(_ForwardIterator __first, _Size __n)
491 _ForwardIterator __cur = __first;
494 for (; __n > 0; --__n, ++__cur)
500 __throw_exception_again;
506 struct __uninitialized_default_n_1<true>
508 template<
typename _ForwardIterator,
typename _Size>
510 __uninit_default_n(_ForwardIterator __first, _Size __n)
512 typedef typename iterator_traits<_ForwardIterator>::value_type
522 template<
typename _ForwardIterator>
524 __uninitialized_default(_ForwardIterator __first,
525 _ForwardIterator __last)
527 typedef typename iterator_traits<_ForwardIterator>::value_type
530 std::__uninitialized_default_1<__is_trivial(_ValueType)>::
531 __uninit_default(__first, __last);
536 template<
typename _ForwardIterator,
typename _Size>
538 __uninitialized_default_n(_ForwardIterator __first, _Size __n)
540 typedef typename iterator_traits<_ForwardIterator>::value_type
543 std::__uninitialized_default_n_1<__is_trivial(_ValueType)>::
544 __uninit_default_n(__first, __n);
551 template<
typename _ForwardIterator,
typename _Allocator>
553 __uninitialized_default_a(_ForwardIterator __first,
554 _ForwardIterator __last,
557 _ForwardIterator __cur = __first;
561 for (; __cur != __last; ++__cur)
567 __throw_exception_again;
571 template<
typename _ForwardIterator,
typename _Tp>
573 __uninitialized_default_a(_ForwardIterator __first,
574 _ForwardIterator __last,
576 { std::__uninitialized_default(__first, __last); }
582 template<
typename _ForwardIterator,
typename _Size,
typename _Allocator>
584 __uninitialized_default_n_a(_ForwardIterator __first, _Size __n,
587 _ForwardIterator __cur = __first;
591 for (; __n > 0; --__n, ++__cur)
597 __throw_exception_again;
601 template<
typename _ForwardIterator,
typename _Size,
typename _Tp>
603 __uninitialized_default_n_a(_ForwardIterator __first, _Size __n,
605 { std::__uninitialized_default_n(__first, __n); }
608 template<
typename _InputIterator,
typename _Size,
609 typename _ForwardIterator>
611 __uninitialized_copy_n(_InputIterator __first, _Size __n,
612 _ForwardIterator __result, input_iterator_tag)
614 _ForwardIterator __cur = __result;
617 for (; __n > 0; --__n, ++__first, ++__cur)
624 __throw_exception_again;
628 template<
typename _RandomAccessIterator,
typename _Size,
629 typename _ForwardIterator>
630 inline _ForwardIterator
631 __uninitialized_copy_n(_RandomAccessIterator __first, _Size __n,
632 _ForwardIterator __result,
633 random_access_iterator_tag)
645 template<
typename _InputIterator,
typename _Size,
typename _ForwardIterator>
646 inline _ForwardIterator
648 _ForwardIterator __result)
649 {
return std::__uninitialized_copy_n(__first, __n, __result,
653 _GLIBCXX_END_NAMESPACE_VERSION
_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).
Uniform interface to C++98 and C++0x allocators.
void uninitialized_fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp &__x)
Copies the value x into the range [first,last).
_Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
void _Construct(_T1 *__p, _Args &&...__args)
ISO C++ entities toplevel namespace is std.
iterator_traits< _Iter >::iterator_category __iterator_category(const _Iter &)
_ForwardIterator uninitialized_copy(_InputIterator __first, _InputIterator __last, _ForwardIterator __result)
Copies the range [first,last) into result.
void _Destroy(_Tp *__pointer)
_ForwardIterator uninitialized_copy_n(_InputIterator __first, _Size __n, _ForwardIterator __result)
Copies the range [first,first+n) into result.