56#ifndef _STL_UNINITIALIZED_H
57#define _STL_UNINITIALIZED_H 1
59#if __cplusplus >= 201103L
71namespace std _GLIBCXX_VISIBILITY(default)
73_GLIBCXX_BEGIN_NAMESPACE_VERSION
81 template<
typename _ForwardIterator,
typename _Alloc =
void>
82 struct _UninitDestroyGuard
86 _UninitDestroyGuard(_ForwardIterator& __first, _Alloc& __a)
87 : _M_first(__first), _M_cur(__builtin_addressof(__first)), _M_alloc(__a)
91 ~_UninitDestroyGuard()
93 if (__builtin_expect(_M_cur != 0, 0))
98 void release() { _M_cur = 0; }
101 _ForwardIterator
const _M_first;
102 _ForwardIterator* _M_cur;
105 _UninitDestroyGuard(
const _UninitDestroyGuard&);
108 template<
typename _ForwardIterator>
109 struct _UninitDestroyGuard<_ForwardIterator, void>
113 _UninitDestroyGuard(_ForwardIterator& __first)
114 : _M_first(__first), _M_cur(__builtin_addressof(__first))
118 ~_UninitDestroyGuard()
120 if (__builtin_expect(_M_cur != 0, 0))
125 void release() { _M_cur = 0; }
127 _ForwardIterator
const _M_first;
128 _ForwardIterator* _M_cur;
131 _UninitDestroyGuard(
const _UninitDestroyGuard&);
136 template<
typename _InputIterator,
typename _Sentinel,
137 typename _ForwardIterator>
140 __do_uninit_copy(_InputIterator __first, _Sentinel __last,
141 _ForwardIterator __result)
143 _UninitDestroyGuard<_ForwardIterator> __guard(__result);
144 for (; __first != __last; ++__first, (void)++__result)
150#if __cplusplus < 201103L
153 template<
typename _Iter,
154 typename _Base = __decltype(std::__niter_base(*(_Iter*)0))>
155 struct __unwrappable_niter
156 {
enum { __value =
false }; };
158 template<
typename _Iter,
typename _Tp>
159 struct __unwrappable_niter<_Iter, _Tp*>
160 {
enum { __value =
true }; };
163 template<
bool _CanMemcpy>
164 struct __uninitialized_copy
166 template<
typename _InputIterator,
typename _ForwardIterator>
167 static _ForwardIterator
168 __uninit_copy(_InputIterator __first, _InputIterator __last,
169 _ForwardIterator __result)
170 {
return std::__do_uninit_copy(__first, __last, __result); }
174 struct __uninitialized_copy<true>
177 template<
typename _InputIterator,
typename _ForwardIterator>
178 static _ForwardIterator
179 __uninit_copy(_InputIterator __first, _InputIterator __last,
180 _ForwardIterator __result)
182 if (__unwrappable_niter<_InputIterator>::__value
183 && __unwrappable_niter<_ForwardIterator>::__value)
185 __uninit_copy(std::__niter_base(__first),
186 std::__niter_base(__last),
187 std::__niter_base(__result));
192 return std::__do_uninit_copy(__first, __last, __result);
196 template<
typename _Tp,
typename _Up>
198 __uninit_copy(_Tp* __first, _Tp* __last, _Up* __result)
202 typedef __typeof__(
static_cast<_Up
>(*__first)) __check
203 __attribute__((__unused__));
205 const ptrdiff_t __n = __last - __first;
206 if (__builtin_expect(__n > 0,
true))
208 __builtin_memcpy(__result, __first, __n *
sizeof(_Tp));
217#pragma GCC diagnostic push
218#pragma GCC diagnostic ignored "-Wc++17-extensions"
228 template<
typename _InputIterator,
typename _ForwardIterator>
230 inline _ForwardIterator
232 _ForwardIterator __result)
255#if __cplusplus >= 201103L
256 using _Dest =
decltype(std::__niter_base(__result));
257 using _Src =
decltype(std::__niter_base(__first));
260#if __glibcxx_raw_memory_algorithms >= 202411L
262 return std::__do_uninit_copy(__first, __last, __result);
265 if constexpr (!__is_trivially_constructible(_ValT,
decltype(*__first)))
266 return std::__do_uninit_copy(__first, __last, __result);
267 else if constexpr (__memcpyable<_Dest, _Src>::__value)
269 ptrdiff_t __n = __last - __first;
270 if (__n > 0) [[__likely__]]
272 using _ValT =
typename remove_pointer<_Src>::type;
273 __builtin_memcpy(std::__niter_base(__result),
274 std::__niter_base(__first),
275 __n *
sizeof(_ValT));
280#if __cpp_lib_concepts
281 else if constexpr (contiguous_iterator<_ForwardIterator>
282 && contiguous_iterator<_InputIterator>)
286 if constexpr (__memcpyable<_DestPtr, _SrcPtr>::__value)
288 if (
auto __n = __last - __first; __n > 0) [[likely]]
293 __builtin_memcpy(__dest, __src, __nbytes);
299 return std::__do_uninit_copy(__first, __last, __result);
303 return std::__do_uninit_copy(__first, __last, __result);
310 const bool __can_memcpy
311 = __memcpyable<_ValueType1*, _ValueType2*>::__value
312 && __is_trivially_constructible(_ValueType2, __decltype(*__first));
314 return __uninitialized_copy<__can_memcpy>::
315 __uninit_copy(__first, __last, __result);
318#pragma GCC diagnostic pop
323 template<
typename _ForwardIterator,
typename _Tp>
324 _GLIBCXX20_CONSTEXPR
void
325 __do_uninit_fill(_ForwardIterator __first, _ForwardIterator __last,
328 _UninitDestroyGuard<_ForwardIterator> __guard(__first);
329 for (; __first != __last; ++__first)
334#if __cplusplus < 201103L
336 template<
bool _CanMemset>
337 struct __uninitialized_fill
339 template<
typename _ForwardIterator,
typename _Tp>
341 __uninit_fill(_ForwardIterator __first, _ForwardIterator __last,
343 { std::__do_uninit_fill(__first, __last, __x); }
347 struct __uninitialized_fill<true>
350 template<
typename _ForwardIterator,
typename _Tp>
352 __uninit_fill(_ForwardIterator __first, _ForwardIterator __last,
355 if (__unwrappable_niter<_ForwardIterator>::__value)
356 __uninit_fill(std::__niter_base(__first),
357 std::__niter_base(__last),
360 std::__do_uninit_copy(__first, __last, __x);
364 template<
typename _Up,
typename _Tp>
366 __uninit_fill(_Up* __first, _Up* __last,
const _Tp& __x)
370 typedef __typeof__(
static_cast<_Up
>(__x)) __check
371 __attribute__((__unused__));
373 if (__first != __last)
374 __builtin_memset(__first, (
unsigned char)__x, __last - __first);
389 template<
typename _ForwardIterator,
typename _Tp>
407#if __cplusplus >= 201103L
408#pragma GCC diagnostic push
409#pragma GCC diagnostic ignored "-Wc++17-extensions"
410#if __glibcxx_raw_memory_algorithms >= 202411L
412 return std::__do_uninit_fill(__first, __last, __x);
415 if constexpr (__is_byte<_ValueType>::__value)
419 using _BasePtr =
decltype(std::__niter_base(__first));
422 void* __dest = std::__niter_base(__first);
423 ptrdiff_t __n = __last - __first;
424 if (__n > 0) [[__likely__]]
425 __builtin_memset(__dest, (
unsigned char)__x, __n);
428#if __cpp_lib_concepts
429 else if constexpr (contiguous_iterator<_ForwardIterator>)
432 auto __n = __last - __first;
433 if (__n > 0) [[__likely__]]
434 __builtin_memset(__dest, (
unsigned char)__x, __n);
439 std::__do_uninit_fill(__first, __last, __x);
440#pragma GCC diagnostic pop
442 const bool __can_memset = __is_byte<_ValueType>::__value
443 && __is_integer<_Tp>::__value;
445 __uninitialized_fill<__can_memset>::__uninit_fill(__first, __last, __x);
452 template<
typename _ForwardIterator,
typename _Size,
typename _Tp>
455 __do_uninit_fill_n(_ForwardIterator __first, _Size __n,
const _Tp& __x)
457 _UninitDestroyGuard<_ForwardIterator> __guard(__first);
458#if __cplusplus >= 201103L
459#pragma GCC diagnostic push
460#pragma GCC diagnostic ignored "-Wc++17-extensions"
461 if constexpr (is_integral<_Size>::value)
463 __glibcxx_assert(__n >= 0);
464 else if constexpr (is_floating_point<_Size>::value)
466 __glibcxx_assert(__n >= 0 &&
static_cast<size_t>(__n) == __n);
467#pragma GCC diagnostic pop
469 for (; __n--; ++__first)
475#if __cplusplus < 201103L
477 template<
bool _CanMemset>
478 struct __uninitialized_fill_n
480 template<
typename _ForwardIterator,
typename _Size,
typename _Tp>
481 static _ForwardIterator
482 __uninit_fill_n(_ForwardIterator __first, _Size __n,
484 {
return std::__do_uninit_fill_n(__first, __n, __x); }
488 struct __uninitialized_fill_n<true>
491 template<
typename _ForwardIterator,
typename _Size,
typename _Tp>
492 static _ForwardIterator
493 __uninit_fill_n(_ForwardIterator __first, _Size __n,
496 if (__unwrappable_niter<_ForwardIterator>::__value)
498 _ForwardIterator __last = __first;
500 __uninitialized_fill<true>::__uninit_fill(__first, __last, __x);
504 return std::__do_uninit_fill_n(__first, __n, __x);
510#pragma GCC diagnostic push
511#pragma GCC diagnostic ignored "-Wc++17-extensions"
523 template<
typename _ForwardIterator,
typename _Size,
typename _Tp>
525 inline _ForwardIterator
537#if __cplusplus >= 201103L
538#if __glibcxx_raw_memory_algorithms >= 202411L
540 return std::__do_uninit_fill_n(__first, __n, __x);
543 if constexpr (__is_byte<_ValueType>::__value)
547 using _BasePtr =
decltype(std::__niter_base(__first));
550 void* __dest = std::__niter_base(__first);
551 if (__n > 0) [[__likely__]]
553 __builtin_memset(__dest, (
unsigned char)__x, __n);
558#if __cpp_lib_concepts
559 else if constexpr (contiguous_iterator<_ForwardIterator>)
562 if (__n > 0) [[__likely__]]
564 __builtin_memset(__dest, (
unsigned char)__x, __n);
571 return std::__do_uninit_fill_n(__first, __n, __x);
573 const bool __can_memset = __is_byte<_ValueType>::__value
574 && __is_integer<_Tp>::__value
575 && __is_integer<_Size>::__value;
577 return __uninitialized_fill_n<__can_memset>::
578 __uninit_fill_n(__first, __n, __x);
581#pragma GCC diagnostic pop
591 template<
typename _InputIterator,
typename _Sentinel,
592 typename _ForwardIterator,
typename _Allocator>
595 __uninitialized_copy_a(_InputIterator __first, _Sentinel __last,
596 _ForwardIterator __result, _Allocator& __alloc)
598 _UninitDestroyGuard<_ForwardIterator, _Allocator>
599 __guard(__result, __alloc);
602 for (; __first != __last; ++__first, (void)++__result)
609 template<
typename _InputIterator,
typename _Sentinel,
610 typename _ForwardIterator,
typename _Tp>
612 inline _ForwardIterator
613 __uninitialized_copy_a(_InputIterator __first, _Sentinel __last,
614 _ForwardIterator __result, allocator<_Tp>&)
616#ifdef __cpp_lib_is_constant_evaluated
617 if (std::is_constant_evaluated())
618 return std::__do_uninit_copy(
std::move(__first), __last, __result);
621#ifdef __glibcxx_ranges
622 if constexpr (!is_same_v<_InputIterator, _Sentinel>)
626 if constexpr (sized_sentinel_for<_Sentinel, _InputIterator>
627 && random_access_iterator<_InputIterator>)
629 __first + (__last - __first),
632 return std::__do_uninit_copy(
std::move(__first), __last, __result);
642 template<
typename _InputIterator,
typename _ForwardIterator,
645 inline _ForwardIterator
646 __uninitialized_move_a(_InputIterator __first, _InputIterator __last,
647 _ForwardIterator __result, _Allocator& __alloc)
649 return std::__uninitialized_copy_a(_GLIBCXX_MAKE_MOVE_ITERATOR(__first),
650 _GLIBCXX_MAKE_MOVE_ITERATOR(__last),
654 template<
typename _InputIterator,
typename _ForwardIterator,
657 inline _ForwardIterator
658 __uninitialized_move_if_noexcept_a(_InputIterator __first,
659 _InputIterator __last,
660 _ForwardIterator __result,
663 return std::__uninitialized_copy_a
664 (_GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(__first),
665 _GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(__last), __result, __alloc);
668 template<
typename _ForwardIterator,
typename _Tp,
typename _Allocator>
671 __uninitialized_fill_a(_ForwardIterator __first, _ForwardIterator __last,
672 const _Tp& __x, _Allocator& __alloc)
674 _UninitDestroyGuard<_ForwardIterator, _Allocator>
675 __guard(__first, __alloc);
678 for (; __first != __last; ++__first)
685 template<
typename _ForwardIterator,
typename _Tp,
typename _Tp2>
688 __uninitialized_fill_a(_ForwardIterator __first, _ForwardIterator __last,
689 const _Tp& __x, allocator<_Tp2>&)
691#ifdef __cpp_lib_is_constant_evaluated
692 if (std::is_constant_evaluated())
693 return std::__do_uninit_fill(__first, __last, __x);
699 template<
typename _ForwardIterator,
typename _Size,
typename _Tp,
703 __uninitialized_fill_n_a(_ForwardIterator __first, _Size __n,
704 const _Tp& __x, _Allocator& __alloc)
706 _UninitDestroyGuard<_ForwardIterator, _Allocator>
707 __guard(__first, __alloc);
709 for (; __n > 0; --__n, (void) ++__first)
716 template<
typename _ForwardIterator,
typename _Size,
typename _Tp,
719 inline _ForwardIterator
720 __uninitialized_fill_n_a(_ForwardIterator __first, _Size __n,
721 const _Tp& __x, allocator<_Tp2>&)
723#ifdef __cpp_lib_is_constant_evaluated
724 if (std::is_constant_evaluated())
725 return std::__do_uninit_fill_n(__first, __n, __x);
740 template<
typename _InputIterator1,
typename _InputIterator2,
741 typename _ForwardIterator,
typename _Allocator>
742 inline _ForwardIterator
743 __uninitialized_copy_move(_InputIterator1 __first1,
744 _InputIterator1 __last1,
745 _InputIterator2 __first2,
746 _InputIterator2 __last2,
747 _ForwardIterator __result,
750 _ForwardIterator __mid = std::__uninitialized_copy_a(__first1, __last1,
752 _UninitDestroyGuard<_ForwardIterator, _Allocator> __guard(__result,
755 __result = std::__uninitialized_move_a(__first2, __last2, __mid, __alloc);
764 template<
typename _InputIterator1,
typename _InputIterator2,
765 typename _ForwardIterator,
typename _Allocator>
766 inline _ForwardIterator
767 __uninitialized_move_copy(_InputIterator1 __first1,
768 _InputIterator1 __last1,
769 _InputIterator2 __first2,
770 _InputIterator2 __last2,
771 _ForwardIterator __result,
774 _ForwardIterator __mid = std::__uninitialized_move_a(__first1, __last1,
776 _UninitDestroyGuard<_ForwardIterator, _Allocator> __guard(__result,
779 __result = std::__uninitialized_copy_a(__first2, __last2, __mid, __alloc);
787 template<
typename _ForwardIterator,
typename _Tp,
typename _InputIterator,
789 inline _ForwardIterator
790 __uninitialized_fill_move(_ForwardIterator __result, _ForwardIterator __mid,
791 const _Tp& __x, _InputIterator __first,
792 _InputIterator __last, _Allocator& __alloc)
794 std::__uninitialized_fill_a(__result, __mid, __x, __alloc);
795 _UninitDestroyGuard<_ForwardIterator, _Allocator> __guard(__result,
798 __result = std::__uninitialized_move_a(__first, __last, __mid, __alloc);
806 template<
typename _InputIterator,
typename _ForwardIterator,
typename _Tp,
809 __uninitialized_move_fill(_InputIterator __first1, _InputIterator __last1,
810 _ForwardIterator __first2,
811 _ForwardIterator __last2,
const _Tp& __x,
814 _ForwardIterator __mid2 = std::__uninitialized_move_a(__first1, __last1,
817 _UninitDestroyGuard<_ForwardIterator, _Allocator> __guard(__first2,
820 std::__uninitialized_fill_a(__mid2, __last2, __x, __alloc);
826#if __cplusplus >= 201103L
832 template<
bool _TrivialValueType>
833 struct __uninitialized_default_1
835 template<
typename _ForwardIterator>
838 __uninit_default(_ForwardIterator __first, _ForwardIterator __last)
840 _UninitDestroyGuard<_ForwardIterator> __guard(__first);
841 for (; __first != __last; ++__first)
848 struct __uninitialized_default_1<true>
850 template<
typename _ForwardIterator>
853 __uninit_default(_ForwardIterator __first, _ForwardIterator __last)
855 if (__first == __last)
858 typename iterator_traits<_ForwardIterator>::value_type* __val
861 if (++__first != __last)
862 std::fill(__first, __last, *__val);
866 template<
bool _TrivialValueType>
867 struct __uninitialized_default_n_1
869 template<
typename _ForwardIterator,
typename _Size>
871 static _ForwardIterator
872 __uninit_default_n(_ForwardIterator __first, _Size __n)
874 _UninitDestroyGuard<_ForwardIterator> __guard(__first);
875 for (; __n > 0; --__n, (void) ++__first)
883 struct __uninitialized_default_n_1<true>
885 template<
typename _ForwardIterator,
typename _Size>
887 static _ForwardIterator
888 __uninit_default_n(_ForwardIterator __first, _Size __n)
892 typename iterator_traits<_ForwardIterator>::value_type* __val
896 __first = std::fill_n(__first, __n - 1, *__val);
904 template<
typename _ForwardIterator>
907 __uninitialized_default(_ForwardIterator __first,
908 _ForwardIterator __last)
910 typedef typename iterator_traits<_ForwardIterator>::value_type
913 const bool __assignable = is_copy_assignable<_ValueType>::value;
915 std::__uninitialized_default_1<__is_trivial(_ValueType)
917 __uninit_default(__first, __last);
922 template<
typename _ForwardIterator,
typename _Size>
924 inline _ForwardIterator
925 __uninitialized_default_n(_ForwardIterator __first, _Size __n)
927#ifdef __cpp_lib_is_constant_evaluated
928 if (std::is_constant_evaluated())
929 return __uninitialized_default_n_1<false>::
930 __uninit_default_n(__first, __n);
933 typedef typename iterator_traits<_ForwardIterator>::value_type
936 constexpr bool __can_fill
937 = __and_<is_integral<_Size>, is_copy_assignable<_ValueType>>::value;
939 return __uninitialized_default_n_1<__is_trivial(_ValueType)
941 __uninit_default_n(__first, __n);
948 template<
typename _ForwardIterator,
typename _Allocator>
950 __uninitialized_default_a(_ForwardIterator __first,
951 _ForwardIterator __last,
954 _UninitDestroyGuard<_ForwardIterator, _Allocator> __guard(__first,
957 for (; __first != __last; ++__first)
963 template<
typename _ForwardIterator,
typename _Tp>
965 __uninitialized_default_a(_ForwardIterator __first,
966 _ForwardIterator __last,
968 { std::__uninitialized_default(__first, __last); }
974 template<
typename _ForwardIterator,
typename _Size,
typename _Allocator>
975 _GLIBCXX20_CONSTEXPR _ForwardIterator
976 __uninitialized_default_n_a(_ForwardIterator __first, _Size __n,
979 _UninitDestroyGuard<_ForwardIterator, _Allocator> __guard(__first,
982 for (; __n > 0; --__n, (void) ++__first)
991 template<
typename _ForwardIterator,
typename _Size,
typename _Tp>
993 inline _ForwardIterator
994 __uninitialized_default_n_a(_ForwardIterator __first, _Size __n,
996 {
return std::__uninitialized_default_n(__first, __n); }
999 template<
bool _TrivialValueType>
1000 struct __uninitialized_default_novalue_1
1002 template<
typename _ForwardIterator>
1003 _GLIBCXX26_CONSTEXPR
1005 __uninit_default_novalue(_ForwardIterator __first,
1006 _ForwardIterator __last)
1008 _UninitDestroyGuard<_ForwardIterator> __guard(__first);
1009 for (; __first != __last; ++__first)
1016 struct __uninitialized_default_novalue_1<true>
1018 template<
typename _ForwardIterator>
1019 _GLIBCXX26_CONSTEXPR
1021 __uninit_default_novalue(_ForwardIterator, _ForwardIterator)
1026 template<
bool _TrivialValueType>
1027 struct __uninitialized_default_novalue_n_1
1029 template<
typename _ForwardIterator,
typename _Size>
1030 _GLIBCXX26_CONSTEXPR
1031 static _ForwardIterator
1032 __uninit_default_novalue_n(_ForwardIterator __first, _Size __n)
1034 _UninitDestroyGuard<_ForwardIterator> __guard(__first);
1035 for (; __n > 0; --__n, (void) ++__first)
1043 struct __uninitialized_default_novalue_n_1<true>
1045 template<
typename _ForwardIterator,
typename _Size>
1046 _GLIBCXX26_CONSTEXPR
1047 static _ForwardIterator
1048 __uninit_default_novalue_n(_ForwardIterator __first, _Size __n)
1049 {
return std::next(__first, __n); }
1054 template<
typename _ForwardIterator>
1055 _GLIBCXX26_CONSTEXPR
1057 __uninitialized_default_novalue(_ForwardIterator __first,
1058 _ForwardIterator __last)
1060 typedef typename iterator_traits<_ForwardIterator>::value_type
1063 std::__uninitialized_default_novalue_1<
1064 is_trivially_default_constructible<_ValueType>::value>::
1065 __uninit_default_novalue(__first, __last);
1070 template<
typename _ForwardIterator,
typename _Size>
1071 _GLIBCXX26_CONSTEXPR
1072 inline _ForwardIterator
1073 __uninitialized_default_novalue_n(_ForwardIterator __first, _Size __n)
1075 typedef typename iterator_traits<_ForwardIterator>::value_type
1078 return __uninitialized_default_novalue_n_1<
1079 is_trivially_default_constructible<_ValueType>::value>::
1080 __uninit_default_novalue_n(__first, __n);
1083 template<
typename _InputIterator,
typename _Size,
1084 typename _ForwardIterator>
1085 _GLIBCXX26_CONSTEXPR
1087 __uninitialized_copy_n(_InputIterator __first, _Size __n,
1088 _ForwardIterator __result, input_iterator_tag)
1090 _UninitDestroyGuard<_ForwardIterator> __guard(__result);
1091 for (; __n > 0; --__n, (void) ++__first, ++__result)
1097 template<
typename _RandomAccessIterator,
typename _Size,
1098 typename _ForwardIterator>
1099 _GLIBCXX26_CONSTEXPR
1100 inline _ForwardIterator
1101 __uninitialized_copy_n(_RandomAccessIterator __first, _Size __n,
1102 _ForwardIterator __result,
1103 random_access_iterator_tag)
1106 template<
typename _InputIterator,
typename _Size,
1107 typename _ForwardIterator>
1108 _GLIBCXX26_CONSTEXPR
1109 pair<_InputIterator, _ForwardIterator>
1110 __uninitialized_copy_n_pair(_InputIterator __first, _Size __n,
1111 _ForwardIterator __result, input_iterator_tag)
1113 _UninitDestroyGuard<_ForwardIterator> __guard(__result);
1114 for (; __n > 0; --__n, (void) ++__first, ++__result)
1117 return {__first, __result};
1120 template<
typename _RandomAccessIterator,
typename _Size,
1121 typename _ForwardIterator>
1122 _GLIBCXX26_CONSTEXPR
1123 inline pair<_RandomAccessIterator, _ForwardIterator>
1124 __uninitialized_copy_n_pair(_RandomAccessIterator __first, _Size __n,
1125 _ForwardIterator __result,
1126 random_access_iterator_tag)
1129 auto __first_res = std::next(__first, __n);
1130 return {__first_res, __second_res};
1145 template<
typename _InputIterator,
typename _Size,
typename _ForwardIterator>
1146 _GLIBCXX26_CONSTEXPR
1147 inline _ForwardIterator
1149 _ForwardIterator __result)
1150 {
return std::__uninitialized_copy_n(__first, __n, __result,
1154 template<
typename _InputIterator,
typename _Size,
typename _ForwardIterator>
1155 _GLIBCXX26_CONSTEXPR
1156 inline pair<_InputIterator, _ForwardIterator>
1157 __uninitialized_copy_n_pair(_InputIterator __first, _Size __n,
1158 _ForwardIterator __result)
1161 std::__uninitialized_copy_n_pair(__first, __n, __result,
1167#ifdef __glibcxx_raw_memory_algorithms
1174 template <
typename _ForwardIterator>
1175 _GLIBCXX26_CONSTEXPR
1178 _ForwardIterator __last)
1180 std::__uninitialized_default_novalue(__first, __last);
1190 template <
typename _ForwardIterator,
typename _Size>
1191 _GLIBCXX26_CONSTEXPR
1192 inline _ForwardIterator
1195 return std::__uninitialized_default_novalue_n(__first, __count);
1204 template <
typename _ForwardIterator>
1205 _GLIBCXX26_CONSTEXPR
1208 _ForwardIterator __last)
1210 return std::__uninitialized_default(__first, __last);
1220 template <
typename _ForwardIterator,
typename _Size>
1221 _GLIBCXX26_CONSTEXPR
1222 inline _ForwardIterator
1225 return std::__uninitialized_default_n(__first, __count);
1236 template <
typename _InputIterator,
typename _ForwardIterator>
1237 _GLIBCXX26_CONSTEXPR
1238 inline _ForwardIterator
1240 _ForwardIterator __result)
1243 (_GLIBCXX_MAKE_MOVE_ITERATOR(__first),
1244 _GLIBCXX_MAKE_MOVE_ITERATOR(__last), __result);
1255 template <
typename _InputIterator,
typename _Size,
typename _ForwardIterator>
1256 _GLIBCXX26_CONSTEXPR
1257 inline pair<_InputIterator, _ForwardIterator>
1259 _ForwardIterator __result)
1261 auto __res = std::__uninitialized_copy_n_pair
1262 (_GLIBCXX_MAKE_MOVE_ITERATOR(__first),
1264 return {__res.first.base(), __res.second};
1268#if __cplusplus >= 201103L
1271 template<
typename _Tp,
typename _Up,
typename _Allocator>
1272 _GLIBCXX20_CONSTEXPR
1274 __relocate_object_a(_Tp* __restrict __dest, _Up* __restrict __orig,
1275 _Allocator& __alloc)
1282 __traits::construct(__alloc, __dest,
std::move(*__orig));
1288 template<
typename _Tp,
typename =
void>
1289 struct __is_bitwise_relocatable
1290 : __bool_constant<__is_trivial(_Tp)>
1293 template <
typename _InputIterator,
typename _ForwardIterator,
1294 typename _Allocator>
1295 _GLIBCXX20_CONSTEXPR
1296 inline _ForwardIterator
1297 __relocate_a_1(_InputIterator __first, _InputIterator __last,
1298 _ForwardIterator __result, _Allocator& __alloc)
1299 noexcept(
noexcept(std::__relocate_object_a(
std::addressof(*__result),
1303 typedef typename iterator_traits<_InputIterator>::value_type
1305 typedef typename iterator_traits<_ForwardIterator>::value_type
1308 "relocation is only possible for values of the same type");
1309 _ForwardIterator __cur = __result;
1310 for (; __first != __last; ++__first, (void)++__cur)
1317 template <
typename _Tp,
typename _Up>
1318 _GLIBCXX20_CONSTEXPR
1319 inline __enable_if_t<std::__is_bitwise_relocatable<_Tp>::value, _Tp*>
1320 __relocate_a_1(_Tp* __first, _Tp* __last,
1322 [[__maybe_unused__]] allocator<_Up>& __alloc)
noexcept
1324 ptrdiff_t __count = __last - __first;
1327#ifdef __cpp_lib_is_constant_evaluated
1328 if (std::is_constant_evaluated())
1332 __gnu_cxx::__normal_iterator<_Tp*, void> __out(__result);
1333 __out = std::__relocate_a_1(__first, __last, __out, __alloc);
1334 return __out.base();
1337 __builtin_memcpy(__result, __first, __count *
sizeof(_Tp));
1339 return __result + __count;
1343 template <
typename _InputIterator,
typename _ForwardIterator,
1344 typename _Allocator>
1345 _GLIBCXX20_CONSTEXPR
1346 inline _ForwardIterator
1347 __relocate_a(_InputIterator __first, _InputIterator __last,
1348 _ForwardIterator __result, _Allocator& __alloc)
1349 noexcept(
noexcept(__relocate_a_1(std::__niter_base(__first),
1350 std::__niter_base(__last),
1351 std::__niter_base(__result), __alloc)))
1353 return std::__relocate_a_1(std::__niter_base(__first),
1354 std::__niter_base(__last),
1355 std::__niter_base(__result), __alloc);
1363_GLIBCXX_END_NAMESPACE_VERSION
_GLIBCXX26_CONSTEXPR void uninitialized_fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp &__x)
Copies the value x into the range [first,last).
_GLIBCXX26_CONSTEXPR _ForwardIterator uninitialized_copy_n(_InputIterator __first, _Size __n, _ForwardIterator __result)
Copies the range [first,first+n) into result.
_GLIBCXX26_CONSTEXPR void uninitialized_value_construct(_ForwardIterator __first, _ForwardIterator __last)
Value-initializes objects in the range [first,last).
_GLIBCXX26_CONSTEXPR void uninitialized_default_construct(_ForwardIterator __first, _ForwardIterator __last)
Default-initializes objects in the range [first,last).
_GLIBCXX26_CONSTEXPR _ForwardIterator uninitialized_fill_n(_ForwardIterator __first, _Size __n, const _Tp &__x)
Copies the value x into the range [first,first+n).
_GLIBCXX26_CONSTEXPR _ForwardIterator uninitialized_copy(_InputIterator __first, _InputIterator __last, _ForwardIterator __result)
Copies the range [first,last) into result.
_GLIBCXX26_CONSTEXPR _ForwardIterator uninitialized_move(_InputIterator __first, _InputIterator __last, _ForwardIterator __result)
Move-construct from the range [first,last) into result.
_GLIBCXX26_CONSTEXPR _ForwardIterator uninitialized_value_construct_n(_ForwardIterator __first, _Size __count)
Value-initializes objects in the range [first,first+count).
_GLIBCXX26_CONSTEXPR pair< _InputIterator, _ForwardIterator > uninitialized_move_n(_InputIterator __first, _Size __count, _ForwardIterator __result)
Move-construct from the range [first,first+count) into result.
_GLIBCXX26_CONSTEXPR _ForwardIterator uninitialized_default_construct_n(_ForwardIterator __first, _Size __count)
Default-initializes objects in the range [first,first+count).
constexpr _Tp * to_address(_Tp *__ptr) noexcept
Obtain address referenced by a pointer to an object.
typename remove_pointer< _Tp >::type remove_pointer_t
Alias template for remove_pointer.
constexpr _Tp * addressof(_Tp &__r) noexcept
Returns the actual address of the object or function referenced by r, even in the presence of an over...
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
constexpr _Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
constexpr iterator_traits< _Iter >::iterator_category __iterator_category(const _Iter &)
ISO C++ entities toplevel namespace is std.
constexpr iterator_traits< _InputIterator >::difference_type distance(_InputIterator __first, _InputIterator __last)
A generalization of pointer arithmetic.
constexpr void _Construct(_Tp *__p, _Args &&... __args)
constexpr void advance(_InputIterator &__i, _Distance __n)
A generalization of pointer arithmetic.
constexpr void _Destroy(_ForwardIterator __first, _ForwardIterator __last)
Uniform interface to all allocator types.
static constexpr void construct(_Alloc &__a, _Tp *__p, _Args &&... __args) noexcept(_S_nothrow_construct< _Tp, _Args... >())
Construct an object of type _Tp
Traits class for iterators.
Uniform interface to C++98 and C++11 allocators.