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"
239#pragma GCC diagnostic ignored "-Wclass-memaccess"
249 template<
typename _InputIterator,
typename _ForwardIterator>
251 inline _ForwardIterator
253 _ForwardIterator __result)
276#if __cplusplus >= 201103L
277 using _Dest =
decltype(std::__niter_base(__result));
278 using _Src =
decltype(std::__niter_base(__first));
281#if __glibcxx_raw_memory_algorithms >= 202411L
283 return std::__do_uninit_copy(__first, __last, __result);
286 if constexpr (!__is_trivially_constructible(_ValT,
decltype(*__first)))
287 return std::__do_uninit_copy(__first, __last, __result);
288 else if constexpr (__memcpyable<_Dest, _Src>::__value)
290 ptrdiff_t __n = __last - __first;
291 if (__n > 0) [[__likely__]]
293 using _ValT =
typename remove_pointer<_Src>::type;
294 __builtin_memcpy(std::__niter_base(__result),
295 std::__niter_base(__first),
296 __n *
sizeof(_ValT));
301#if __cpp_lib_concepts
302 else if constexpr (contiguous_iterator<_ForwardIterator>
303 && contiguous_iterator<_InputIterator>)
307 if constexpr (__memcpyable<_DestPtr, _SrcPtr>::__value)
309 if (
auto __n = __last - __first; __n > 0) [[likely]]
314 __builtin_memcpy(__dest, __src, __nbytes);
320 return std::__do_uninit_copy(__first, __last, __result);
324 return std::__do_uninit_copy(__first, __last, __result);
331 const bool __can_memcpy
332 = __memcpyable<_ValueType1*, _ValueType2*>::__value
333 && __is_trivially_constructible(_ValueType2, __decltype(*__first));
335 return __uninitialized_copy<__can_memcpy>::
336 __uninit_copy(__first, __last, __result);
339#pragma GCC diagnostic pop
344 template<
typename _ForwardIterator,
typename _Tp>
345 _GLIBCXX20_CONSTEXPR
void
346 __do_uninit_fill(_ForwardIterator __first, _ForwardIterator __last,
349 _UninitDestroyGuard<_ForwardIterator> __guard(__first);
350 for (; __first != __last; ++__first)
355#if __cplusplus < 201103L
357 template<
bool _CanMemset>
358 struct __uninitialized_fill
360 template<
typename _ForwardIterator,
typename _Tp>
362 __uninit_fill(_ForwardIterator __first, _ForwardIterator __last,
364 { std::__do_uninit_fill(__first, __last, __x); }
368 struct __uninitialized_fill<true>
371 template<
typename _ForwardIterator,
typename _Tp>
373 __uninit_fill(_ForwardIterator __first, _ForwardIterator __last,
376 if (__unwrappable_niter<_ForwardIterator>::__value)
377 __uninit_fill(std::__niter_base(__first),
378 std::__niter_base(__last),
381 std::__do_uninit_fill(__first, __last, __x);
385 template<
typename _Up,
typename _Tp>
387 __uninit_fill(_Up* __first, _Up* __last,
const _Tp& __x)
391 typedef __typeof__(
static_cast<_Up
>(__x)) __check
392 __attribute__((__unused__));
394 if (__first != __last)
395 __builtin_memset(__first, (
unsigned char)__x, __last - __first);
410 template<
typename _ForwardIterator,
typename _Tp>
428#if __cplusplus >= 201103L
429#pragma GCC diagnostic push
430#pragma GCC diagnostic ignored "-Wc++17-extensions"
431#pragma GCC diagnostic ignored "-Wclass-memaccess"
432#if __glibcxx_raw_memory_algorithms >= 202411L
434 return std::__do_uninit_fill(__first, __last, __x);
437 if constexpr (__is_byte<_ValueType>::__value)
441 using _BasePtr =
decltype(std::__niter_base(__first));
444 void* __dest = std::__niter_base(__first);
445 ptrdiff_t __n = __last - __first;
446 if (__n > 0) [[__likely__]]
447 __builtin_memset(__dest, (
unsigned char)__x, __n);
450#if __cpp_lib_concepts
451 else if constexpr (contiguous_iterator<_ForwardIterator>)
454 auto __n = __last - __first;
455 if (__n > 0) [[__likely__]]
456 __builtin_memset(__dest, (
unsigned char)__x, __n);
461 std::__do_uninit_fill(__first, __last, __x);
462#pragma GCC diagnostic pop
464 const bool __can_memset = __is_byte<_ValueType>::__value
465 && __is_integer<_Tp>::__value;
467 __uninitialized_fill<__can_memset>::__uninit_fill(__first, __last, __x);
474 template<
typename _ForwardIterator,
typename _Size,
typename _Tp>
477 __do_uninit_fill_n(_ForwardIterator __first, _Size __n,
const _Tp& __x)
479 _UninitDestroyGuard<_ForwardIterator> __guard(__first);
480#if __cplusplus >= 201103L
481#pragma GCC diagnostic push
482#pragma GCC diagnostic ignored "-Wc++17-extensions"
483 if constexpr (is_integral<_Size>::value)
485 __glibcxx_assert(__n >= 0);
486 else if constexpr (is_floating_point<_Size>::value)
488 __glibcxx_assert(__n >= 0 &&
static_cast<size_t>(__n) == __n);
489#pragma GCC diagnostic pop
491 for (; __n--; ++__first)
497#if __cplusplus < 201103L
499 template<
bool _CanMemset>
500 struct __uninitialized_fill_n
502 template<
typename _ForwardIterator,
typename _Size,
typename _Tp>
503 static _ForwardIterator
504 __uninit_fill_n(_ForwardIterator __first, _Size __n,
506 {
return std::__do_uninit_fill_n(__first, __n, __x); }
510 struct __uninitialized_fill_n<true>
513 template<
typename _ForwardIterator,
typename _Size,
typename _Tp>
514 static _ForwardIterator
515 __uninit_fill_n(_ForwardIterator __first, _Size __n,
518 if (__unwrappable_niter<_ForwardIterator>::__value)
520 _ForwardIterator __last = __first;
522 __uninitialized_fill<true>::__uninit_fill(__first, __last, __x);
526 return std::__do_uninit_fill_n(__first, __n, __x);
532#pragma GCC diagnostic push
533#pragma GCC diagnostic ignored "-Wc++17-extensions"
534#pragma GCC diagnostic ignored "-Wclass-memaccess"
546 template<
typename _ForwardIterator,
typename _Size,
typename _Tp>
548 inline _ForwardIterator
560#if __cplusplus >= 201103L
561#if __glibcxx_raw_memory_algorithms >= 202411L
563 return std::__do_uninit_fill_n(__first, __n, __x);
566 if constexpr (__is_byte<_ValueType>::__value)
570 using _BasePtr =
decltype(std::__niter_base(__first));
573 void* __dest = std::__niter_base(__first);
574 if (__n > 0) [[__likely__]]
576 __builtin_memset(__dest, (
unsigned char)__x, __n);
581#if __cpp_lib_concepts
582 else if constexpr (contiguous_iterator<_ForwardIterator>)
585 if (__n > 0) [[__likely__]]
587 __builtin_memset(__dest, (
unsigned char)__x, __n);
594 return std::__do_uninit_fill_n(__first, __n, __x);
596 const bool __can_memset = __is_byte<_ValueType>::__value
597 && __is_integer<_Tp>::__value
598 && __is_integer<_Size>::__value;
600 return __uninitialized_fill_n<__can_memset>::
601 __uninit_fill_n(__first, __n, __x);
604#pragma GCC diagnostic pop
614 template<
typename _InputIterator,
typename _Sentinel,
615 typename _ForwardIterator,
typename _Allocator>
618 __uninitialized_copy_a(_InputIterator __first, _Sentinel __last,
619 _ForwardIterator __result, _Allocator& __alloc)
621 _UninitDestroyGuard<_ForwardIterator, _Allocator>
622 __guard(__result, __alloc);
625 for (; __first != __last; ++__first, (void)++__result)
632 template<
typename _InputIterator,
typename _Sentinel,
633 typename _ForwardIterator,
typename _Tp>
635 inline _ForwardIterator
636 __uninitialized_copy_a(_InputIterator __first, _Sentinel __last,
639#ifdef __cpp_lib_is_constant_evaluated
640 if (std::is_constant_evaluated())
641 return std::__do_uninit_copy(
std::move(__first), __last, __result);
644#ifdef __glibcxx_ranges
645 if constexpr (!is_same_v<_InputIterator, _Sentinel>)
649 if constexpr (sized_sentinel_for<_Sentinel, _InputIterator>
650 && random_access_iterator<_InputIterator>)
652 __first + (__last - __first),
655 return std::__do_uninit_copy(
std::move(__first), __last, __result);
665 template<
typename _InputIterator,
typename _ForwardIterator,
668 inline _ForwardIterator
669 __uninitialized_move_a(_InputIterator __first, _InputIterator __last,
670 _ForwardIterator __result, _Allocator& __alloc)
672 return std::__uninitialized_copy_a(_GLIBCXX_MAKE_MOVE_ITERATOR(__first),
673 _GLIBCXX_MAKE_MOVE_ITERATOR(__last),
677 template<
typename _InputIterator,
typename _ForwardIterator,
680 inline _ForwardIterator
681 __uninitialized_move_if_noexcept_a(_InputIterator __first,
682 _InputIterator __last,
683 _ForwardIterator __result,
686 return std::__uninitialized_copy_a
687 (_GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(__first),
688 _GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(__last), __result, __alloc);
691 template<
typename _ForwardIterator,
typename _Tp,
typename _Allocator>
694 __uninitialized_fill_a(_ForwardIterator __first, _ForwardIterator __last,
695 const _Tp& __x, _Allocator& __alloc)
697 _UninitDestroyGuard<_ForwardIterator, _Allocator>
698 __guard(__first, __alloc);
700 typedef __gnu_cxx::__alloc_traits<_Allocator> __traits;
701 for (; __first != __last; ++__first)
708 template<
typename _ForwardIterator,
typename _Tp,
typename _Tp2>
711 __uninitialized_fill_a(_ForwardIterator __first, _ForwardIterator __last,
714#ifdef __cpp_lib_is_constant_evaluated
715 if (std::is_constant_evaluated())
716 return std::__do_uninit_fill(__first, __last, __x);
722 template<
typename _ForwardIterator,
typename _Size,
typename _Tp,
726 __uninitialized_fill_n_a(_ForwardIterator __first, _Size __n,
727 const _Tp& __x, _Allocator& __alloc)
729 _UninitDestroyGuard<_ForwardIterator, _Allocator>
730 __guard(__first, __alloc);
731 typedef __gnu_cxx::__alloc_traits<_Allocator> __traits;
732 for (; __n > 0; --__n, (void) ++__first)
739 template<
typename _ForwardIterator,
typename _Size,
typename _Tp,
742 inline _ForwardIterator
743 __uninitialized_fill_n_a(_ForwardIterator __first, _Size __n,
746#ifdef __cpp_lib_is_constant_evaluated
747 if (std::is_constant_evaluated())
748 return std::__do_uninit_fill_n(__first, __n, __x);
763 template<
typename _InputIterator1,
typename _InputIterator2,
764 typename _ForwardIterator,
typename _Allocator>
765 inline _ForwardIterator
766 __uninitialized_copy_move(_InputIterator1 __first1,
767 _InputIterator1 __last1,
768 _InputIterator2 __first2,
769 _InputIterator2 __last2,
770 _ForwardIterator __result,
773 _ForwardIterator __mid = std::__uninitialized_copy_a(__first1, __last1,
775 _UninitDestroyGuard<_ForwardIterator, _Allocator> __guard(__result,
778 __result = std::__uninitialized_move_a(__first2, __last2, __mid, __alloc);
787 template<
typename _InputIterator1,
typename _InputIterator2,
788 typename _ForwardIterator,
typename _Allocator>
789 inline _ForwardIterator
790 __uninitialized_move_copy(_InputIterator1 __first1,
791 _InputIterator1 __last1,
792 _InputIterator2 __first2,
793 _InputIterator2 __last2,
794 _ForwardIterator __result,
797 _ForwardIterator __mid = std::__uninitialized_move_a(__first1, __last1,
799 _UninitDestroyGuard<_ForwardIterator, _Allocator> __guard(__result,
802 __result = std::__uninitialized_copy_a(__first2, __last2, __mid, __alloc);
810 template<
typename _ForwardIterator,
typename _Tp,
typename _InputIterator,
812 inline _ForwardIterator
813 __uninitialized_fill_move(_ForwardIterator __result, _ForwardIterator __mid,
814 const _Tp& __x, _InputIterator __first,
815 _InputIterator __last, _Allocator& __alloc)
817 std::__uninitialized_fill_a(__result, __mid, __x, __alloc);
818 _UninitDestroyGuard<_ForwardIterator, _Allocator> __guard(__result,
821 __result = std::__uninitialized_move_a(__first, __last, __mid, __alloc);
829 template<
typename _InputIterator,
typename _ForwardIterator,
typename _Tp,
832 __uninitialized_move_fill(_InputIterator __first1, _InputIterator __last1,
833 _ForwardIterator __first2,
834 _ForwardIterator __last2,
const _Tp& __x,
837 _ForwardIterator __mid2 = std::__uninitialized_move_a(__first1, __last1,
840 _UninitDestroyGuard<_ForwardIterator, _Allocator> __guard(__first2,
843 std::__uninitialized_fill_a(__mid2, __last2, __x, __alloc);
849#if __cplusplus >= 201103L
855 template<
bool _TrivialValueType>
856 struct __uninitialized_default_1
858 template<
typename _ForwardIterator>
861 __uninit_default(_ForwardIterator __first, _ForwardIterator __last)
863 _UninitDestroyGuard<_ForwardIterator> __guard(__first);
864 for (; __first != __last; ++__first)
871 struct __uninitialized_default_1<true>
873 template<
typename _ForwardIterator>
876 __uninit_default(_ForwardIterator __first, _ForwardIterator __last)
878 if (__first == __last)
881 typename iterator_traits<_ForwardIterator>::value_type* __val
884 if (++__first != __last)
885 std::fill(__first, __last, *__val);
889 template<
bool _TrivialValueType>
890 struct __uninitialized_default_n_1
892 template<
typename _ForwardIterator,
typename _Size>
894 static _ForwardIterator
895 __uninit_default_n(_ForwardIterator __first, _Size __n)
897 _UninitDestroyGuard<_ForwardIterator> __guard(__first);
898 for (; __n > 0; --__n, (void) ++__first)
906 struct __uninitialized_default_n_1<true>
908 template<
typename _ForwardIterator,
typename _Size>
910 static _ForwardIterator
911 __uninit_default_n(_ForwardIterator __first, _Size __n)
915 typename iterator_traits<_ForwardIterator>::value_type* __val
919 __first = std::fill_n(__first, __n - 1, *__val);
927 template<
typename _ForwardIterator>
930 __uninitialized_default(_ForwardIterator __first,
931 _ForwardIterator __last)
933#ifdef __cpp_lib_is_constant_evaluated
934 if (std::is_constant_evaluated())
935 return __uninitialized_default_1<false>::
936 __uninit_default(__first, __last);
944 std::__uninitialized_default_1<__is_trivial(_ValueType)
946 __uninit_default(__first, __last);
951 template<
typename _ForwardIterator,
typename _Size>
953 inline _ForwardIterator
954 __uninitialized_default_n(_ForwardIterator __first, _Size __n)
956#ifdef __cpp_lib_is_constant_evaluated
957 if (std::is_constant_evaluated())
958 return __uninitialized_default_n_1<false>::
959 __uninit_default_n(__first, __n);
965 constexpr bool __can_fill
968 return __uninitialized_default_n_1<__is_trivial(_ValueType)
970 __uninit_default_n(__first, __n);
977 template<
typename _ForwardIterator,
typename _Allocator>
979 __uninitialized_default_a(_ForwardIterator __first,
980 _ForwardIterator __last,
983 _UninitDestroyGuard<_ForwardIterator, _Allocator> __guard(__first,
985 typedef __gnu_cxx::__alloc_traits<_Allocator> __traits;
986 for (; __first != __last; ++__first)
992 template<
typename _ForwardIterator,
typename _Tp>
994 __uninitialized_default_a(_ForwardIterator __first,
995 _ForwardIterator __last,
997 { std::__uninitialized_default(__first, __last); }
1003 template<
typename _ForwardIterator,
typename _Size,
typename _Allocator>
1004 _GLIBCXX20_CONSTEXPR _ForwardIterator
1005 __uninitialized_default_n_a(_ForwardIterator __first, _Size __n,
1006 _Allocator& __alloc)
1008 _UninitDestroyGuard<_ForwardIterator, _Allocator> __guard(__first,
1010 typedef __gnu_cxx::__alloc_traits<_Allocator> __traits;
1011 for (; __n > 0; --__n, (void) ++__first)
1020 template<
typename _ForwardIterator,
typename _Size,
typename _Tp>
1021 _GLIBCXX20_CONSTEXPR
1022 inline _ForwardIterator
1023 __uninitialized_default_n_a(_ForwardIterator __first, _Size __n,
1025 {
return std::__uninitialized_default_n(__first, __n); }
1028 template<
bool _TrivialValueType>
1029 struct __uninitialized_default_novalue_1
1031 template<
typename _ForwardIterator>
1032 _GLIBCXX26_CONSTEXPR
1034 __uninit_default_novalue(_ForwardIterator __first,
1035 _ForwardIterator __last)
1037 _UninitDestroyGuard<_ForwardIterator> __guard(__first);
1038 for (; __first != __last; ++__first)
1045 struct __uninitialized_default_novalue_1<true>
1047 template<
typename _ForwardIterator>
1048 _GLIBCXX26_CONSTEXPR
1050 __uninit_default_novalue(_ForwardIterator, _ForwardIterator)
1055 template<
bool _TrivialValueType>
1056 struct __uninitialized_default_novalue_n_1
1058 template<
typename _ForwardIterator,
typename _Size>
1059 _GLIBCXX26_CONSTEXPR
1060 static _ForwardIterator
1061 __uninit_default_novalue_n(_ForwardIterator __first, _Size __n)
1063 _UninitDestroyGuard<_ForwardIterator> __guard(__first);
1064 for (; __n > 0; --__n, (void) ++__first)
1072 struct __uninitialized_default_novalue_n_1<true>
1074 template<
typename _ForwardIterator,
typename _Size>
1075 _GLIBCXX26_CONSTEXPR
1076 static _ForwardIterator
1077 __uninit_default_novalue_n(_ForwardIterator __first, _Size __n)
1078 {
return std::next(__first, __n); }
1083 template<
typename _ForwardIterator>
1084 _GLIBCXX26_CONSTEXPR
1086 __uninitialized_default_novalue(_ForwardIterator __first,
1087 _ForwardIterator __last)
1092 std::__uninitialized_default_novalue_1<
1094 __uninit_default_novalue(__first, __last);
1099 template<
typename _ForwardIterator,
typename _Size>
1100 _GLIBCXX26_CONSTEXPR
1101 inline _ForwardIterator
1102 __uninitialized_default_novalue_n(_ForwardIterator __first, _Size __n)
1107 return __uninitialized_default_novalue_n_1<
1109 __uninit_default_novalue_n(__first, __n);
1112 template<
typename _InputIterator,
typename _Size,
1113 typename _ForwardIterator>
1114 _GLIBCXX26_CONSTEXPR
1116 __uninitialized_copy_n(_InputIterator __first, _Size __n,
1119 _UninitDestroyGuard<_ForwardIterator> __guard(__result);
1120 for (; __n > 0; --__n, (void) ++__first, ++__result)
1126 template<
typename _RandomAccessIterator,
typename _Size,
1127 typename _ForwardIterator>
1128 _GLIBCXX26_CONSTEXPR
1129 inline _ForwardIterator
1130 __uninitialized_copy_n(_RandomAccessIterator __first, _Size __n,
1131 _ForwardIterator __result,
1135 template<
typename _InputIterator,
typename _Size,
1136 typename _ForwardIterator>
1137 _GLIBCXX26_CONSTEXPR
1139 __uninitialized_copy_n_pair(_InputIterator __first, _Size __n,
1142 _UninitDestroyGuard<_ForwardIterator> __guard(__result);
1143 for (; __n > 0; --__n, (void) ++__first, ++__result)
1146 return {__first, __result};
1149 template<
typename _RandomAccessIterator,
typename _Size,
1150 typename _ForwardIterator>
1151 _GLIBCXX26_CONSTEXPR
1153 __uninitialized_copy_n_pair(_RandomAccessIterator __first, _Size __n,
1154 _ForwardIterator __result,
1158 auto __first_res = std::next(__first, __n);
1159 return {__first_res, __second_res};
1174 template<
typename _InputIterator,
typename _Size,
typename _ForwardIterator>
1175 _GLIBCXX26_CONSTEXPR
1176 inline _ForwardIterator
1178 _ForwardIterator __result)
1179 {
return std::__uninitialized_copy_n(__first, __n, __result,
1183 template<
typename _InputIterator,
typename _Size,
typename _ForwardIterator>
1184 _GLIBCXX26_CONSTEXPR
1186 __uninitialized_copy_n_pair(_InputIterator __first, _Size __n,
1187 _ForwardIterator __result)
1190 std::__uninitialized_copy_n_pair(__first, __n, __result,
1196#ifdef __glibcxx_raw_memory_algorithms
1203 template <
typename _ForwardIterator>
1204 _GLIBCXX26_CONSTEXPR
1207 _ForwardIterator __last)
1209 std::__uninitialized_default_novalue(__first, __last);
1219 template <
typename _ForwardIterator,
typename _Size>
1220 _GLIBCXX26_CONSTEXPR
1221 inline _ForwardIterator
1224 return std::__uninitialized_default_novalue_n(__first, __count);
1233 template <
typename _ForwardIterator>
1234 _GLIBCXX26_CONSTEXPR
1237 _ForwardIterator __last)
1239 return std::__uninitialized_default(__first, __last);
1249 template <
typename _ForwardIterator,
typename _Size>
1250 _GLIBCXX26_CONSTEXPR
1251 inline _ForwardIterator
1254 return std::__uninitialized_default_n(__first, __count);
1265 template <
typename _InputIterator,
typename _ForwardIterator>
1266 _GLIBCXX26_CONSTEXPR
1267 inline _ForwardIterator
1269 _ForwardIterator __result)
1272 std::make_move_iterator(__last),
1284 template <
typename _InputIterator,
typename _Size,
typename _ForwardIterator>
1285 _GLIBCXX26_CONSTEXPR
1288 _ForwardIterator __result)
1291 = std::__uninitialized_copy_n_pair(std::make_move_iterator(__first),
1293 return {__res.first.base(), __res.second};
1297#if __cplusplus >= 201103L
1300 template<
typename _Tp,
typename _Up,
typename _Allocator>
1301 _GLIBCXX20_CONSTEXPR
1303 __relocate_object_a(_Tp* __restrict __dest, _Up* __restrict __orig,
1304 _Allocator& __alloc)
1311 __traits::construct(__alloc, __dest,
std::move(*__orig));
1317 template<
typename _Tp,
typename =
void>
1318 struct __is_bitwise_relocatable
1319 : __bool_constant<__is_trivial(_Tp)>
1322 template <
typename _InputIterator,
typename _ForwardIterator,
1323 typename _Allocator>
1324 _GLIBCXX20_CONSTEXPR
1325 inline _ForwardIterator
1326 __relocate_a_1(_InputIterator __first, _InputIterator __last,
1327 _ForwardIterator __result, _Allocator& __alloc)
1328 noexcept(
noexcept(std::__relocate_object_a(
std::addressof(*__result),
1336 static_assert(std::is_same<_ValueType, _ValueType2>::value,
1337 "relocation is only possible for values of the same type");
1338 _ForwardIterator __cur = __result;
1339 for (; __first != __last; ++__first, (void)++__cur)
1346 template <
typename _Tp,
typename _Up>
1347 _GLIBCXX20_CONSTEXPR
1348 inline __enable_if_t<std::__is_bitwise_relocatable<_Tp>::value, _Tp*>
1349 __relocate_a_1(_Tp* __first, _Tp* __last,
1353 ptrdiff_t __count = __last - __first;
1356#ifdef __cpp_lib_is_constant_evaluated
1357 if (std::is_constant_evaluated())
1361 __gnu_cxx::__normal_iterator<_Tp*, void> __out(__result);
1362 __out = std::__relocate_a_1(__first, __last, __out, __alloc);
1363 return __out.base();
1366 __builtin_memcpy(__result, __first, __count *
sizeof(_Tp));
1368 return __result + __count;
1372 template <
typename _InputIterator,
typename _ForwardIterator,
1373 typename _Allocator>
1374 _GLIBCXX20_CONSTEXPR
1375 inline _ForwardIterator
1376 __relocate_a(_InputIterator __first, _InputIterator __last,
1377 _ForwardIterator __result, _Allocator& __alloc)
1378 noexcept(
noexcept(__relocate_a_1(std::__niter_base(__first),
1379 std::__niter_base(__last),
1380 std::__niter_base(__result), __alloc)))
1382 return std::__relocate_a_1(std::__niter_base(__first),
1383 std::__niter_base(__last),
1384 std::__niter_base(__result), __alloc);
1392_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.