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::__miter_base(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::__miter_base(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,
670 _GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*>
671 __uninitialized_copy_a(
672 _GLIBCXX_STD_C::_Deque_iterator<_ITp, _IRef, _IPtr> __first,
673 _GLIBCXX_STD_C::_Deque_iterator<_ITp, _IRef, _IPtr> __last,
674 _GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*> __result,
677 template<
typename _Iter,
typename _OTp,
typename _Tp>
679 __enable_if_t<__is_random_access_iter<_Iter>::value,
680 _GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*>>
681 __uninitialized_copy_a(_Iter __first, _Iter __last,
682 _GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*> __result,
685 template<
typename _ITp,
typename _IRef,
typename _IPtr,
typename _OTp,
688 _GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*>
689 __uninitialized_move_a(
690 _GLIBCXX_STD_C::_Deque_iterator<_ITp, _IRef, _IPtr> __first,
691 _GLIBCXX_STD_C::_Deque_iterator<_ITp, _IRef, _IPtr> __last,
692 _GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*> __result,
696 template<
typename _InputIterator,
typename _ForwardIterator,
699 inline _ForwardIterator
700 __uninitialized_move_a(_InputIterator __first, _InputIterator __last,
701 _ForwardIterator __result, _Allocator& __alloc)
703 return std::__uninitialized_copy_a(_GLIBCXX_MAKE_MOVE_ITERATOR(__first),
704 _GLIBCXX_MAKE_MOVE_ITERATOR(__last),
708 template<
typename _InputIterator,
typename _ForwardIterator,
711 inline _ForwardIterator
712 __uninitialized_move_if_noexcept_a(_InputIterator __first,
713 _InputIterator __last,
714 _ForwardIterator __result,
717 return std::__uninitialized_copy_a
718 (_GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(__first),
719 _GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(__last), __result, __alloc);
722 template<
typename _ForwardIterator,
typename _Tp,
typename _Allocator>
725 __uninitialized_fill_a(_ForwardIterator __first, _ForwardIterator __last,
726 const _Tp& __x, _Allocator& __alloc)
728 _UninitDestroyGuard<_ForwardIterator, _Allocator>
729 __guard(__first, __alloc);
731 typedef __gnu_cxx::__alloc_traits<_Allocator> __traits;
732 for (; __first != __last; ++__first)
739 template<
typename _ForwardIterator,
typename _Tp,
typename _Tp2>
742 __uninitialized_fill_a(_ForwardIterator __first, _ForwardIterator __last,
745#ifdef __cpp_lib_is_constant_evaluated
746 if (std::is_constant_evaluated())
747 return std::__do_uninit_fill(__first, __last, __x);
753 template<
typename _ForwardIterator,
typename _Size,
typename _Tp,
757 __uninitialized_fill_n_a(_ForwardIterator __first, _Size __n,
758 const _Tp& __x, _Allocator& __alloc)
760 _UninitDestroyGuard<_ForwardIterator, _Allocator>
761 __guard(__first, __alloc);
762 typedef __gnu_cxx::__alloc_traits<_Allocator> __traits;
763 for (; __n > 0; --__n, (void) ++__first)
770 template<
typename _ForwardIterator,
typename _Size,
typename _Tp,
773 inline _ForwardIterator
774 __uninitialized_fill_n_a(_ForwardIterator __first, _Size __n,
777#ifdef __cpp_lib_is_constant_evaluated
778 if (std::is_constant_evaluated())
779 return std::__do_uninit_fill_n(__first, __n, __x);
794 template<
typename _InputIterator1,
typename _InputIterator2,
795 typename _ForwardIterator,
typename _Allocator>
796 inline _ForwardIterator
797 __uninitialized_copy_move(_InputIterator1 __first1,
798 _InputIterator1 __last1,
799 _InputIterator2 __first2,
800 _InputIterator2 __last2,
801 _ForwardIterator __result,
804 _ForwardIterator __mid = std::__uninitialized_copy_a(__first1, __last1,
806 _UninitDestroyGuard<_ForwardIterator, _Allocator> __guard(__result,
809 __result = std::__uninitialized_move_a(__first2, __last2, __mid, __alloc);
818 template<
typename _InputIterator1,
typename _InputIterator2,
819 typename _ForwardIterator,
typename _Allocator>
820 inline _ForwardIterator
821 __uninitialized_move_copy(_InputIterator1 __first1,
822 _InputIterator1 __last1,
823 _InputIterator2 __first2,
824 _InputIterator2 __last2,
825 _ForwardIterator __result,
828 _ForwardIterator __mid = std::__uninitialized_move_a(__first1, __last1,
830 _UninitDestroyGuard<_ForwardIterator, _Allocator> __guard(__result,
833 __result = std::__uninitialized_copy_a(__first2, __last2, __mid, __alloc);
841 template<
typename _ForwardIterator,
typename _Tp,
typename _InputIterator,
843 inline _ForwardIterator
844 __uninitialized_fill_move(_ForwardIterator __result, _ForwardIterator __mid,
845 const _Tp& __x, _InputIterator __first,
846 _InputIterator __last, _Allocator& __alloc)
848 std::__uninitialized_fill_a(__result, __mid, __x, __alloc);
849 _UninitDestroyGuard<_ForwardIterator, _Allocator> __guard(__result,
852 __result = std::__uninitialized_move_a(__first, __last, __mid, __alloc);
860 template<
typename _InputIterator,
typename _ForwardIterator,
typename _Tp,
863 __uninitialized_move_fill(_InputIterator __first1, _InputIterator __last1,
864 _ForwardIterator __first2,
865 _ForwardIterator __last2,
const _Tp& __x,
868 _ForwardIterator __mid2 = std::__uninitialized_move_a(__first1, __last1,
871 _UninitDestroyGuard<_ForwardIterator, _Allocator> __guard(__first2,
874 std::__uninitialized_fill_a(__mid2, __last2, __x, __alloc);
880#if __cplusplus >= 201103L
886 template<
bool _TrivialValueType>
887 struct __uninitialized_default_1
889 template<
typename _ForwardIterator>
892 __uninit_default(_ForwardIterator __first, _ForwardIterator __last)
894 _UninitDestroyGuard<_ForwardIterator> __guard(__first);
895 for (; __first != __last; ++__first)
902 struct __uninitialized_default_1<true>
904 template<
typename _ForwardIterator>
907 __uninit_default(_ForwardIterator __first, _ForwardIterator __last)
909 if (__first == __last)
912 typename iterator_traits<_ForwardIterator>::value_type* __val
915 if (++__first != __last)
916 std::fill(__first, __last, *__val);
920 template<
bool _TrivialValueType>
921 struct __uninitialized_default_n_1
923 template<
typename _ForwardIterator,
typename _Size>
925 static _ForwardIterator
926 __uninit_default_n(_ForwardIterator __first, _Size __n)
928 _UninitDestroyGuard<_ForwardIterator> __guard(__first);
929 for (; __n > 0; --__n, (void) ++__first)
937 struct __uninitialized_default_n_1<true>
939 template<
typename _ForwardIterator,
typename _Size>
941 static _ForwardIterator
942 __uninit_default_n(_ForwardIterator __first, _Size __n)
946 typename iterator_traits<_ForwardIterator>::value_type* __val
950 __first = std::fill_n(__first, __n - 1, *__val);
958 template<
typename _ForwardIterator>
961 __uninitialized_default(_ForwardIterator __first,
962 _ForwardIterator __last)
964#ifdef __cpp_lib_is_constant_evaluated
965 if (std::is_constant_evaluated())
966 return __uninitialized_default_1<false>::
967 __uninit_default(__first, __last);
975 std::__uninitialized_default_1<__is_trivial(_ValueType)
977 __uninit_default(__first, __last);
982 template<
typename _ForwardIterator,
typename _Size>
984 inline _ForwardIterator
985 __uninitialized_default_n(_ForwardIterator __first, _Size __n)
987#ifdef __cpp_lib_is_constant_evaluated
988 if (std::is_constant_evaluated())
989 return __uninitialized_default_n_1<false>::
990 __uninit_default_n(__first, __n);
996 constexpr bool __can_fill
999 return __uninitialized_default_n_1<__is_trivial(_ValueType)
1001 __uninit_default_n(__first, __n);
1008 template<
typename _ForwardIterator,
typename _Allocator>
1009 _GLIBCXX20_CONSTEXPR
void
1010 __uninitialized_default_a(_ForwardIterator __first,
1011 _ForwardIterator __last,
1012 _Allocator& __alloc)
1014 _UninitDestroyGuard<_ForwardIterator, _Allocator> __guard(__first,
1016 typedef __gnu_cxx::__alloc_traits<_Allocator> __traits;
1017 for (; __first != __last; ++__first)
1023 template<
typename _ForwardIterator,
typename _Tp>
1024 inline _GLIBCXX20_CONSTEXPR
void
1025 __uninitialized_default_a(_ForwardIterator __first,
1026 _ForwardIterator __last,
1028 { std::__uninitialized_default(__first, __last); }
1034 template<
typename _ForwardIterator,
typename _Size,
typename _Allocator>
1035 _GLIBCXX20_CONSTEXPR _ForwardIterator
1036 __uninitialized_default_n_a(_ForwardIterator __first, _Size __n,
1037 _Allocator& __alloc)
1039 _UninitDestroyGuard<_ForwardIterator, _Allocator> __guard(__first,
1041 typedef __gnu_cxx::__alloc_traits<_Allocator> __traits;
1042 for (; __n > 0; --__n, (void) ++__first)
1051 template<
typename _ForwardIterator,
typename _Size,
typename _Tp>
1052 _GLIBCXX20_CONSTEXPR
1053 inline _ForwardIterator
1054 __uninitialized_default_n_a(_ForwardIterator __first, _Size __n,
1056 {
return std::__uninitialized_default_n(__first, __n); }
1059 template<
bool _TrivialValueType>
1060 struct __uninitialized_default_novalue_1
1062 template<
typename _ForwardIterator>
1063 _GLIBCXX26_CONSTEXPR
1065 __uninit_default_novalue(_ForwardIterator __first,
1066 _ForwardIterator __last)
1068 _UninitDestroyGuard<_ForwardIterator> __guard(__first);
1069 for (; __first != __last; ++__first)
1076 struct __uninitialized_default_novalue_1<true>
1078 template<
typename _ForwardIterator>
1079 _GLIBCXX26_CONSTEXPR
1081 __uninit_default_novalue(_ForwardIterator, _ForwardIterator)
1086 template<
bool _TrivialValueType>
1087 struct __uninitialized_default_novalue_n_1
1089 template<
typename _ForwardIterator,
typename _Size>
1090 _GLIBCXX26_CONSTEXPR
1091 static _ForwardIterator
1092 __uninit_default_novalue_n(_ForwardIterator __first, _Size __n)
1094 _UninitDestroyGuard<_ForwardIterator> __guard(__first);
1095 for (; __n > 0; --__n, (void) ++__first)
1103 struct __uninitialized_default_novalue_n_1<true>
1105 template<
typename _ForwardIterator,
typename _Size>
1106 _GLIBCXX26_CONSTEXPR
1107 static _ForwardIterator
1108 __uninit_default_novalue_n(_ForwardIterator __first, _Size __n)
1109 {
return std::next(__first, __n); }
1114 template<
typename _ForwardIterator>
1115 _GLIBCXX26_CONSTEXPR
1117 __uninitialized_default_novalue(_ForwardIterator __first,
1118 _ForwardIterator __last)
1123 std::__uninitialized_default_novalue_1<
1125 __uninit_default_novalue(__first, __last);
1130 template<
typename _ForwardIterator,
typename _Size>
1131 _GLIBCXX26_CONSTEXPR
1132 inline _ForwardIterator
1133 __uninitialized_default_novalue_n(_ForwardIterator __first, _Size __n)
1138 return __uninitialized_default_novalue_n_1<
1140 __uninit_default_novalue_n(__first, __n);
1143 template<
typename _InputIterator,
typename _Size,
1144 typename _ForwardIterator>
1145 _GLIBCXX26_CONSTEXPR
1147 __uninitialized_copy_n(_InputIterator __first, _Size __n,
1150 _UninitDestroyGuard<_ForwardIterator> __guard(__result);
1151 for (; __n > 0; --__n, (void) ++__first, ++__result)
1157 template<
typename _RandomAccessIterator,
typename _Size,
1158 typename _ForwardIterator>
1159 _GLIBCXX26_CONSTEXPR
1160 inline _ForwardIterator
1161 __uninitialized_copy_n(_RandomAccessIterator __first, _Size __n,
1162 _ForwardIterator __result,
1166 template<
typename _InputIterator,
typename _Size,
1167 typename _ForwardIterator>
1168 _GLIBCXX26_CONSTEXPR
1170 __uninitialized_copy_n_pair(_InputIterator __first, _Size __n,
1173 _UninitDestroyGuard<_ForwardIterator> __guard(__result);
1174 for (; __n > 0; --__n, (void) ++__first, ++__result)
1177 return {__first, __result};
1180 template<
typename _RandomAccessIterator,
typename _Size,
1181 typename _ForwardIterator>
1182 _GLIBCXX26_CONSTEXPR
1184 __uninitialized_copy_n_pair(_RandomAccessIterator __first, _Size __n,
1185 _ForwardIterator __result,
1189 auto __first_res = std::next(__first, __n);
1190 return {__first_res, __second_res};
1205 template<
typename _InputIterator,
typename _Size,
typename _ForwardIterator>
1206 _GLIBCXX26_CONSTEXPR
1207 inline _ForwardIterator
1209 _ForwardIterator __result)
1210 {
return std::__uninitialized_copy_n(__first, __n, __result,
1211 std::__iter_concept_or_category(__first)); }
1214 template<
typename _InputIterator,
typename _Size,
typename _ForwardIterator>
1215 _GLIBCXX26_CONSTEXPR
1217 __uninitialized_copy_n_pair(_InputIterator __first, _Size __n,
1218 _ForwardIterator __result)
1221 std::__uninitialized_copy_n_pair(__first, __n, __result,
1222 std::__iter_concept_or_category(__first));
1227#ifdef __glibcxx_raw_memory_algorithms
1234 template <
typename _ForwardIterator>
1235 _GLIBCXX26_CONSTEXPR
1238 _ForwardIterator __last)
1240 std::__uninitialized_default_novalue(__first, __last);
1250 template <
typename _ForwardIterator,
typename _Size>
1251 _GLIBCXX26_CONSTEXPR
1252 inline _ForwardIterator
1255 return std::__uninitialized_default_novalue_n(__first, __count);
1264 template <
typename _ForwardIterator>
1265 _GLIBCXX26_CONSTEXPR
1268 _ForwardIterator __last)
1270 return std::__uninitialized_default(__first, __last);
1280 template <
typename _ForwardIterator,
typename _Size>
1281 _GLIBCXX26_CONSTEXPR
1282 inline _ForwardIterator
1285 return std::__uninitialized_default_n(__first, __count);
1296 template <
typename _InputIterator,
typename _ForwardIterator>
1297 _GLIBCXX26_CONSTEXPR
1298 inline _ForwardIterator
1300 _ForwardIterator __result)
1303 std::make_move_iterator(__last),
1315 template <
typename _InputIterator,
typename _Size,
typename _ForwardIterator>
1316 _GLIBCXX26_CONSTEXPR
1319 _ForwardIterator __result)
1322 = std::__uninitialized_copy_n_pair(std::make_move_iterator(__first),
1324 return {__res.first.base(), __res.second};
1328#if __cplusplus >= 201103L
1331 template<
typename _Tp,
typename _Up,
typename _Allocator>
1332 _GLIBCXX20_CONSTEXPR
1334 __relocate_object_a(_Tp* __restrict __dest, _Up* __restrict __orig,
1335 _Allocator& __alloc)
1342 __traits::construct(__alloc, __dest,
std::move(*__orig));
1348 template<
typename _Tp,
typename =
void>
1349 struct __is_bitwise_relocatable
1350 : __bool_constant<__is_trivial(_Tp)>
1353 template <
typename _InputIterator,
typename _ForwardIterator,
1354 typename _Allocator>
1355 _GLIBCXX20_CONSTEXPR
1356 inline _ForwardIterator
1357 __relocate_a_1(_InputIterator __first, _InputIterator __last,
1358 _ForwardIterator __result, _Allocator& __alloc)
1359 noexcept(
noexcept(std::__relocate_object_a(
std::addressof(*__result),
1367 static_assert(std::is_same<_ValueType, _ValueType2>::value,
1368 "relocation is only possible for values of the same type");
1369 _ForwardIterator __cur = __result;
1370 for (; __first != __last; ++__first, (void)++__cur)
1377 template <
typename _Tp,
typename _Up>
1378 _GLIBCXX20_CONSTEXPR
1379 inline __enable_if_t<std::__is_bitwise_relocatable<_Tp>::value, _Tp*>
1380 __relocate_a_1(_Tp* __first, _Tp* __last,
1384 ptrdiff_t __count = __last - __first;
1387#ifdef __cpp_lib_is_constant_evaluated
1388 if (std::is_constant_evaluated())
1392 __gnu_cxx::__normal_iterator<_Tp*, void> __out(__result);
1393 __out = std::__relocate_a_1(__first, __last, __out, __alloc);
1394 return __out.base();
1397 __builtin_memcpy(__result, __first, __count *
sizeof(_Tp));
1399 return __result + __count;
1403 template <
typename _InputIterator,
typename _ForwardIterator,
1404 typename _Allocator>
1405 _GLIBCXX20_CONSTEXPR
1406 inline _ForwardIterator
1407 __relocate_a(_InputIterator __first, _InputIterator __last,
1408 _ForwardIterator __result, _Allocator& __alloc)
1409 noexcept(
noexcept(__relocate_a_1(std::__niter_base(__first),
1410 std::__niter_base(__last),
1411 std::__niter_base(__result), __alloc)))
1413 return std::__relocate_a_1(std::__niter_base(__first),
1414 std::__niter_base(__last),
1415 std::__niter_base(__result), __alloc);
1423_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.