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>
194 static _ForwardIterator
195 __uninit_fill_n(_ForwardIterator __first, _Size __n,
198 _ForwardIterator __cur = __first;
201 for (; __n > 0; --__n, ++__cur)
208 __throw_exception_again;
214 struct __uninitialized_fill_n<true>
216 template<
typename _ForwardIterator,
typename _Size,
typename _Tp>
217 static _ForwardIterator
218 __uninit_fill_n(_ForwardIterator __first, _Size __n,
234 template<
typename _ForwardIterator,
typename _Size,
typename _Tp>
235 inline _ForwardIterator
238 typedef typename iterator_traits<_ForwardIterator>::value_type
240 #if __cplusplus < 201103L 241 const bool __assignable =
true;
244 const bool __assignable = is_copy_assignable<_ValueType>::value;
246 return __uninitialized_fill_n<__is_trivial(_ValueType) && __assignable>::
247 __uninit_fill_n(__first, __n, __x);
256 template<
typename _InputIterator,
typename _ForwardIterator,
259 __uninitialized_copy_a(_InputIterator __first, _InputIterator __last,
260 _ForwardIterator __result, _Allocator& __alloc)
262 _ForwardIterator __cur = __result;
266 for (; __first != __last; ++__first, ++__cur)
273 __throw_exception_again;
277 template<
typename _InputIterator,
typename _ForwardIterator,
typename _Tp>
278 inline _ForwardIterator
279 __uninitialized_copy_a(_InputIterator __first, _InputIterator __last,
283 template<
typename _InputIterator,
typename _ForwardIterator,
285 inline _ForwardIterator
286 __uninitialized_move_a(_InputIterator __first, _InputIterator __last,
287 _ForwardIterator __result, _Allocator& __alloc)
289 return std::__uninitialized_copy_a(_GLIBCXX_MAKE_MOVE_ITERATOR(__first),
290 _GLIBCXX_MAKE_MOVE_ITERATOR(__last),
294 template<
typename _InputIterator,
typename _ForwardIterator,
296 inline _ForwardIterator
297 __uninitialized_move_if_noexcept_a(_InputIterator __first,
298 _InputIterator __last,
299 _ForwardIterator __result,
302 return std::__uninitialized_copy_a
303 (_GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(__first),
304 _GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(__last), __result, __alloc);
307 template<
typename _ForwardIterator,
typename _Tp,
typename _Allocator>
309 __uninitialized_fill_a(_ForwardIterator __first, _ForwardIterator __last,
310 const _Tp& __x, _Allocator& __alloc)
312 _ForwardIterator __cur = __first;
316 for (; __cur != __last; ++__cur)
322 __throw_exception_again;
326 template<
typename _ForwardIterator,
typename _Tp,
typename _Tp2>
328 __uninitialized_fill_a(_ForwardIterator __first, _ForwardIterator __last,
332 template<
typename _ForwardIterator,
typename _Size,
typename _Tp,
335 __uninitialized_fill_n_a(_ForwardIterator __first, _Size __n,
336 const _Tp& __x, _Allocator& __alloc)
338 _ForwardIterator __cur = __first;
342 for (; __n > 0; --__n, ++__cur)
349 __throw_exception_again;
353 template<
typename _ForwardIterator,
typename _Size,
typename _Tp,
355 inline _ForwardIterator
356 __uninitialized_fill_n_a(_ForwardIterator __first, _Size __n,
370 template<
typename _InputIterator1,
typename _InputIterator2,
371 typename _ForwardIterator,
typename _Allocator>
372 inline _ForwardIterator
373 __uninitialized_copy_move(_InputIterator1 __first1,
374 _InputIterator1 __last1,
375 _InputIterator2 __first2,
376 _InputIterator2 __last2,
377 _ForwardIterator __result,
380 _ForwardIterator __mid = std::__uninitialized_copy_a(__first1, __last1,
385 return std::__uninitialized_move_a(__first2, __last2, __mid, __alloc);
390 __throw_exception_again;
398 template<
typename _InputIterator1,
typename _InputIterator2,
399 typename _ForwardIterator,
typename _Allocator>
400 inline _ForwardIterator
401 __uninitialized_move_copy(_InputIterator1 __first1,
402 _InputIterator1 __last1,
403 _InputIterator2 __first2,
404 _InputIterator2 __last2,
405 _ForwardIterator __result,
408 _ForwardIterator __mid = std::__uninitialized_move_a(__first1, __last1,
413 return std::__uninitialized_copy_a(__first2, __last2, __mid, __alloc);
418 __throw_exception_again;
425 template<
typename _ForwardIterator,
typename _Tp,
typename _InputIterator,
427 inline _ForwardIterator
428 __uninitialized_fill_move(_ForwardIterator __result, _ForwardIterator __mid,
429 const _Tp& __x, _InputIterator __first,
430 _InputIterator __last, _Allocator& __alloc)
432 std::__uninitialized_fill_a(__result, __mid, __x, __alloc);
435 return std::__uninitialized_move_a(__first, __last, __mid, __alloc);
440 __throw_exception_again;
447 template<
typename _InputIterator,
typename _ForwardIterator,
typename _Tp,
450 __uninitialized_move_fill(_InputIterator __first1, _InputIterator __last1,
451 _ForwardIterator __first2,
452 _ForwardIterator __last2,
const _Tp& __x,
455 _ForwardIterator __mid2 = std::__uninitialized_move_a(__first1, __last1,
460 std::__uninitialized_fill_a(__mid2, __last2, __x, __alloc);
465 __throw_exception_again;
469 #if __cplusplus >= 201103L 473 template<
bool _TrivialValueType>
474 struct __uninitialized_default_1
476 template<
typename _ForwardIterator>
478 __uninit_default(_ForwardIterator __first, _ForwardIterator __last)
480 _ForwardIterator __cur = __first;
483 for (; __cur != __last; ++__cur)
489 __throw_exception_again;
495 struct __uninitialized_default_1<true>
497 template<
typename _ForwardIterator>
499 __uninit_default(_ForwardIterator __first, _ForwardIterator __last)
501 typedef typename iterator_traits<_ForwardIterator>::value_type
504 std::fill(__first, __last, _ValueType());
508 template<
bool _TrivialValueType>
509 struct __uninitialized_default_n_1
511 template<
typename _ForwardIterator,
typename _Size>
512 static _ForwardIterator
513 __uninit_default_n(_ForwardIterator __first, _Size __n)
515 _ForwardIterator __cur = __first;
518 for (; __n > 0; --__n, ++__cur)
525 __throw_exception_again;
531 struct __uninitialized_default_n_1<true>
533 template<
typename _ForwardIterator,
typename _Size>
534 static _ForwardIterator
535 __uninit_default_n(_ForwardIterator __first, _Size __n)
537 typedef typename iterator_traits<_ForwardIterator>::value_type
547 template<
typename _ForwardIterator>
549 __uninitialized_default(_ForwardIterator __first,
550 _ForwardIterator __last)
552 typedef typename iterator_traits<_ForwardIterator>::value_type
555 const bool __assignable = is_copy_assignable<_ValueType>::value;
557 std::__uninitialized_default_1<__is_trivial(_ValueType)
559 __uninit_default(__first, __last);
564 template<
typename _ForwardIterator,
typename _Size>
565 inline _ForwardIterator
566 __uninitialized_default_n(_ForwardIterator __first, _Size __n)
568 typedef typename iterator_traits<_ForwardIterator>::value_type
571 const bool __assignable = is_copy_assignable<_ValueType>::value;
573 return __uninitialized_default_n_1<__is_trivial(_ValueType)
575 __uninit_default_n(__first, __n);
582 template<
typename _ForwardIterator,
typename _Allocator>
584 __uninitialized_default_a(_ForwardIterator __first,
585 _ForwardIterator __last,
588 _ForwardIterator __cur = __first;
592 for (; __cur != __last; ++__cur)
598 __throw_exception_again;
602 template<
typename _ForwardIterator,
typename _Tp>
604 __uninitialized_default_a(_ForwardIterator __first,
605 _ForwardIterator __last,
607 { std::__uninitialized_default(__first, __last); }
613 template<
typename _ForwardIterator,
typename _Size,
typename _Allocator>
615 __uninitialized_default_n_a(_ForwardIterator __first, _Size __n,
618 _ForwardIterator __cur = __first;
622 for (; __n > 0; --__n, ++__cur)
629 __throw_exception_again;
633 template<
typename _ForwardIterator,
typename _Size,
typename _Tp>
634 inline _ForwardIterator
635 __uninitialized_default_n_a(_ForwardIterator __first, _Size __n,
637 {
return std::__uninitialized_default_n(__first, __n); }
640 template<
typename _InputIterator,
typename _Size,
641 typename _ForwardIterator>
643 __uninitialized_copy_n(_InputIterator __first, _Size __n,
646 _ForwardIterator __cur = __result;
649 for (; __n > 0; --__n, ++__first, ++__cur)
656 __throw_exception_again;
660 template<
typename _RandomAccessIterator,
typename _Size,
661 typename _ForwardIterator>
662 inline _ForwardIterator
663 __uninitialized_copy_n(_RandomAccessIterator __first, _Size __n,
664 _ForwardIterator __result,
677 template<
typename _InputIterator,
typename _Size,
typename _ForwardIterator>
678 inline _ForwardIterator
680 _ForwardIterator __result)
681 {
return std::__uninitialized_copy_n(__first, __n, __result,
685 _GLIBCXX_END_NAMESPACE_VERSION
_Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
void _Construct(_T1 *__p, _Args &&...__args)
The standard allocator, as per [20.4].
_ForwardIterator uninitialized_copy_n(_InputIterator __first, _Size __n, _ForwardIterator __result)
Copies the range [first,first+n) into result.
_OI fill_n(_OI __first, _Size __n, const _Tp &__value)
Fills the range [first,first+n) with copies of value.
void _Destroy(_Tp *__pointer)
Random-access iterators support a superset of bidirectional iterator operations.
_ForwardIterator uninitialized_copy(_InputIterator __first, _InputIterator __last, _ForwardIterator __result)
Copies the range [first,last) into result.
_ForwardIterator 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).
iterator_traits< _Iter >::iterator_category __iterator_category(const _Iter &)
ISO C++ entities toplevel namespace is std.
Uniform interface to C++98 and C++0x allocators.