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))
121#if __cplusplus == 201703L
124 _S_destroy(_M_first, *_M_cur);
131 void release() { _M_cur = 0; }
133 _ForwardIterator
const _M_first;
134 _ForwardIterator* _M_cur;
137 _UninitDestroyGuard(
const _UninitDestroyGuard&);
139#if __cplusplus == 201703L
140 template<
typename _Iter>
142 _S_destroy(_Iter __first, _Iter __last)
144 using _ValT =
typename iterator_traits<_Iter>::value_type;
145 if constexpr (is_array<_ValT>::value)
146 for (; __first != __last; ++__first)
147 _S_destroy(*__first, *__first + extent<_ValT>::value);
156 template<
typename _InputIterator,
typename _Sentinel,
157 typename _ForwardIterator>
160 __do_uninit_copy(_InputIterator __first, _Sentinel __last,
161 _ForwardIterator __result)
163 _UninitDestroyGuard<_ForwardIterator> __guard(__result);
164 for (; __first != __last; ++__first, (void)++__result)
170#if __cplusplus < 201103L
173 template<
typename _Iter,
174 typename _Base = __decltype(std::__niter_base(*(_Iter*)0))>
175 struct __unwrappable_niter
176 {
enum { __value =
false }; };
178 template<
typename _Iter,
typename _Tp>
179 struct __unwrappable_niter<_Iter, _Tp*>
180 {
enum { __value =
true }; };
183 template<
bool _CanMemcpy>
184 struct __uninitialized_copy
186 template<
typename _InputIterator,
typename _ForwardIterator>
187 static _ForwardIterator
188 __uninit_copy(_InputIterator __first, _InputIterator __last,
189 _ForwardIterator __result)
190 {
return std::__do_uninit_copy(__first, __last, __result); }
194 struct __uninitialized_copy<true>
197 template<
typename _InputIterator,
typename _ForwardIterator>
198 static _ForwardIterator
199 __uninit_copy(_InputIterator __first, _InputIterator __last,
200 _ForwardIterator __result)
202 if (__unwrappable_niter<_InputIterator>::__value
203 && __unwrappable_niter<_ForwardIterator>::__value)
205 __uninit_copy(std::__niter_base(__first),
206 std::__niter_base(__last),
207 std::__niter_base(__result));
212 return std::__do_uninit_copy(__first, __last, __result);
216 template<
typename _Tp,
typename _Up>
218 __uninit_copy(_Tp* __first, _Tp* __last, _Up* __result)
222 typedef __typeof__(
static_cast<_Up
>(*__first)) __check
223 __attribute__((__unused__));
225 const ptrdiff_t __n = __last - __first;
226 if (__builtin_expect(__n > 0,
true))
228 __builtin_memcpy(__result, __first, __n *
sizeof(_Tp));
237#pragma GCC diagnostic push
238#pragma GCC diagnostic ignored "-Wc++17-extensions"
248 template<
typename _InputIterator,
typename _ForwardIterator>
250 inline _ForwardIterator
252 _ForwardIterator __result)
275#if __cplusplus >= 201103L
276 using _Dest =
decltype(std::__niter_base(__result));
277 using _Src =
decltype(std::__niter_base(__first));
280#if __glibcxx_raw_memory_algorithms >= 202411L
282 return std::__do_uninit_copy(__first, __last, __result);
285 if constexpr (!__is_trivially_constructible(_ValT,
decltype(*__first)))
286 return std::__do_uninit_copy(__first, __last, __result);
287 else if constexpr (__memcpyable<_Dest, _Src>::__value)
289 ptrdiff_t __n = __last - __first;
290 if (__n > 0) [[__likely__]]
292 using _ValT =
typename remove_pointer<_Src>::type;
293 __builtin_memcpy(std::__niter_base(__result),
294 std::__niter_base(__first),
295 __n *
sizeof(_ValT));
300#if __cpp_lib_concepts
301 else if constexpr (contiguous_iterator<_ForwardIterator>
302 && contiguous_iterator<_InputIterator>)
306 if constexpr (__memcpyable<_DestPtr, _SrcPtr>::__value)
308 if (
auto __n = __last - __first; __n > 0) [[likely]]
313 __builtin_memcpy(__dest, __src, __nbytes);
319 return std::__do_uninit_copy(__first, __last, __result);
323 return std::__do_uninit_copy(__first, __last, __result);
330 const bool __can_memcpy
331 = __memcpyable<_ValueType1*, _ValueType2*>::__value
332 && __is_trivially_constructible(_ValueType2, __decltype(*__first));
334 return __uninitialized_copy<__can_memcpy>::
335 __uninit_copy(__first, __last, __result);
338#pragma GCC diagnostic pop
343 template<
typename _ForwardIterator,
typename _Tp>
344 _GLIBCXX20_CONSTEXPR
void
345 __do_uninit_fill(_ForwardIterator __first, _ForwardIterator __last,
348 _UninitDestroyGuard<_ForwardIterator> __guard(__first);
349 for (; __first != __last; ++__first)
354#if __cplusplus < 201103L
356 template<
bool _CanMemset>
357 struct __uninitialized_fill
359 template<
typename _ForwardIterator,
typename _Tp>
361 __uninit_fill(_ForwardIterator __first, _ForwardIterator __last,
363 { std::__do_uninit_fill(__first, __last, __x); }
367 struct __uninitialized_fill<true>
370 template<
typename _ForwardIterator,
typename _Tp>
372 __uninit_fill(_ForwardIterator __first, _ForwardIterator __last,
375 if (__unwrappable_niter<_ForwardIterator>::__value)
376 __uninit_fill(std::__niter_base(__first),
377 std::__niter_base(__last),
380 std::__do_uninit_fill(__first, __last, __x);
384 template<
typename _Up,
typename _Tp>
386 __uninit_fill(_Up* __first, _Up* __last,
const _Tp& __x)
390 typedef __typeof__(
static_cast<_Up
>(__x)) __check
391 __attribute__((__unused__));
393 if (__first != __last)
394 __builtin_memset(__first, (
unsigned char)__x, __last - __first);
409 template<
typename _ForwardIterator,
typename _Tp>
427#if __cplusplus >= 201103L
428#pragma GCC diagnostic push
429#pragma GCC diagnostic ignored "-Wc++17-extensions"
430#if __glibcxx_raw_memory_algorithms >= 202411L
432 return std::__do_uninit_fill(__first, __last, __x);
435 if constexpr (__is_byte<_ValueType>::__value)
439 using _BasePtr =
decltype(std::__niter_base(__first));
442 void* __dest = std::__niter_base(__first);
443 ptrdiff_t __n = __last - __first;
444 if (__n > 0) [[__likely__]]
445 __builtin_memset(__dest, (
unsigned char)__x, __n);
448#if __cpp_lib_concepts
449 else if constexpr (contiguous_iterator<_ForwardIterator>)
452 auto __n = __last - __first;
453 if (__n > 0) [[__likely__]]
454 __builtin_memset(__dest, (
unsigned char)__x, __n);
459 std::__do_uninit_fill(__first, __last, __x);
460#pragma GCC diagnostic pop
462 const bool __can_memset = __is_byte<_ValueType>::__value
463 && __is_integer<_Tp>::__value;
465 __uninitialized_fill<__can_memset>::__uninit_fill(__first, __last, __x);
472 template<
typename _ForwardIterator,
typename _Size,
typename _Tp>
475 __do_uninit_fill_n(_ForwardIterator __first, _Size __n,
const _Tp& __x)
477 _UninitDestroyGuard<_ForwardIterator> __guard(__first);
478#if __cplusplus >= 201103L
479#pragma GCC diagnostic push
480#pragma GCC diagnostic ignored "-Wc++17-extensions"
481 if constexpr (is_integral<_Size>::value)
483 __glibcxx_assert(__n >= 0);
484 else if constexpr (is_floating_point<_Size>::value)
486 __glibcxx_assert(__n >= 0 &&
static_cast<size_t>(__n) == __n);
487#pragma GCC diagnostic pop
489 for (; __n--; ++__first)
495#if __cplusplus < 201103L
497 template<
bool _CanMemset>
498 struct __uninitialized_fill_n
500 template<
typename _ForwardIterator,
typename _Size,
typename _Tp>
501 static _ForwardIterator
502 __uninit_fill_n(_ForwardIterator __first, _Size __n,
504 {
return std::__do_uninit_fill_n(__first, __n, __x); }
508 struct __uninitialized_fill_n<true>
511 template<
typename _ForwardIterator,
typename _Size,
typename _Tp>
512 static _ForwardIterator
513 __uninit_fill_n(_ForwardIterator __first, _Size __n,
516 if (__unwrappable_niter<_ForwardIterator>::__value)
518 _ForwardIterator __last = __first;
520 __uninitialized_fill<true>::__uninit_fill(__first, __last, __x);
524 return std::__do_uninit_fill_n(__first, __n, __x);
530#pragma GCC diagnostic push
531#pragma GCC diagnostic ignored "-Wc++17-extensions"
543 template<
typename _ForwardIterator,
typename _Size,
typename _Tp>
545 inline _ForwardIterator
557#if __cplusplus >= 201103L
558#if __glibcxx_raw_memory_algorithms >= 202411L
560 return std::__do_uninit_fill_n(__first, __n, __x);
563 if constexpr (__is_byte<_ValueType>::__value)
567 using _BasePtr =
decltype(std::__niter_base(__first));
570 void* __dest = std::__niter_base(__first);
571 if (__n > 0) [[__likely__]]
573 __builtin_memset(__dest, (
unsigned char)__x, __n);
578#if __cpp_lib_concepts
579 else if constexpr (contiguous_iterator<_ForwardIterator>)
582 if (__n > 0) [[__likely__]]
584 __builtin_memset(__dest, (
unsigned char)__x, __n);
591 return std::__do_uninit_fill_n(__first, __n, __x);
593 const bool __can_memset = __is_byte<_ValueType>::__value
594 && __is_integer<_Tp>::__value
595 && __is_integer<_Size>::__value;
597 return __uninitialized_fill_n<__can_memset>::
598 __uninit_fill_n(__first, __n, __x);
601#pragma GCC diagnostic pop
611 template<
typename _InputIterator,
typename _Sentinel,
612 typename _ForwardIterator,
typename _Allocator>
615 __uninitialized_copy_a(_InputIterator __first, _Sentinel __last,
616 _ForwardIterator __result, _Allocator& __alloc)
618 _UninitDestroyGuard<_ForwardIterator, _Allocator>
619 __guard(__result, __alloc);
622 for (; __first != __last; ++__first, (void)++__result)
629 template<
typename _InputIterator,
typename _Sentinel,
630 typename _ForwardIterator,
typename _Tp>
632 inline _ForwardIterator
633 __uninitialized_copy_a(_InputIterator __first, _Sentinel __last,
636#ifdef __cpp_lib_is_constant_evaluated
637 if (std::is_constant_evaluated())
638 return std::__do_uninit_copy(
std::move(__first), __last, __result);
641#ifdef __glibcxx_ranges
642 if constexpr (!is_same_v<_InputIterator, _Sentinel>)
646 if constexpr (sized_sentinel_for<_Sentinel, _InputIterator>
647 && random_access_iterator<_InputIterator>)
649 __first + (__last - __first),
652 return std::__do_uninit_copy(
std::move(__first), __last, __result);
662 template<
typename _InputIterator,
typename _ForwardIterator,
665 inline _ForwardIterator
666 __uninitialized_move_a(_InputIterator __first, _InputIterator __last,
667 _ForwardIterator __result, _Allocator& __alloc)
669 return std::__uninitialized_copy_a(_GLIBCXX_MAKE_MOVE_ITERATOR(__first),
670 _GLIBCXX_MAKE_MOVE_ITERATOR(__last),
674 template<
typename _InputIterator,
typename _ForwardIterator,
677 inline _ForwardIterator
678 __uninitialized_move_if_noexcept_a(_InputIterator __first,
679 _InputIterator __last,
680 _ForwardIterator __result,
683 return std::__uninitialized_copy_a
684 (_GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(__first),
685 _GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(__last), __result, __alloc);
688 template<
typename _ForwardIterator,
typename _Tp,
typename _Allocator>
691 __uninitialized_fill_a(_ForwardIterator __first, _ForwardIterator __last,
692 const _Tp& __x, _Allocator& __alloc)
694 _UninitDestroyGuard<_ForwardIterator, _Allocator>
695 __guard(__first, __alloc);
697 typedef __gnu_cxx::__alloc_traits<_Allocator> __traits;
698 for (; __first != __last; ++__first)
705 template<
typename _ForwardIterator,
typename _Tp,
typename _Tp2>
708 __uninitialized_fill_a(_ForwardIterator __first, _ForwardIterator __last,
711#ifdef __cpp_lib_is_constant_evaluated
712 if (std::is_constant_evaluated())
713 return std::__do_uninit_fill(__first, __last, __x);
719 template<
typename _ForwardIterator,
typename _Size,
typename _Tp,
723 __uninitialized_fill_n_a(_ForwardIterator __first, _Size __n,
724 const _Tp& __x, _Allocator& __alloc)
726 _UninitDestroyGuard<_ForwardIterator, _Allocator>
727 __guard(__first, __alloc);
728 typedef __gnu_cxx::__alloc_traits<_Allocator> __traits;
729 for (; __n > 0; --__n, (void) ++__first)
736 template<
typename _ForwardIterator,
typename _Size,
typename _Tp,
739 inline _ForwardIterator
740 __uninitialized_fill_n_a(_ForwardIterator __first, _Size __n,
743#ifdef __cpp_lib_is_constant_evaluated
744 if (std::is_constant_evaluated())
745 return std::__do_uninit_fill_n(__first, __n, __x);
760 template<
typename _InputIterator1,
typename _InputIterator2,
761 typename _ForwardIterator,
typename _Allocator>
762 inline _ForwardIterator
763 __uninitialized_copy_move(_InputIterator1 __first1,
764 _InputIterator1 __last1,
765 _InputIterator2 __first2,
766 _InputIterator2 __last2,
767 _ForwardIterator __result,
770 _ForwardIterator __mid = std::__uninitialized_copy_a(__first1, __last1,
772 _UninitDestroyGuard<_ForwardIterator, _Allocator> __guard(__result,
775 __result = std::__uninitialized_move_a(__first2, __last2, __mid, __alloc);
784 template<
typename _InputIterator1,
typename _InputIterator2,
785 typename _ForwardIterator,
typename _Allocator>
786 inline _ForwardIterator
787 __uninitialized_move_copy(_InputIterator1 __first1,
788 _InputIterator1 __last1,
789 _InputIterator2 __first2,
790 _InputIterator2 __last2,
791 _ForwardIterator __result,
794 _ForwardIterator __mid = std::__uninitialized_move_a(__first1, __last1,
796 _UninitDestroyGuard<_ForwardIterator, _Allocator> __guard(__result,
799 __result = std::__uninitialized_copy_a(__first2, __last2, __mid, __alloc);
807 template<
typename _ForwardIterator,
typename _Tp,
typename _InputIterator,
809 inline _ForwardIterator
810 __uninitialized_fill_move(_ForwardIterator __result, _ForwardIterator __mid,
811 const _Tp& __x, _InputIterator __first,
812 _InputIterator __last, _Allocator& __alloc)
814 std::__uninitialized_fill_a(__result, __mid, __x, __alloc);
815 _UninitDestroyGuard<_ForwardIterator, _Allocator> __guard(__result,
818 __result = std::__uninitialized_move_a(__first, __last, __mid, __alloc);
826 template<
typename _InputIterator,
typename _ForwardIterator,
typename _Tp,
829 __uninitialized_move_fill(_InputIterator __first1, _InputIterator __last1,
830 _ForwardIterator __first2,
831 _ForwardIterator __last2,
const _Tp& __x,
834 _ForwardIterator __mid2 = std::__uninitialized_move_a(__first1, __last1,
837 _UninitDestroyGuard<_ForwardIterator, _Allocator> __guard(__first2,
840 std::__uninitialized_fill_a(__mid2, __last2, __x, __alloc);
846#if __cplusplus >= 201103L
852 template<
bool _TrivialValueType>
853 struct __uninitialized_default_1
855 template<
typename _ForwardIterator>
858 __uninit_default(_ForwardIterator __first, _ForwardIterator __last)
860 _UninitDestroyGuard<_ForwardIterator> __guard(__first);
861 for (; __first != __last; ++__first)
868 struct __uninitialized_default_1<true>
870 template<
typename _ForwardIterator>
873 __uninit_default(_ForwardIterator __first, _ForwardIterator __last)
875 if (__first == __last)
878 typename iterator_traits<_ForwardIterator>::value_type* __val
881 if (++__first != __last)
882 std::fill(__first, __last, *__val);
886 template<
bool _TrivialValueType>
887 struct __uninitialized_default_n_1
889 template<
typename _ForwardIterator,
typename _Size>
891 static _ForwardIterator
892 __uninit_default_n(_ForwardIterator __first, _Size __n)
894 _UninitDestroyGuard<_ForwardIterator> __guard(__first);
895 for (; __n > 0; --__n, (void) ++__first)
903 struct __uninitialized_default_n_1<true>
905 template<
typename _ForwardIterator,
typename _Size>
907 static _ForwardIterator
908 __uninit_default_n(_ForwardIterator __first, _Size __n)
912 typename iterator_traits<_ForwardIterator>::value_type* __val
916 __first = std::fill_n(__first, __n - 1, *__val);
924 template<
typename _ForwardIterator>
927 __uninitialized_default(_ForwardIterator __first,
928 _ForwardIterator __last)
930#ifdef __cpp_lib_is_constant_evaluated
931 if (std::is_constant_evaluated())
932 return __uninitialized_default_1<false>::
933 __uninit_default(__first, __last);
941 std::__uninitialized_default_1<__is_trivial(_ValueType)
943 __uninit_default(__first, __last);
948 template<
typename _ForwardIterator,
typename _Size>
950 inline _ForwardIterator
951 __uninitialized_default_n(_ForwardIterator __first, _Size __n)
953#ifdef __cpp_lib_is_constant_evaluated
954 if (std::is_constant_evaluated())
955 return __uninitialized_default_n_1<false>::
956 __uninit_default_n(__first, __n);
962 constexpr bool __can_fill
965 return __uninitialized_default_n_1<__is_trivial(_ValueType)
967 __uninit_default_n(__first, __n);
974 template<
typename _ForwardIterator,
typename _Allocator>
976 __uninitialized_default_a(_ForwardIterator __first,
977 _ForwardIterator __last,
980 _UninitDestroyGuard<_ForwardIterator, _Allocator> __guard(__first,
982 typedef __gnu_cxx::__alloc_traits<_Allocator> __traits;
983 for (; __first != __last; ++__first)
989 template<
typename _ForwardIterator,
typename _Tp>
991 __uninitialized_default_a(_ForwardIterator __first,
992 _ForwardIterator __last,
994 { std::__uninitialized_default(__first, __last); }
1000 template<
typename _ForwardIterator,
typename _Size,
typename _Allocator>
1001 _GLIBCXX20_CONSTEXPR _ForwardIterator
1002 __uninitialized_default_n_a(_ForwardIterator __first, _Size __n,
1003 _Allocator& __alloc)
1005 _UninitDestroyGuard<_ForwardIterator, _Allocator> __guard(__first,
1007 typedef __gnu_cxx::__alloc_traits<_Allocator> __traits;
1008 for (; __n > 0; --__n, (void) ++__first)
1017 template<
typename _ForwardIterator,
typename _Size,
typename _Tp>
1018 _GLIBCXX20_CONSTEXPR
1019 inline _ForwardIterator
1020 __uninitialized_default_n_a(_ForwardIterator __first, _Size __n,
1022 {
return std::__uninitialized_default_n(__first, __n); }
1025 template<
bool _TrivialValueType>
1026 struct __uninitialized_default_novalue_1
1028 template<
typename _ForwardIterator>
1029 _GLIBCXX26_CONSTEXPR
1031 __uninit_default_novalue(_ForwardIterator __first,
1032 _ForwardIterator __last)
1034 _UninitDestroyGuard<_ForwardIterator> __guard(__first);
1035 for (; __first != __last; ++__first)
1042 struct __uninitialized_default_novalue_1<true>
1044 template<
typename _ForwardIterator>
1045 _GLIBCXX26_CONSTEXPR
1047 __uninit_default_novalue(_ForwardIterator, _ForwardIterator)
1052 template<
bool _TrivialValueType>
1053 struct __uninitialized_default_novalue_n_1
1055 template<
typename _ForwardIterator,
typename _Size>
1056 _GLIBCXX26_CONSTEXPR
1057 static _ForwardIterator
1058 __uninit_default_novalue_n(_ForwardIterator __first, _Size __n)
1060 _UninitDestroyGuard<_ForwardIterator> __guard(__first);
1061 for (; __n > 0; --__n, (void) ++__first)
1069 struct __uninitialized_default_novalue_n_1<true>
1071 template<
typename _ForwardIterator,
typename _Size>
1072 _GLIBCXX26_CONSTEXPR
1073 static _ForwardIterator
1074 __uninit_default_novalue_n(_ForwardIterator __first, _Size __n)
1075 {
return std::next(__first, __n); }
1080 template<
typename _ForwardIterator>
1081 _GLIBCXX26_CONSTEXPR
1083 __uninitialized_default_novalue(_ForwardIterator __first,
1084 _ForwardIterator __last)
1089 std::__uninitialized_default_novalue_1<
1091 __uninit_default_novalue(__first, __last);
1096 template<
typename _ForwardIterator,
typename _Size>
1097 _GLIBCXX26_CONSTEXPR
1098 inline _ForwardIterator
1099 __uninitialized_default_novalue_n(_ForwardIterator __first, _Size __n)
1104 return __uninitialized_default_novalue_n_1<
1106 __uninit_default_novalue_n(__first, __n);
1109 template<
typename _InputIterator,
typename _Size,
1110 typename _ForwardIterator>
1111 _GLIBCXX26_CONSTEXPR
1113 __uninitialized_copy_n(_InputIterator __first, _Size __n,
1116 _UninitDestroyGuard<_ForwardIterator> __guard(__result);
1117 for (; __n > 0; --__n, (void) ++__first, ++__result)
1123 template<
typename _RandomAccessIterator,
typename _Size,
1124 typename _ForwardIterator>
1125 _GLIBCXX26_CONSTEXPR
1126 inline _ForwardIterator
1127 __uninitialized_copy_n(_RandomAccessIterator __first, _Size __n,
1128 _ForwardIterator __result,
1132 template<
typename _InputIterator,
typename _Size,
1133 typename _ForwardIterator>
1134 _GLIBCXX26_CONSTEXPR
1136 __uninitialized_copy_n_pair(_InputIterator __first, _Size __n,
1139 _UninitDestroyGuard<_ForwardIterator> __guard(__result);
1140 for (; __n > 0; --__n, (void) ++__first, ++__result)
1143 return {__first, __result};
1146 template<
typename _RandomAccessIterator,
typename _Size,
1147 typename _ForwardIterator>
1148 _GLIBCXX26_CONSTEXPR
1150 __uninitialized_copy_n_pair(_RandomAccessIterator __first, _Size __n,
1151 _ForwardIterator __result,
1155 auto __first_res = std::next(__first, __n);
1156 return {__first_res, __second_res};
1171 template<
typename _InputIterator,
typename _Size,
typename _ForwardIterator>
1172 _GLIBCXX26_CONSTEXPR
1173 inline _ForwardIterator
1175 _ForwardIterator __result)
1176 {
return std::__uninitialized_copy_n(__first, __n, __result,
1180 template<
typename _InputIterator,
typename _Size,
typename _ForwardIterator>
1181 _GLIBCXX26_CONSTEXPR
1183 __uninitialized_copy_n_pair(_InputIterator __first, _Size __n,
1184 _ForwardIterator __result)
1187 std::__uninitialized_copy_n_pair(__first, __n, __result,
1193#ifdef __glibcxx_raw_memory_algorithms
1200 template <
typename _ForwardIterator>
1201 _GLIBCXX26_CONSTEXPR
1204 _ForwardIterator __last)
1206 std::__uninitialized_default_novalue(__first, __last);
1216 template <
typename _ForwardIterator,
typename _Size>
1217 _GLIBCXX26_CONSTEXPR
1218 inline _ForwardIterator
1221 return std::__uninitialized_default_novalue_n(__first, __count);
1230 template <
typename _ForwardIterator>
1231 _GLIBCXX26_CONSTEXPR
1234 _ForwardIterator __last)
1236 return std::__uninitialized_default(__first, __last);
1246 template <
typename _ForwardIterator,
typename _Size>
1247 _GLIBCXX26_CONSTEXPR
1248 inline _ForwardIterator
1251 return std::__uninitialized_default_n(__first, __count);
1262 template <
typename _InputIterator,
typename _ForwardIterator>
1263 _GLIBCXX26_CONSTEXPR
1264 inline _ForwardIterator
1266 _ForwardIterator __result)
1269 (_GLIBCXX_MAKE_MOVE_ITERATOR(__first),
1270 _GLIBCXX_MAKE_MOVE_ITERATOR(__last), __result);
1281 template <
typename _InputIterator,
typename _Size,
typename _ForwardIterator>
1282 _GLIBCXX26_CONSTEXPR
1285 _ForwardIterator __result)
1287 auto __res = std::__uninitialized_copy_n_pair
1288 (_GLIBCXX_MAKE_MOVE_ITERATOR(__first),
1290 return {__res.first.base(), __res.second};
1294#if __cplusplus >= 201103L
1297 template<
typename _Tp,
typename _Up,
typename _Allocator>
1298 _GLIBCXX20_CONSTEXPR
1300 __relocate_object_a(_Tp* __restrict __dest, _Up* __restrict __orig,
1301 _Allocator& __alloc)
1308 __traits::construct(__alloc, __dest,
std::move(*__orig));
1314 template<
typename _Tp,
typename =
void>
1315 struct __is_bitwise_relocatable
1316 : __bool_constant<__is_trivial(_Tp)>
1319 template <
typename _InputIterator,
typename _ForwardIterator,
1320 typename _Allocator>
1321 _GLIBCXX20_CONSTEXPR
1322 inline _ForwardIterator
1323 __relocate_a_1(_InputIterator __first, _InputIterator __last,
1324 _ForwardIterator __result, _Allocator& __alloc)
1325 noexcept(
noexcept(std::__relocate_object_a(
std::addressof(*__result),
1333 static_assert(std::is_same<_ValueType, _ValueType2>::value,
1334 "relocation is only possible for values of the same type");
1335 _ForwardIterator __cur = __result;
1336 for (; __first != __last; ++__first, (void)++__cur)
1343 template <
typename _Tp,
typename _Up>
1344 _GLIBCXX20_CONSTEXPR
1345 inline __enable_if_t<std::__is_bitwise_relocatable<_Tp>::value, _Tp*>
1346 __relocate_a_1(_Tp* __first, _Tp* __last,
1350 ptrdiff_t __count = __last - __first;
1353#ifdef __cpp_lib_is_constant_evaluated
1354 if (std::is_constant_evaluated())
1358 __gnu_cxx::__normal_iterator<_Tp*, void> __out(__result);
1359 __out = std::__relocate_a_1(__first, __last, __out, __alloc);
1360 return __out.base();
1363 __builtin_memcpy(__result, __first, __count *
sizeof(_Tp));
1365 return __result + __count;
1369 template <
typename _InputIterator,
typename _ForwardIterator,
1370 typename _Allocator>
1371 _GLIBCXX20_CONSTEXPR
1372 inline _ForwardIterator
1373 __relocate_a(_InputIterator __first, _InputIterator __last,
1374 _ForwardIterator __result, _Allocator& __alloc)
1375 noexcept(
noexcept(__relocate_a_1(std::__niter_base(__first),
1376 std::__niter_base(__last),
1377 std::__niter_base(__result), __alloc)))
1379 return std::__relocate_a_1(std::__niter_base(__first),
1380 std::__niter_base(__last),
1381 std::__niter_base(__result), __alloc);
1389_GLIBCXX_END_NAMESPACE_VERSION
_ForwardIterator uninitialized_copy_n(_InputIterator __first, _Size __n, _ForwardIterator __result)
Copies the range [first,first+n) into result.
void uninitialized_fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp &__x)
Copies the value x into the range [first,last).
_ForwardIterator uninitialized_value_construct_n(_ForwardIterator __first, _Size __count)
Value-initializes objects in the range [first,first+count).
_ForwardIterator uninitialized_move(_InputIterator __first, _InputIterator __last, _ForwardIterator __result)
Move-construct from 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).
_ForwardIterator uninitialized_default_construct_n(_ForwardIterator __first, _Size __count)
Default-initializes objects in the range [first,first+count).
void uninitialized_default_construct(_ForwardIterator __first, _ForwardIterator __last)
Default-initializes objects in the range [first,last).
_ForwardIterator uninitialized_copy(_InputIterator __first, _InputIterator __last, _ForwardIterator __result)
Copies the range [first,last) into result.
void uninitialized_value_construct(_ForwardIterator __first, _ForwardIterator __last)
Value-initializes objects in the range [first,last).
pair< _InputIterator, _ForwardIterator > uninitialized_move_n(_InputIterator __first, _Size __count, _ForwardIterator __result)
Move-construct from the range [first,first+count) into result.
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.
pair(_T1, _T2) -> pair< _T1, _T2 >
Two pairs are equal iff their members are equal.
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)
is_trivially_default_constructible
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
static constexpr void destroy(_Alloc &__a, _Tp *__p) noexcept(_S_nothrow_destroy< _Tp >())
Destroy an object of type _Tp.
The standard allocator, as per C++03 [20.4.1].
Struct holding two objects of arbitrary type.
Random-access iterators support a superset of bidirectional iterator operations.
Traits class for iterators.
Uniform interface to C++98 and C++11 allocators.