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 _RefType1;
119 typedef typename iterator_traits<_ForwardIterator>::reference _RefType2;
120 const bool __assignable = is_assignable<_RefType2, _RefType1>::value;
123 return std::__uninitialized_copy<__is_trivial(_ValueType1)
124 && __is_trivial(_ValueType2)
126 __uninit_copy(__first, __last, __result);
130 template<
bool _TrivialValueType>
131 struct __uninitialized_fill
133 template<
typename _ForwardIterator,
typename _Tp>
135 __uninit_fill(_ForwardIterator __first, _ForwardIterator __last,
138 _ForwardIterator __cur = __first;
141 for (; __cur != __last; ++__cur)
147 __throw_exception_again;
153 struct __uninitialized_fill<true>
155 template<
typename _ForwardIterator,
typename _Tp>
157 __uninit_fill(_ForwardIterator __first, _ForwardIterator __last,
159 { std::fill(__first, __last, __x); }
171 template<
typename _ForwardIterator,
typename _Tp>
176 typedef typename iterator_traits<_ForwardIterator>::value_type
178 #if __cplusplus < 201103L 179 const bool __assignable =
true;
182 const bool __assignable = is_copy_assignable<_ValueType>::value;
185 std::__uninitialized_fill<__is_trivial(_ValueType) && __assignable>::
186 __uninit_fill(__first, __last, __x);
190 template<
bool _TrivialValueType>
191 struct __uninitialized_fill_n
193 template<
typename _ForwardIterator,
typename _Size,
typename _Tp>
195 __uninit_fill_n(_ForwardIterator __first, _Size __n,
198 _ForwardIterator __cur = __first;
201 for (; __n > 0; --__n, ++__cur)
207 __throw_exception_again;
213 struct __uninitialized_fill_n<true>
215 template<
typename _ForwardIterator,
typename _Size,
typename _Tp>
217 __uninit_fill_n(_ForwardIterator __first, _Size __n,
231 template<
typename _ForwardIterator,
typename _Size,
typename _Tp>
235 typedef typename iterator_traits<_ForwardIterator>::value_type
237 #if __cplusplus < 201103L 238 const bool __assignable =
true;
241 const bool __assignable = is_copy_assignable<_ValueType>::value;
244 std::__uninitialized_fill_n<__is_trivial(_ValueType) && __assignable>::
245 __uninit_fill_n(__first, __n, __x);
254 template<
typename _InputIterator,
typename _ForwardIterator,
257 __uninitialized_copy_a(_InputIterator __first, _InputIterator __last,
258 _ForwardIterator __result, _Allocator& __alloc)
260 _ForwardIterator __cur = __result;
264 for (; __first != __last; ++__first, ++__cur)
271 __throw_exception_again;
275 template<
typename _InputIterator,
typename _ForwardIterator,
typename _Tp>
276 inline _ForwardIterator
277 __uninitialized_copy_a(_InputIterator __first, _InputIterator __last,
281 template<
typename _InputIterator,
typename _ForwardIterator,
283 inline _ForwardIterator
284 __uninitialized_move_a(_InputIterator __first, _InputIterator __last,
285 _ForwardIterator __result, _Allocator& __alloc)
287 return std::__uninitialized_copy_a(_GLIBCXX_MAKE_MOVE_ITERATOR(__first),
288 _GLIBCXX_MAKE_MOVE_ITERATOR(__last),
292 template<
typename _InputIterator,
typename _ForwardIterator,
294 inline _ForwardIterator
295 __uninitialized_move_if_noexcept_a(_InputIterator __first,
296 _InputIterator __last,
297 _ForwardIterator __result,
300 return std::__uninitialized_copy_a
301 (_GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(__first),
302 _GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(__last), __result, __alloc);
305 template<
typename _ForwardIterator,
typename _Tp,
typename _Allocator>
307 __uninitialized_fill_a(_ForwardIterator __first, _ForwardIterator __last,
308 const _Tp& __x, _Allocator& __alloc)
310 _ForwardIterator __cur = __first;
314 for (; __cur != __last; ++__cur)
320 __throw_exception_again;
324 template<
typename _ForwardIterator,
typename _Tp,
typename _Tp2>
326 __uninitialized_fill_a(_ForwardIterator __first, _ForwardIterator __last,
330 template<
typename _ForwardIterator,
typename _Size,
typename _Tp,
333 __uninitialized_fill_n_a(_ForwardIterator __first, _Size __n,
334 const _Tp& __x, _Allocator& __alloc)
336 _ForwardIterator __cur = __first;
340 for (; __n > 0; --__n, ++__cur)
346 __throw_exception_again;
350 template<
typename _ForwardIterator,
typename _Size,
typename _Tp,
353 __uninitialized_fill_n_a(_ForwardIterator __first, _Size __n,
367 template<
typename _InputIterator1,
typename _InputIterator2,
368 typename _ForwardIterator,
typename _Allocator>
369 inline _ForwardIterator
370 __uninitialized_copy_move(_InputIterator1 __first1,
371 _InputIterator1 __last1,
372 _InputIterator2 __first2,
373 _InputIterator2 __last2,
374 _ForwardIterator __result,
377 _ForwardIterator __mid = std::__uninitialized_copy_a(__first1, __last1,
382 return std::__uninitialized_move_a(__first2, __last2, __mid, __alloc);
387 __throw_exception_again;
395 template<
typename _InputIterator1,
typename _InputIterator2,
396 typename _ForwardIterator,
typename _Allocator>
397 inline _ForwardIterator
398 __uninitialized_move_copy(_InputIterator1 __first1,
399 _InputIterator1 __last1,
400 _InputIterator2 __first2,
401 _InputIterator2 __last2,
402 _ForwardIterator __result,
405 _ForwardIterator __mid = std::__uninitialized_move_a(__first1, __last1,
410 return std::__uninitialized_copy_a(__first2, __last2, __mid, __alloc);
415 __throw_exception_again;
422 template<
typename _ForwardIterator,
typename _Tp,
typename _InputIterator,
424 inline _ForwardIterator
425 __uninitialized_fill_move(_ForwardIterator __result, _ForwardIterator __mid,
426 const _Tp& __x, _InputIterator __first,
427 _InputIterator __last, _Allocator& __alloc)
429 std::__uninitialized_fill_a(__result, __mid, __x, __alloc);
432 return std::__uninitialized_move_a(__first, __last, __mid, __alloc);
437 __throw_exception_again;
444 template<
typename _InputIterator,
typename _ForwardIterator,
typename _Tp,
447 __uninitialized_move_fill(_InputIterator __first1, _InputIterator __last1,
448 _ForwardIterator __first2,
449 _ForwardIterator __last2,
const _Tp& __x,
452 _ForwardIterator __mid2 = std::__uninitialized_move_a(__first1, __last1,
457 std::__uninitialized_fill_a(__mid2, __last2, __x, __alloc);
462 __throw_exception_again;
466 #if __cplusplus >= 201103L 470 template<
bool _TrivialValueType>
471 struct __uninitialized_default_1
473 template<
typename _ForwardIterator>
475 __uninit_default(_ForwardIterator __first, _ForwardIterator __last)
477 _ForwardIterator __cur = __first;
480 for (; __cur != __last; ++__cur)
486 __throw_exception_again;
492 struct __uninitialized_default_1<true>
494 template<
typename _ForwardIterator>
496 __uninit_default(_ForwardIterator __first, _ForwardIterator __last)
498 typedef typename iterator_traits<_ForwardIterator>::value_type
501 std::fill(__first, __last, _ValueType());
505 template<
bool _TrivialValueType>
506 struct __uninitialized_default_n_1
508 template<
typename _ForwardIterator,
typename _Size>
510 __uninit_default_n(_ForwardIterator __first, _Size __n)
512 _ForwardIterator __cur = __first;
515 for (; __n > 0; --__n, ++__cur)
521 __throw_exception_again;
527 struct __uninitialized_default_n_1<true>
529 template<
typename _ForwardIterator,
typename _Size>
531 __uninit_default_n(_ForwardIterator __first, _Size __n)
533 typedef typename iterator_traits<_ForwardIterator>::value_type
543 template<
typename _ForwardIterator>
545 __uninitialized_default(_ForwardIterator __first,
546 _ForwardIterator __last)
548 typedef typename iterator_traits<_ForwardIterator>::value_type
551 const bool __assignable = is_copy_assignable<_ValueType>::value;
553 std::__uninitialized_default_1<__is_trivial(_ValueType)
555 __uninit_default(__first, __last);
560 template<
typename _ForwardIterator,
typename _Size>
562 __uninitialized_default_n(_ForwardIterator __first, _Size __n)
564 typedef typename iterator_traits<_ForwardIterator>::value_type
567 const bool __assignable = is_copy_assignable<_ValueType>::value;
569 std::__uninitialized_default_n_1<__is_trivial(_ValueType)
571 __uninit_default_n(__first, __n);
578 template<
typename _ForwardIterator,
typename _Allocator>
580 __uninitialized_default_a(_ForwardIterator __first,
581 _ForwardIterator __last,
584 _ForwardIterator __cur = __first;
588 for (; __cur != __last; ++__cur)
594 __throw_exception_again;
598 template<
typename _ForwardIterator,
typename _Tp>
600 __uninitialized_default_a(_ForwardIterator __first,
601 _ForwardIterator __last,
603 { std::__uninitialized_default(__first, __last); }
609 template<
typename _ForwardIterator,
typename _Size,
typename _Allocator>
611 __uninitialized_default_n_a(_ForwardIterator __first, _Size __n,
614 _ForwardIterator __cur = __first;
618 for (; __n > 0; --__n, ++__cur)
624 __throw_exception_again;
628 template<
typename _ForwardIterator,
typename _Size,
typename _Tp>
630 __uninitialized_default_n_a(_ForwardIterator __first, _Size __n,
632 { std::__uninitialized_default_n(__first, __n); }
635 template<
typename _InputIterator,
typename _Size,
636 typename _ForwardIterator>
638 __uninitialized_copy_n(_InputIterator __first, _Size __n,
641 _ForwardIterator __cur = __result;
644 for (; __n > 0; --__n, ++__first, ++__cur)
651 __throw_exception_again;
655 template<
typename _RandomAccessIterator,
typename _Size,
656 typename _ForwardIterator>
657 inline _ForwardIterator
658 __uninitialized_copy_n(_RandomAccessIterator __first, _Size __n,
659 _ForwardIterator __result,
672 template<
typename _InputIterator,
typename _Size,
typename _ForwardIterator>
673 inline _ForwardIterator
675 _ForwardIterator __result)
676 {
return std::__uninitialized_copy_n(__first, __n, __result,
680 _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 _Construct(_T1 *__p, _Args &&...__args)
iterator_traits< _Iter >::iterator_category __iterator_category(const _Iter &)
_Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
_ForwardIterator uninitialized_copy(_InputIterator __first, _InputIterator __last, _ForwardIterator __result)
Copies the range [first,last) into result.
ISO C++ entities toplevel namespace is std.
void _Destroy(_Tp *__pointer)
void uninitialized_fill_n(_ForwardIterator __first, _Size __n, const _Tp &__x)
Copies the value x into the range [first,first+n).
Random-access iterators support a superset of bidirectional iterator operations.
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).
_ForwardIterator uninitialized_copy_n(_InputIterator __first, _Size __n, _ForwardIterator __result)
Copies the range [first,first+n) into result.
The standard allocator, as per [20.4].