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
114 #if __cplusplus < 201103L
115 const bool __assignable =
true;
118 typedef typename iterator_traits<_InputIterator>::reference _RefType;
119 const bool __assignable = is_assignable<_ValueType1, _RefType>::value;
122 return std::__uninitialized_copy<__is_trivial(_ValueType1)
123 && __is_trivial(_ValueType2)
125 __uninit_copy(__first, __last, __result);
129 template<
bool _TrivialValueType>
130 struct __uninitialized_fill
132 template<
typename _ForwardIterator,
typename _Tp>
134 __uninit_fill(_ForwardIterator __first, _ForwardIterator __last,
137 _ForwardIterator __cur = __first;
140 for (; __cur != __last; ++__cur)
146 __throw_exception_again;
152 struct __uninitialized_fill<true>
154 template<
typename _ForwardIterator,
typename _Tp>
156 __uninit_fill(_ForwardIterator __first, _ForwardIterator __last,
158 { std::fill(__first, __last, __x); }
170 template<
typename _ForwardIterator,
typename _Tp>
175 typedef typename iterator_traits<_ForwardIterator>::value_type
177 #if __cplusplus < 201103L
178 const bool __assignable =
true;
181 const bool __assignable = is_copy_assignable<_ValueType>::value;
184 std::__uninitialized_fill<__is_trivial(_ValueType) && __assignable>::
185 __uninit_fill(__first, __last, __x);
189 template<
bool _TrivialValueType>
190 struct __uninitialized_fill_n
192 template<
typename _ForwardIterator,
typename _Size,
typename _Tp>
194 __uninit_fill_n(_ForwardIterator __first, _Size __n,
197 _ForwardIterator __cur = __first;
200 for (; __n > 0; --__n, ++__cur)
206 __throw_exception_again;
212 struct __uninitialized_fill_n<true>
214 template<
typename _ForwardIterator,
typename _Size,
typename _Tp>
216 __uninit_fill_n(_ForwardIterator __first, _Size __n,
230 template<
typename _ForwardIterator,
typename _Size,
typename _Tp>
234 typedef typename iterator_traits<_ForwardIterator>::value_type
236 #if __cplusplus < 201103L
237 const bool __assignable =
true;
240 const bool __assignable = is_copy_assignable<_ValueType>::value;
243 std::__uninitialized_fill_n<__is_trivial(_ValueType) && __assignable>::
244 __uninit_fill_n(__first, __n, __x);
253 template<
typename _InputIterator,
typename _ForwardIterator,
256 __uninitialized_copy_a(_InputIterator __first, _InputIterator __last,
257 _ForwardIterator __result, _Allocator& __alloc)
259 _ForwardIterator __cur = __result;
263 for (; __first != __last; ++__first, ++__cur)
270 __throw_exception_again;
274 template<
typename _InputIterator,
typename _ForwardIterator,
typename _Tp>
275 inline _ForwardIterator
276 __uninitialized_copy_a(_InputIterator __first, _InputIterator __last,
277 _ForwardIterator __result, allocator<_Tp>&)
280 template<
typename _InputIterator,
typename _ForwardIterator,
282 inline _ForwardIterator
283 __uninitialized_move_a(_InputIterator __first, _InputIterator __last,
284 _ForwardIterator __result, _Allocator& __alloc)
286 return std::__uninitialized_copy_a(_GLIBCXX_MAKE_MOVE_ITERATOR(__first),
287 _GLIBCXX_MAKE_MOVE_ITERATOR(__last),
291 template<
typename _InputIterator,
typename _ForwardIterator,
293 inline _ForwardIterator
294 __uninitialized_move_if_noexcept_a(_InputIterator __first,
295 _InputIterator __last,
296 _ForwardIterator __result,
299 return std::__uninitialized_copy_a
300 (_GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(__first),
301 _GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(__last), __result, __alloc);
304 template<
typename _ForwardIterator,
typename _Tp,
typename _Allocator>
306 __uninitialized_fill_a(_ForwardIterator __first, _ForwardIterator __last,
307 const _Tp& __x, _Allocator& __alloc)
309 _ForwardIterator __cur = __first;
313 for (; __cur != __last; ++__cur)
319 __throw_exception_again;
323 template<
typename _ForwardIterator,
typename _Tp,
typename _Tp2>
325 __uninitialized_fill_a(_ForwardIterator __first, _ForwardIterator __last,
326 const _Tp& __x, allocator<_Tp2>&)
329 template<
typename _ForwardIterator,
typename _Size,
typename _Tp,
332 __uninitialized_fill_n_a(_ForwardIterator __first, _Size __n,
333 const _Tp& __x, _Allocator& __alloc)
335 _ForwardIterator __cur = __first;
339 for (; __n > 0; --__n, ++__cur)
345 __throw_exception_again;
349 template<
typename _ForwardIterator,
typename _Size,
typename _Tp,
352 __uninitialized_fill_n_a(_ForwardIterator __first, _Size __n,
353 const _Tp& __x, allocator<_Tp2>&)
366 template<
typename _InputIterator1,
typename _InputIterator2,
367 typename _ForwardIterator,
typename _Allocator>
368 inline _ForwardIterator
369 __uninitialized_copy_move(_InputIterator1 __first1,
370 _InputIterator1 __last1,
371 _InputIterator2 __first2,
372 _InputIterator2 __last2,
373 _ForwardIterator __result,
376 _ForwardIterator __mid = std::__uninitialized_copy_a(__first1, __last1,
381 return std::__uninitialized_move_a(__first2, __last2, __mid, __alloc);
386 __throw_exception_again;
394 template<
typename _InputIterator1,
typename _InputIterator2,
395 typename _ForwardIterator,
typename _Allocator>
396 inline _ForwardIterator
397 __uninitialized_move_copy(_InputIterator1 __first1,
398 _InputIterator1 __last1,
399 _InputIterator2 __first2,
400 _InputIterator2 __last2,
401 _ForwardIterator __result,
404 _ForwardIterator __mid = std::__uninitialized_move_a(__first1, __last1,
409 return std::__uninitialized_copy_a(__first2, __last2, __mid, __alloc);
414 __throw_exception_again;
421 template<
typename _ForwardIterator,
typename _Tp,
typename _InputIterator,
423 inline _ForwardIterator
424 __uninitialized_fill_move(_ForwardIterator __result, _ForwardIterator __mid,
425 const _Tp& __x, _InputIterator __first,
426 _InputIterator __last, _Allocator& __alloc)
428 std::__uninitialized_fill_a(__result, __mid, __x, __alloc);
431 return std::__uninitialized_move_a(__first, __last, __mid, __alloc);
436 __throw_exception_again;
443 template<
typename _InputIterator,
typename _ForwardIterator,
typename _Tp,
446 __uninitialized_move_fill(_InputIterator __first1, _InputIterator __last1,
447 _ForwardIterator __first2,
448 _ForwardIterator __last2,
const _Tp& __x,
451 _ForwardIterator __mid2 = std::__uninitialized_move_a(__first1, __last1,
456 std::__uninitialized_fill_a(__mid2, __last2, __x, __alloc);
461 __throw_exception_again;
465 #if __cplusplus >= 201103L
469 template<
bool _TrivialValueType>
470 struct __uninitialized_default_1
472 template<
typename _ForwardIterator>
474 __uninit_default(_ForwardIterator __first, _ForwardIterator __last)
476 _ForwardIterator __cur = __first;
479 for (; __cur != __last; ++__cur)
485 __throw_exception_again;
491 struct __uninitialized_default_1<true>
493 template<
typename _ForwardIterator>
495 __uninit_default(_ForwardIterator __first, _ForwardIterator __last)
497 typedef typename iterator_traits<_ForwardIterator>::value_type
500 std::fill(__first, __last, _ValueType());
504 template<
bool _TrivialValueType>
505 struct __uninitialized_default_n_1
507 template<
typename _ForwardIterator,
typename _Size>
509 __uninit_default_n(_ForwardIterator __first, _Size __n)
511 _ForwardIterator __cur = __first;
514 for (; __n > 0; --__n, ++__cur)
520 __throw_exception_again;
526 struct __uninitialized_default_n_1<true>
528 template<
typename _ForwardIterator,
typename _Size>
530 __uninit_default_n(_ForwardIterator __first, _Size __n)
532 typedef typename iterator_traits<_ForwardIterator>::value_type
542 template<
typename _ForwardIterator>
544 __uninitialized_default(_ForwardIterator __first,
545 _ForwardIterator __last)
547 typedef typename iterator_traits<_ForwardIterator>::value_type
550 const bool __assignable = is_copy_assignable<_ValueType>::value;
552 std::__uninitialized_default_1<__is_trivial(_ValueType)
554 __uninit_default(__first, __last);
559 template<
typename _ForwardIterator,
typename _Size>
561 __uninitialized_default_n(_ForwardIterator __first, _Size __n)
563 typedef typename iterator_traits<_ForwardIterator>::value_type
566 const bool __assignable = is_copy_assignable<_ValueType>::value;
568 std::__uninitialized_default_n_1<__is_trivial(_ValueType)
570 __uninit_default_n(__first, __n);
577 template<
typename _ForwardIterator,
typename _Allocator>
579 __uninitialized_default_a(_ForwardIterator __first,
580 _ForwardIterator __last,
583 _ForwardIterator __cur = __first;
587 for (; __cur != __last; ++__cur)
593 __throw_exception_again;
597 template<
typename _ForwardIterator,
typename _Tp>
599 __uninitialized_default_a(_ForwardIterator __first,
600 _ForwardIterator __last,
602 { std::__uninitialized_default(__first, __last); }
608 template<
typename _ForwardIterator,
typename _Size,
typename _Allocator>
610 __uninitialized_default_n_a(_ForwardIterator __first, _Size __n,
613 _ForwardIterator __cur = __first;
617 for (; __n > 0; --__n, ++__cur)
623 __throw_exception_again;
627 template<
typename _ForwardIterator,
typename _Size,
typename _Tp>
629 __uninitialized_default_n_a(_ForwardIterator __first, _Size __n,
631 { std::__uninitialized_default_n(__first, __n); }
634 template<
typename _InputIterator,
typename _Size,
635 typename _ForwardIterator>
637 __uninitialized_copy_n(_InputIterator __first, _Size __n,
638 _ForwardIterator __result, input_iterator_tag)
640 _ForwardIterator __cur = __result;
643 for (; __n > 0; --__n, ++__first, ++__cur)
650 __throw_exception_again;
654 template<
typename _RandomAccessIterator,
typename _Size,
655 typename _ForwardIterator>
656 inline _ForwardIterator
657 __uninitialized_copy_n(_RandomAccessIterator __first, _Size __n,
658 _ForwardIterator __result,
659 random_access_iterator_tag)
671 template<
typename _InputIterator,
typename _Size,
typename _ForwardIterator>
672 inline _ForwardIterator
674 _ForwardIterator __result)
675 {
return std::__uninitialized_copy_n(__first, __n, __result,
679 _GLIBCXX_END_NAMESPACE_VERSION
void uninitialized_fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp &__x)
Copies the value x into the range [first,last).
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.
_ForwardIterator uninitialized_copy_n(_InputIterator __first, _Size __n, _ForwardIterator __result)
Copies the range [first,first+n) into result.
_ForwardIterator uninitialized_copy(_InputIterator __first, _InputIterator __last, _ForwardIterator __result)
Copies the range [first,last) into result.
void _Destroy(_Tp *__pointer)
ISO C++ entities toplevel namespace is std.
_OI fill_n(_OI __first, _Size __n, const _Tp &__value)
Fills the range [first,first+n) with copies of value.
iterator_traits< _Iter >::iterator_category __iterator_category(const _Iter &)
_Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
void _Construct(_T1 *__p, _Args &&...__args)