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);
409 template<
typename _ForwardIterator,
410 typename _Tp _GLIBCXX26_ALGO_DEF_VAL_T(_ForwardIterator)>
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,
547 typename _Tp _GLIBCXX26_ALGO_DEF_VAL_T(_ForwardIterator)>
549 inline _ForwardIterator
561#if __cplusplus >= 201103L
562#if __glibcxx_raw_memory_algorithms >= 202411L
564 return std::__do_uninit_fill_n(__first, __n, __x);
567 if constexpr (__is_byte<_ValueType>::__value)
571 using _BasePtr =
decltype(std::__niter_base(__first));
574 void* __dest = std::__niter_base(__first);
575 if (__n > 0) [[__likely__]]
577 __builtin_memset(__dest, (
unsigned char)__x, __n);
582#if __cpp_lib_concepts
583 else if constexpr (contiguous_iterator<_ForwardIterator>)
586 if (__n > 0) [[__likely__]]
588 __builtin_memset(__dest, (
unsigned char)__x, __n);
595 return std::__do_uninit_fill_n(__first, __n, __x);
597 const bool __can_memset = __is_byte<_ValueType>::__value
598 && __is_integer<_Tp>::__value
599 && __is_integer<_Size>::__value;
601 return __uninitialized_fill_n<__can_memset>::
602 __uninit_fill_n(__first, __n, __x);
605#pragma GCC diagnostic pop
615 template<
typename _InputIterator,
typename _Sentinel,
616 typename _ForwardIterator,
typename _Allocator>
619 __uninitialized_copy_a(_InputIterator __first, _Sentinel __last,
620 _ForwardIterator __result, _Allocator& __alloc)
622 _UninitDestroyGuard<_ForwardIterator, _Allocator>
623 __guard(__result, __alloc);
626 for (; __first != __last; ++__first, (void)++__result)
633 template<
typename _InputIterator,
typename _Sentinel,
634 typename _ForwardIterator,
typename _Tp>
636 inline _ForwardIterator
637 __uninitialized_copy_a(_InputIterator __first, _Sentinel __last,
640#ifdef __cpp_lib_is_constant_evaluated
641 if (std::is_constant_evaluated())
642 return std::__do_uninit_copy(
std::move(__first), __last, __result);
645#ifdef __glibcxx_ranges
646 if constexpr (!is_same_v<_InputIterator, _Sentinel>)
650 if constexpr (sized_sentinel_for<_Sentinel, _InputIterator>
651 && random_access_iterator<_InputIterator>)
653 __first + (__last - __first),
656 return std::__do_uninit_copy(
std::move(__first), __last, __result);
666#if __cplusplus >= 201103L
667 template<
typename _ITp,
typename _IRef,
typename _IPtr,
typename _OTp,
669 _GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*>
670 __uninitialized_copy_a(
671 _GLIBCXX_STD_C::_Deque_iterator<_ITp, _IRef, _IPtr> __first,
672 _GLIBCXX_STD_C::_Deque_iterator<_ITp, _IRef, _IPtr> __last,
673 _GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*> __result,
676 template<
typename _Iter,
typename _OTp,
typename _Tp>
677 __enable_if_t<__is_random_access_iter<_Iter>::value,
678 _GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*>>
679 __uninitialized_copy_a(_Iter __first, _Iter __last,
680 _GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*> __result,
683 template<
typename _ITp,
typename _IRef,
typename _IPtr,
typename _OTp,
685 _GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*>
686 __uninitialized_move_a(
687 _GLIBCXX_STD_C::_Deque_iterator<_ITp, _IRef, _IPtr> __first,
688 _GLIBCXX_STD_C::_Deque_iterator<_ITp, _IRef, _IPtr> __last,
689 _GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*> __result,
693 template<
typename _InputIterator,
typename _ForwardIterator,
696 inline _ForwardIterator
697 __uninitialized_move_a(_InputIterator __first, _InputIterator __last,
698 _ForwardIterator __result, _Allocator& __alloc)
700 return std::__uninitialized_copy_a(_GLIBCXX_MAKE_MOVE_ITERATOR(__first),
701 _GLIBCXX_MAKE_MOVE_ITERATOR(__last),
705 template<
typename _InputIterator,
typename _ForwardIterator,
708 inline _ForwardIterator
709 __uninitialized_move_if_noexcept_a(_InputIterator __first,
710 _InputIterator __last,
711 _ForwardIterator __result,
714 return std::__uninitialized_copy_a
715 (_GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(__first),
716 _GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(__last), __result, __alloc);
719 template<
typename _ForwardIterator,
typename _Tp,
typename _Allocator>
722 __uninitialized_fill_a(_ForwardIterator __first, _ForwardIterator __last,
723 const _Tp& __x, _Allocator& __alloc)
725 _UninitDestroyGuard<_ForwardIterator, _Allocator>
726 __guard(__first, __alloc);
728 typedef __gnu_cxx::__alloc_traits<_Allocator> __traits;
729 for (; __first != __last; ++__first)
736 template<
typename _ForwardIterator,
typename _Tp,
typename _Tp2>
739 __uninitialized_fill_a(_ForwardIterator __first, _ForwardIterator __last,
742#ifdef __cpp_lib_is_constant_evaluated
743 if (std::is_constant_evaluated())
744 return std::__do_uninit_fill(__first, __last, __x);
750 template<
typename _ForwardIterator,
typename _Size,
typename _Tp,
754 __uninitialized_fill_n_a(_ForwardIterator __first, _Size __n,
755 const _Tp& __x, _Allocator& __alloc)
757 _UninitDestroyGuard<_ForwardIterator, _Allocator>
758 __guard(__first, __alloc);
759 typedef __gnu_cxx::__alloc_traits<_Allocator> __traits;
760 for (; __n > 0; --__n, (void) ++__first)
767 template<
typename _ForwardIterator,
typename _Size,
typename _Tp,
770 inline _ForwardIterator
771 __uninitialized_fill_n_a(_ForwardIterator __first, _Size __n,
774#ifdef __cpp_lib_is_constant_evaluated
775 if (std::is_constant_evaluated())
776 return std::__do_uninit_fill_n(__first, __n, __x);
791 template<
typename _InputIterator1,
typename _InputIterator2,
792 typename _ForwardIterator,
typename _Allocator>
793 inline _ForwardIterator
794 __uninitialized_copy_move(_InputIterator1 __first1,
795 _InputIterator1 __last1,
796 _InputIterator2 __first2,
797 _InputIterator2 __last2,
798 _ForwardIterator __result,
801 _ForwardIterator __mid = std::__uninitialized_copy_a(__first1, __last1,
803 _UninitDestroyGuard<_ForwardIterator, _Allocator> __guard(__result,
806 __result = std::__uninitialized_move_a(__first2, __last2, __mid, __alloc);
815 template<
typename _InputIterator1,
typename _InputIterator2,
816 typename _ForwardIterator,
typename _Allocator>
817 inline _ForwardIterator
818 __uninitialized_move_copy(_InputIterator1 __first1,
819 _InputIterator1 __last1,
820 _InputIterator2 __first2,
821 _InputIterator2 __last2,
822 _ForwardIterator __result,
825 _ForwardIterator __mid = std::__uninitialized_move_a(__first1, __last1,
827 _UninitDestroyGuard<_ForwardIterator, _Allocator> __guard(__result,
830 __result = std::__uninitialized_copy_a(__first2, __last2, __mid, __alloc);
838 template<
typename _ForwardIterator,
typename _Tp,
typename _InputIterator,
840 inline _ForwardIterator
841 __uninitialized_fill_move(_ForwardIterator __result, _ForwardIterator __mid,
842 const _Tp& __x, _InputIterator __first,
843 _InputIterator __last, _Allocator& __alloc)
845 std::__uninitialized_fill_a(__result, __mid, __x, __alloc);
846 _UninitDestroyGuard<_ForwardIterator, _Allocator> __guard(__result,
849 __result = std::__uninitialized_move_a(__first, __last, __mid, __alloc);
857 template<
typename _InputIterator,
typename _ForwardIterator,
typename _Tp,
860 __uninitialized_move_fill(_InputIterator __first1, _InputIterator __last1,
861 _ForwardIterator __first2,
862 _ForwardIterator __last2,
const _Tp& __x,
865 _ForwardIterator __mid2 = std::__uninitialized_move_a(__first1, __last1,
868 _UninitDestroyGuard<_ForwardIterator, _Allocator> __guard(__first2,
871 std::__uninitialized_fill_a(__mid2, __last2, __x, __alloc);
877#if __cplusplus >= 201103L
883 template<
bool _TrivialValueType>
884 struct __uninitialized_default_1
886 template<
typename _ForwardIterator>
889 __uninit_default(_ForwardIterator __first, _ForwardIterator __last)
891 _UninitDestroyGuard<_ForwardIterator> __guard(__first);
892 for (; __first != __last; ++__first)
899 struct __uninitialized_default_1<true>
901 template<
typename _ForwardIterator>
904 __uninit_default(_ForwardIterator __first, _ForwardIterator __last)
906 if (__first == __last)
909 typename iterator_traits<_ForwardIterator>::value_type* __val
912 if (++__first != __last)
913 std::fill(__first, __last, *__val);
917 template<
bool _TrivialValueType>
918 struct __uninitialized_default_n_1
920 template<
typename _ForwardIterator,
typename _Size>
922 static _ForwardIterator
923 __uninit_default_n(_ForwardIterator __first, _Size __n)
925 _UninitDestroyGuard<_ForwardIterator> __guard(__first);
926 for (; __n > 0; --__n, (void) ++__first)
934 struct __uninitialized_default_n_1<true>
936 template<
typename _ForwardIterator,
typename _Size>
938 static _ForwardIterator
939 __uninit_default_n(_ForwardIterator __first, _Size __n)
943 typename iterator_traits<_ForwardIterator>::value_type* __val
947 __first = std::fill_n(__first, __n - 1, *__val);
955 template<
typename _ForwardIterator>
958 __uninitialized_default(_ForwardIterator __first,
959 _ForwardIterator __last)
961#ifdef __cpp_lib_is_constant_evaluated
962 if (std::is_constant_evaluated())
963 return __uninitialized_default_1<false>::
964 __uninit_default(__first, __last);
972 std::__uninitialized_default_1<__is_trivial(_ValueType)
974 __uninit_default(__first, __last);
979 template<
typename _ForwardIterator,
typename _Size>
981 inline _ForwardIterator
982 __uninitialized_default_n(_ForwardIterator __first, _Size __n)
984#ifdef __cpp_lib_is_constant_evaluated
985 if (std::is_constant_evaluated())
986 return __uninitialized_default_n_1<false>::
987 __uninit_default_n(__first, __n);
993 constexpr bool __can_fill
996 return __uninitialized_default_n_1<__is_trivial(_ValueType)
998 __uninit_default_n(__first, __n);
1005 template<
typename _ForwardIterator,
typename _Allocator>
1007 __uninitialized_default_a(_ForwardIterator __first,
1008 _ForwardIterator __last,
1009 _Allocator& __alloc)
1011 _UninitDestroyGuard<_ForwardIterator, _Allocator> __guard(__first,
1013 typedef __gnu_cxx::__alloc_traits<_Allocator> __traits;
1014 for (; __first != __last; ++__first)
1020 template<
typename _ForwardIterator,
typename _Tp>
1022 __uninitialized_default_a(_ForwardIterator __first,
1023 _ForwardIterator __last,
1025 { std::__uninitialized_default(__first, __last); }
1031 template<
typename _ForwardIterator,
typename _Size,
typename _Allocator>
1032 _GLIBCXX20_CONSTEXPR _ForwardIterator
1033 __uninitialized_default_n_a(_ForwardIterator __first, _Size __n,
1034 _Allocator& __alloc)
1036 _UninitDestroyGuard<_ForwardIterator, _Allocator> __guard(__first,
1038 typedef __gnu_cxx::__alloc_traits<_Allocator> __traits;
1039 for (; __n > 0; --__n, (void) ++__first)
1048 template<
typename _ForwardIterator,
typename _Size,
typename _Tp>
1049 _GLIBCXX20_CONSTEXPR
1050 inline _ForwardIterator
1051 __uninitialized_default_n_a(_ForwardIterator __first, _Size __n,
1053 {
return std::__uninitialized_default_n(__first, __n); }
1056 template<
bool _TrivialValueType>
1057 struct __uninitialized_default_novalue_1
1059 template<
typename _ForwardIterator>
1060 _GLIBCXX26_CONSTEXPR
1062 __uninit_default_novalue(_ForwardIterator __first,
1063 _ForwardIterator __last)
1065 _UninitDestroyGuard<_ForwardIterator> __guard(__first);
1066 for (; __first != __last; ++__first)
1073 struct __uninitialized_default_novalue_1<true>
1075 template<
typename _ForwardIterator>
1076 _GLIBCXX26_CONSTEXPR
1078 __uninit_default_novalue(_ForwardIterator, _ForwardIterator)
1083 template<
bool _TrivialValueType>
1084 struct __uninitialized_default_novalue_n_1
1086 template<
typename _ForwardIterator,
typename _Size>
1087 _GLIBCXX26_CONSTEXPR
1088 static _ForwardIterator
1089 __uninit_default_novalue_n(_ForwardIterator __first, _Size __n)
1091 _UninitDestroyGuard<_ForwardIterator> __guard(__first);
1092 for (; __n > 0; --__n, (void) ++__first)
1100 struct __uninitialized_default_novalue_n_1<true>
1102 template<
typename _ForwardIterator,
typename _Size>
1103 _GLIBCXX26_CONSTEXPR
1104 static _ForwardIterator
1105 __uninit_default_novalue_n(_ForwardIterator __first, _Size __n)
1106 {
return std::next(__first, __n); }
1111 template<
typename _ForwardIterator>
1112 _GLIBCXX26_CONSTEXPR
1114 __uninitialized_default_novalue(_ForwardIterator __first,
1115 _ForwardIterator __last)
1120 std::__uninitialized_default_novalue_1<
1122 __uninit_default_novalue(__first, __last);
1127 template<
typename _ForwardIterator,
typename _Size>
1128 _GLIBCXX26_CONSTEXPR
1129 inline _ForwardIterator
1130 __uninitialized_default_novalue_n(_ForwardIterator __first, _Size __n)
1135 return __uninitialized_default_novalue_n_1<
1137 __uninit_default_novalue_n(__first, __n);
1140 template<
typename _InputIterator,
typename _Size,
1141 typename _ForwardIterator>
1142 _GLIBCXX26_CONSTEXPR
1144 __uninitialized_copy_n(_InputIterator __first, _Size __n,
1147 _UninitDestroyGuard<_ForwardIterator> __guard(__result);
1148 for (; __n > 0; --__n, (void) ++__first, ++__result)
1154 template<
typename _RandomAccessIterator,
typename _Size,
1155 typename _ForwardIterator>
1156 _GLIBCXX26_CONSTEXPR
1157 inline _ForwardIterator
1158 __uninitialized_copy_n(_RandomAccessIterator __first, _Size __n,
1159 _ForwardIterator __result,
1163 template<
typename _InputIterator,
typename _Size,
1164 typename _ForwardIterator>
1165 _GLIBCXX26_CONSTEXPR
1167 __uninitialized_copy_n_pair(_InputIterator __first, _Size __n,
1170 _UninitDestroyGuard<_ForwardIterator> __guard(__result);
1171 for (; __n > 0; --__n, (void) ++__first, ++__result)
1174 return {__first, __result};
1177 template<
typename _RandomAccessIterator,
typename _Size,
1178 typename _ForwardIterator>
1179 _GLIBCXX26_CONSTEXPR
1181 __uninitialized_copy_n_pair(_RandomAccessIterator __first, _Size __n,
1182 _ForwardIterator __result,
1186 auto __first_res = std::next(__first, __n);
1187 return {__first_res, __second_res};
1202 template<
typename _InputIterator,
typename _Size,
typename _ForwardIterator>
1203 _GLIBCXX26_CONSTEXPR
1204 inline _ForwardIterator
1206 _ForwardIterator __result)
1207 {
return std::__uninitialized_copy_n(__first, __n, __result,
1208 std::__iter_concept_or_category(__first)); }
1211 template<
typename _InputIterator,
typename _Size,
typename _ForwardIterator>
1212 _GLIBCXX26_CONSTEXPR
1214 __uninitialized_copy_n_pair(_InputIterator __first, _Size __n,
1215 _ForwardIterator __result)
1218 std::__uninitialized_copy_n_pair(__first, __n, __result,
1219 std::__iter_concept_or_category(__first));
1224#ifdef __glibcxx_raw_memory_algorithms
1231 template <
typename _ForwardIterator>
1232 _GLIBCXX26_CONSTEXPR
1235 _ForwardIterator __last)
1237 std::__uninitialized_default_novalue(__first, __last);
1247 template <
typename _ForwardIterator,
typename _Size>
1248 _GLIBCXX26_CONSTEXPR
1249 inline _ForwardIterator
1252 return std::__uninitialized_default_novalue_n(__first, __count);
1261 template <
typename _ForwardIterator>
1262 _GLIBCXX26_CONSTEXPR
1265 _ForwardIterator __last)
1267 return std::__uninitialized_default(__first, __last);
1277 template <
typename _ForwardIterator,
typename _Size>
1278 _GLIBCXX26_CONSTEXPR
1279 inline _ForwardIterator
1282 return std::__uninitialized_default_n(__first, __count);
1293 template <
typename _InputIterator,
typename _ForwardIterator>
1294 _GLIBCXX26_CONSTEXPR
1295 inline _ForwardIterator
1297 _ForwardIterator __result)
1300 std::make_move_iterator(__last),
1312 template <
typename _InputIterator,
typename _Size,
typename _ForwardIterator>
1313 _GLIBCXX26_CONSTEXPR
1316 _ForwardIterator __result)
1319 = std::__uninitialized_copy_n_pair(std::make_move_iterator(__first),
1321 return {__res.first.base(), __res.second};
1325#if __cplusplus >= 201103L
1328 template<
typename _Tp,
typename _Up,
typename _Allocator>
1329 _GLIBCXX20_CONSTEXPR
1331 __relocate_object_a(_Tp* __restrict __dest, _Up* __restrict __orig,
1332 _Allocator& __alloc)
1339 __traits::construct(__alloc, __dest,
std::move(*__orig));
1345 template<
typename _Tp,
typename =
void>
1346 struct __is_bitwise_relocatable
1347 : __bool_constant<__is_trivial(_Tp)>
1350 template <
typename _InputIterator,
typename _ForwardIterator,
1351 typename _Allocator>
1352 _GLIBCXX20_CONSTEXPR
1353 inline _ForwardIterator
1354 __relocate_a_1(_InputIterator __first, _InputIterator __last,
1355 _ForwardIterator __result, _Allocator& __alloc)
1356 noexcept(
noexcept(std::__relocate_object_a(
std::addressof(*__result),
1364 static_assert(std::is_same<_ValueType, _ValueType2>::value,
1365 "relocation is only possible for values of the same type");
1366 _ForwardIterator __cur = __result;
1367 for (; __first != __last; ++__first, (void)++__cur)
1374 template <
typename _Tp,
typename _Up>
1375 _GLIBCXX20_CONSTEXPR
1376 inline __enable_if_t<std::__is_bitwise_relocatable<_Tp>::value, _Tp*>
1377 __relocate_a_1(_Tp* __first, _Tp* __last,
1381 ptrdiff_t __count = __last - __first;
1384#ifdef __cpp_lib_is_constant_evaluated
1385 if (std::is_constant_evaluated())
1389 __gnu_cxx::__normal_iterator<_Tp*, void> __out(__result);
1390 __out = std::__relocate_a_1(__first, __last, __out, __alloc);
1391 return __out.base();
1394 __builtin_memcpy(__result, __first, __count *
sizeof(_Tp));
1396 return __result + __count;
1400 template <
typename _InputIterator,
typename _ForwardIterator,
1401 typename _Allocator>
1402 _GLIBCXX20_CONSTEXPR
1403 inline _ForwardIterator
1404 __relocate_a(_InputIterator __first, _InputIterator __last,
1405 _ForwardIterator __result, _Allocator& __alloc)
1406 noexcept(
noexcept(__relocate_a_1(std::__niter_base(__first),
1407 std::__niter_base(__last),
1408 std::__niter_base(__result), __alloc)))
1410 return std::__relocate_a_1(std::__niter_base(__first),
1411 std::__niter_base(__last),
1412 std::__niter_base(__result), __alloc);
1420_GLIBCXX_END_NAMESPACE_VERSION
constexpr _ForwardIterator uninitialized_value_construct_n(_ForwardIterator __first, _Size __count)
Value-initializes objects in the range [first,first+count).
constexpr _ForwardIterator uninitialized_copy_n(_InputIterator __first, _Size __n, _ForwardIterator __result)
Copies the range [first,first+n) into result.
constexpr void uninitialized_fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp &__x)
Copies the value x into the range [first,last).
constexpr void uninitialized_default_construct(_ForwardIterator __first, _ForwardIterator __last)
Default-initializes objects in the range [first,last).
constexpr void uninitialized_value_construct(_ForwardIterator __first, _ForwardIterator __last)
Value-initializes objects in the range [first,last).
constexpr _ForwardIterator uninitialized_move(_InputIterator __first, _InputIterator __last, _ForwardIterator __result)
Move-construct from the range [first,last) into result.
constexpr pair< _InputIterator, _ForwardIterator > uninitialized_move_n(_InputIterator __first, _Size __count, _ForwardIterator __result)
Move-construct from the range [first,first+count) into result.
constexpr _ForwardIterator uninitialized_fill_n(_ForwardIterator __first, _Size __n, const _Tp &__x)
Copies the value x into the range [first,first+n).
constexpr _ForwardIterator uninitialized_default_construct_n(_ForwardIterator __first, _Size __count)
Default-initializes objects in the range [first,first+count).
constexpr _ForwardIterator uninitialized_copy(_InputIterator __first, _InputIterator __last, _ForwardIterator __result)
Copies the range [first,last) 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.
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].
Traits class for iterators.
Struct holding two objects (or references) of arbitrary type.
Random-access iterators support a superset of bidirectional iterator operations.
Uniform interface to C++98 and C++11 allocators.