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,
typename _Tp>
427#if __cplusplus >= 201103L
428#pragma GCC diagnostic push
429#pragma GCC diagnostic ignored "-Wc++17-extensions"
430#pragma GCC diagnostic ignored "-Wclass-memaccess"
431#if __glibcxx_raw_memory_algorithms >= 202411L
433 return std::__do_uninit_fill(__first, __last, __x);
436 if constexpr (__is_byte<_ValueType>::__value)
440 using _BasePtr =
decltype(std::__niter_base(__first));
443 void* __dest = std::__niter_base(__first);
444 ptrdiff_t __n = __last - __first;
445 if (__n > 0) [[__likely__]]
446 __builtin_memset(__dest, (
unsigned char)__x, __n);
449#if __cpp_lib_concepts
450 else if constexpr (contiguous_iterator<_ForwardIterator>)
453 auto __n = __last - __first;
454 if (__n > 0) [[__likely__]]
455 __builtin_memset(__dest, (
unsigned char)__x, __n);
460 std::__do_uninit_fill(__first, __last, __x);
461#pragma GCC diagnostic pop
463 const bool __can_memset = __is_byte<_ValueType>::__value
464 && __is_integer<_Tp>::__value;
466 __uninitialized_fill<__can_memset>::__uninit_fill(__first, __last, __x);
473 template<
typename _ForwardIterator,
typename _Size,
typename _Tp>
476 __do_uninit_fill_n(_ForwardIterator __first, _Size __n,
const _Tp& __x)
478 _UninitDestroyGuard<_ForwardIterator> __guard(__first);
479#if __cplusplus >= 201103L
480#pragma GCC diagnostic push
481#pragma GCC diagnostic ignored "-Wc++17-extensions"
482 if constexpr (is_integral<_Size>::value)
484 __glibcxx_assert(__n >= 0);
485 else if constexpr (is_floating_point<_Size>::value)
487 __glibcxx_assert(__n >= 0 &&
static_cast<size_t>(__n) == __n);
488#pragma GCC diagnostic pop
490 for (; __n--; ++__first)
496#if __cplusplus < 201103L
498 template<
bool _CanMemset>
499 struct __uninitialized_fill_n
501 template<
typename _ForwardIterator,
typename _Size,
typename _Tp>
502 static _ForwardIterator
503 __uninit_fill_n(_ForwardIterator __first, _Size __n,
505 {
return std::__do_uninit_fill_n(__first, __n, __x); }
509 struct __uninitialized_fill_n<true>
512 template<
typename _ForwardIterator,
typename _Size,
typename _Tp>
513 static _ForwardIterator
514 __uninit_fill_n(_ForwardIterator __first, _Size __n,
517 if (__unwrappable_niter<_ForwardIterator>::__value)
519 _ForwardIterator __last = __first;
521 __uninitialized_fill<true>::__uninit_fill(__first, __last, __x);
525 return std::__do_uninit_fill_n(__first, __n, __x);
531#pragma GCC diagnostic push
532#pragma GCC diagnostic ignored "-Wc++17-extensions"
533#pragma GCC diagnostic ignored "-Wclass-memaccess"
545 template<
typename _ForwardIterator,
typename _Size,
typename _Tp>
547 inline _ForwardIterator
559#if __cplusplus >= 201103L
560#if __glibcxx_raw_memory_algorithms >= 202411L
562 return std::__do_uninit_fill_n(__first, __n, __x);
565 if constexpr (__is_byte<_ValueType>::__value)
569 using _BasePtr =
decltype(std::__niter_base(__first));
572 void* __dest = std::__niter_base(__first);
573 if (__n > 0) [[__likely__]]
575 __builtin_memset(__dest, (
unsigned char)__x, __n);
580#if __cpp_lib_concepts
581 else if constexpr (contiguous_iterator<_ForwardIterator>)
584 if (__n > 0) [[__likely__]]
586 __builtin_memset(__dest, (
unsigned char)__x, __n);
593 return std::__do_uninit_fill_n(__first, __n, __x);
595 const bool __can_memset = __is_byte<_ValueType>::__value
596 && __is_integer<_Tp>::__value
597 && __is_integer<_Size>::__value;
599 return __uninitialized_fill_n<__can_memset>::
600 __uninit_fill_n(__first, __n, __x);
603#pragma GCC diagnostic pop
613 template<
typename _InputIterator,
typename _Sentinel,
614 typename _ForwardIterator,
typename _Allocator>
617 __uninitialized_copy_a(_InputIterator __first, _Sentinel __last,
618 _ForwardIterator __result, _Allocator& __alloc)
620 _UninitDestroyGuard<_ForwardIterator, _Allocator>
621 __guard(__result, __alloc);
624 for (; __first != __last; ++__first, (void)++__result)
631 template<
typename _InputIterator,
typename _Sentinel,
632 typename _ForwardIterator,
typename _Tp>
634 inline _ForwardIterator
635 __uninitialized_copy_a(_InputIterator __first, _Sentinel __last,
638#ifdef __cpp_lib_is_constant_evaluated
639 if (std::is_constant_evaluated())
640 return std::__do_uninit_copy(
std::move(__first), __last, __result);
643#ifdef __glibcxx_ranges
644 if constexpr (!is_same_v<_InputIterator, _Sentinel>)
648 if constexpr (sized_sentinel_for<_Sentinel, _InputIterator>
649 && random_access_iterator<_InputIterator>)
651 __first + (__last - __first),
654 return std::__do_uninit_copy(
std::move(__first), __last, __result);
664#if __cplusplus >= 201103L
665 template<
typename _ITp,
typename _IRef,
typename _IPtr,
typename _OTp,
667 _GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*>
668 __uninitialized_copy_a(
669 _GLIBCXX_STD_C::_Deque_iterator<_ITp, _IRef, _IPtr> __first,
670 _GLIBCXX_STD_C::_Deque_iterator<_ITp, _IRef, _IPtr> __last,
671 _GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*> __result,
674 template<
typename _Iter,
typename _OTp,
typename _Tp>
675 __enable_if_t<__is_random_access_iter<_Iter>::value,
676 _GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*>>
677 __uninitialized_copy_a(_Iter __first, _Iter __last,
678 _GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*> __result,
681 template<
typename _ITp,
typename _IRef,
typename _IPtr,
typename _OTp,
683 _GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*>
684 __uninitialized_move_a(
685 _GLIBCXX_STD_C::_Deque_iterator<_ITp, _IRef, _IPtr> __first,
686 _GLIBCXX_STD_C::_Deque_iterator<_ITp, _IRef, _IPtr> __last,
687 _GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*> __result,
691 template<
typename _InputIterator,
typename _ForwardIterator,
694 inline _ForwardIterator
695 __uninitialized_move_a(_InputIterator __first, _InputIterator __last,
696 _ForwardIterator __result, _Allocator& __alloc)
698 return std::__uninitialized_copy_a(_GLIBCXX_MAKE_MOVE_ITERATOR(__first),
699 _GLIBCXX_MAKE_MOVE_ITERATOR(__last),
703 template<
typename _InputIterator,
typename _ForwardIterator,
706 inline _ForwardIterator
707 __uninitialized_move_if_noexcept_a(_InputIterator __first,
708 _InputIterator __last,
709 _ForwardIterator __result,
712 return std::__uninitialized_copy_a
713 (_GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(__first),
714 _GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(__last), __result, __alloc);
717 template<
typename _ForwardIterator,
typename _Tp,
typename _Allocator>
720 __uninitialized_fill_a(_ForwardIterator __first, _ForwardIterator __last,
721 const _Tp& __x, _Allocator& __alloc)
723 _UninitDestroyGuard<_ForwardIterator, _Allocator>
724 __guard(__first, __alloc);
726 typedef __gnu_cxx::__alloc_traits<_Allocator> __traits;
727 for (; __first != __last; ++__first)
734 template<
typename _ForwardIterator,
typename _Tp,
typename _Tp2>
737 __uninitialized_fill_a(_ForwardIterator __first, _ForwardIterator __last,
740#ifdef __cpp_lib_is_constant_evaluated
741 if (std::is_constant_evaluated())
742 return std::__do_uninit_fill(__first, __last, __x);
748 template<
typename _ForwardIterator,
typename _Size,
typename _Tp,
752 __uninitialized_fill_n_a(_ForwardIterator __first, _Size __n,
753 const _Tp& __x, _Allocator& __alloc)
755 _UninitDestroyGuard<_ForwardIterator, _Allocator>
756 __guard(__first, __alloc);
757 typedef __gnu_cxx::__alloc_traits<_Allocator> __traits;
758 for (; __n > 0; --__n, (void) ++__first)
765 template<
typename _ForwardIterator,
typename _Size,
typename _Tp,
768 inline _ForwardIterator
769 __uninitialized_fill_n_a(_ForwardIterator __first, _Size __n,
772#ifdef __cpp_lib_is_constant_evaluated
773 if (std::is_constant_evaluated())
774 return std::__do_uninit_fill_n(__first, __n, __x);
789 template<
typename _InputIterator1,
typename _InputIterator2,
790 typename _ForwardIterator,
typename _Allocator>
791 inline _ForwardIterator
792 __uninitialized_copy_move(_InputIterator1 __first1,
793 _InputIterator1 __last1,
794 _InputIterator2 __first2,
795 _InputIterator2 __last2,
796 _ForwardIterator __result,
799 _ForwardIterator __mid = std::__uninitialized_copy_a(__first1, __last1,
801 _UninitDestroyGuard<_ForwardIterator, _Allocator> __guard(__result,
804 __result = std::__uninitialized_move_a(__first2, __last2, __mid, __alloc);
813 template<
typename _InputIterator1,
typename _InputIterator2,
814 typename _ForwardIterator,
typename _Allocator>
815 inline _ForwardIterator
816 __uninitialized_move_copy(_InputIterator1 __first1,
817 _InputIterator1 __last1,
818 _InputIterator2 __first2,
819 _InputIterator2 __last2,
820 _ForwardIterator __result,
823 _ForwardIterator __mid = std::__uninitialized_move_a(__first1, __last1,
825 _UninitDestroyGuard<_ForwardIterator, _Allocator> __guard(__result,
828 __result = std::__uninitialized_copy_a(__first2, __last2, __mid, __alloc);
836 template<
typename _ForwardIterator,
typename _Tp,
typename _InputIterator,
838 inline _ForwardIterator
839 __uninitialized_fill_move(_ForwardIterator __result, _ForwardIterator __mid,
840 const _Tp& __x, _InputIterator __first,
841 _InputIterator __last, _Allocator& __alloc)
843 std::__uninitialized_fill_a(__result, __mid, __x, __alloc);
844 _UninitDestroyGuard<_ForwardIterator, _Allocator> __guard(__result,
847 __result = std::__uninitialized_move_a(__first, __last, __mid, __alloc);
855 template<
typename _InputIterator,
typename _ForwardIterator,
typename _Tp,
858 __uninitialized_move_fill(_InputIterator __first1, _InputIterator __last1,
859 _ForwardIterator __first2,
860 _ForwardIterator __last2,
const _Tp& __x,
863 _ForwardIterator __mid2 = std::__uninitialized_move_a(__first1, __last1,
866 _UninitDestroyGuard<_ForwardIterator, _Allocator> __guard(__first2,
869 std::__uninitialized_fill_a(__mid2, __last2, __x, __alloc);
875#if __cplusplus >= 201103L
881 template<
bool _TrivialValueType>
882 struct __uninitialized_default_1
884 template<
typename _ForwardIterator>
887 __uninit_default(_ForwardIterator __first, _ForwardIterator __last)
889 _UninitDestroyGuard<_ForwardIterator> __guard(__first);
890 for (; __first != __last; ++__first)
897 struct __uninitialized_default_1<true>
899 template<
typename _ForwardIterator>
902 __uninit_default(_ForwardIterator __first, _ForwardIterator __last)
904 if (__first == __last)
907 typename iterator_traits<_ForwardIterator>::value_type* __val
910 if (++__first != __last)
911 std::fill(__first, __last, *__val);
915 template<
bool _TrivialValueType>
916 struct __uninitialized_default_n_1
918 template<
typename _ForwardIterator,
typename _Size>
920 static _ForwardIterator
921 __uninit_default_n(_ForwardIterator __first, _Size __n)
923 _UninitDestroyGuard<_ForwardIterator> __guard(__first);
924 for (; __n > 0; --__n, (void) ++__first)
932 struct __uninitialized_default_n_1<true>
934 template<
typename _ForwardIterator,
typename _Size>
936 static _ForwardIterator
937 __uninit_default_n(_ForwardIterator __first, _Size __n)
941 typename iterator_traits<_ForwardIterator>::value_type* __val
945 __first = std::fill_n(__first, __n - 1, *__val);
953 template<
typename _ForwardIterator>
956 __uninitialized_default(_ForwardIterator __first,
957 _ForwardIterator __last)
959#ifdef __cpp_lib_is_constant_evaluated
960 if (std::is_constant_evaluated())
961 return __uninitialized_default_1<false>::
962 __uninit_default(__first, __last);
970 std::__uninitialized_default_1<__is_trivial(_ValueType)
972 __uninit_default(__first, __last);
977 template<
typename _ForwardIterator,
typename _Size>
979 inline _ForwardIterator
980 __uninitialized_default_n(_ForwardIterator __first, _Size __n)
982#ifdef __cpp_lib_is_constant_evaluated
983 if (std::is_constant_evaluated())
984 return __uninitialized_default_n_1<false>::
985 __uninit_default_n(__first, __n);
991 constexpr bool __can_fill
994 return __uninitialized_default_n_1<__is_trivial(_ValueType)
996 __uninit_default_n(__first, __n);
1003 template<
typename _ForwardIterator,
typename _Allocator>
1005 __uninitialized_default_a(_ForwardIterator __first,
1006 _ForwardIterator __last,
1007 _Allocator& __alloc)
1009 _UninitDestroyGuard<_ForwardIterator, _Allocator> __guard(__first,
1011 typedef __gnu_cxx::__alloc_traits<_Allocator> __traits;
1012 for (; __first != __last; ++__first)
1018 template<
typename _ForwardIterator,
typename _Tp>
1020 __uninitialized_default_a(_ForwardIterator __first,
1021 _ForwardIterator __last,
1023 { std::__uninitialized_default(__first, __last); }
1029 template<
typename _ForwardIterator,
typename _Size,
typename _Allocator>
1030 _GLIBCXX20_CONSTEXPR _ForwardIterator
1031 __uninitialized_default_n_a(_ForwardIterator __first, _Size __n,
1032 _Allocator& __alloc)
1034 _UninitDestroyGuard<_ForwardIterator, _Allocator> __guard(__first,
1036 typedef __gnu_cxx::__alloc_traits<_Allocator> __traits;
1037 for (; __n > 0; --__n, (void) ++__first)
1046 template<
typename _ForwardIterator,
typename _Size,
typename _Tp>
1047 _GLIBCXX20_CONSTEXPR
1048 inline _ForwardIterator
1049 __uninitialized_default_n_a(_ForwardIterator __first, _Size __n,
1051 {
return std::__uninitialized_default_n(__first, __n); }
1054 template<
bool _TrivialValueType>
1055 struct __uninitialized_default_novalue_1
1057 template<
typename _ForwardIterator>
1058 _GLIBCXX26_CONSTEXPR
1060 __uninit_default_novalue(_ForwardIterator __first,
1061 _ForwardIterator __last)
1063 _UninitDestroyGuard<_ForwardIterator> __guard(__first);
1064 for (; __first != __last; ++__first)
1071 struct __uninitialized_default_novalue_1<true>
1073 template<
typename _ForwardIterator>
1074 _GLIBCXX26_CONSTEXPR
1076 __uninit_default_novalue(_ForwardIterator, _ForwardIterator)
1081 template<
bool _TrivialValueType>
1082 struct __uninitialized_default_novalue_n_1
1084 template<
typename _ForwardIterator,
typename _Size>
1085 _GLIBCXX26_CONSTEXPR
1086 static _ForwardIterator
1087 __uninit_default_novalue_n(_ForwardIterator __first, _Size __n)
1089 _UninitDestroyGuard<_ForwardIterator> __guard(__first);
1090 for (; __n > 0; --__n, (void) ++__first)
1098 struct __uninitialized_default_novalue_n_1<true>
1100 template<
typename _ForwardIterator,
typename _Size>
1101 _GLIBCXX26_CONSTEXPR
1102 static _ForwardIterator
1103 __uninit_default_novalue_n(_ForwardIterator __first, _Size __n)
1104 {
return std::next(__first, __n); }
1109 template<
typename _ForwardIterator>
1110 _GLIBCXX26_CONSTEXPR
1112 __uninitialized_default_novalue(_ForwardIterator __first,
1113 _ForwardIterator __last)
1118 std::__uninitialized_default_novalue_1<
1120 __uninit_default_novalue(__first, __last);
1125 template<
typename _ForwardIterator,
typename _Size>
1126 _GLIBCXX26_CONSTEXPR
1127 inline _ForwardIterator
1128 __uninitialized_default_novalue_n(_ForwardIterator __first, _Size __n)
1133 return __uninitialized_default_novalue_n_1<
1135 __uninit_default_novalue_n(__first, __n);
1138 template<
typename _InputIterator,
typename _Size,
1139 typename _ForwardIterator>
1140 _GLIBCXX26_CONSTEXPR
1142 __uninitialized_copy_n(_InputIterator __first, _Size __n,
1145 _UninitDestroyGuard<_ForwardIterator> __guard(__result);
1146 for (; __n > 0; --__n, (void) ++__first, ++__result)
1152 template<
typename _RandomAccessIterator,
typename _Size,
1153 typename _ForwardIterator>
1154 _GLIBCXX26_CONSTEXPR
1155 inline _ForwardIterator
1156 __uninitialized_copy_n(_RandomAccessIterator __first, _Size __n,
1157 _ForwardIterator __result,
1161 template<
typename _InputIterator,
typename _Size,
1162 typename _ForwardIterator>
1163 _GLIBCXX26_CONSTEXPR
1165 __uninitialized_copy_n_pair(_InputIterator __first, _Size __n,
1168 _UninitDestroyGuard<_ForwardIterator> __guard(__result);
1169 for (; __n > 0; --__n, (void) ++__first, ++__result)
1172 return {__first, __result};
1175 template<
typename _RandomAccessIterator,
typename _Size,
1176 typename _ForwardIterator>
1177 _GLIBCXX26_CONSTEXPR
1179 __uninitialized_copy_n_pair(_RandomAccessIterator __first, _Size __n,
1180 _ForwardIterator __result,
1184 auto __first_res = std::next(__first, __n);
1185 return {__first_res, __second_res};
1200 template<
typename _InputIterator,
typename _Size,
typename _ForwardIterator>
1201 _GLIBCXX26_CONSTEXPR
1202 inline _ForwardIterator
1204 _ForwardIterator __result)
1205 {
return std::__uninitialized_copy_n(__first, __n, __result,
1206 std::__iter_concept_or_category(__first)); }
1209 template<
typename _InputIterator,
typename _Size,
typename _ForwardIterator>
1210 _GLIBCXX26_CONSTEXPR
1212 __uninitialized_copy_n_pair(_InputIterator __first, _Size __n,
1213 _ForwardIterator __result)
1216 std::__uninitialized_copy_n_pair(__first, __n, __result,
1217 std::__iter_concept_or_category(__first));
1222#ifdef __glibcxx_raw_memory_algorithms
1229 template <
typename _ForwardIterator>
1230 _GLIBCXX26_CONSTEXPR
1233 _ForwardIterator __last)
1235 std::__uninitialized_default_novalue(__first, __last);
1245 template <
typename _ForwardIterator,
typename _Size>
1246 _GLIBCXX26_CONSTEXPR
1247 inline _ForwardIterator
1250 return std::__uninitialized_default_novalue_n(__first, __count);
1259 template <
typename _ForwardIterator>
1260 _GLIBCXX26_CONSTEXPR
1263 _ForwardIterator __last)
1265 return std::__uninitialized_default(__first, __last);
1275 template <
typename _ForwardIterator,
typename _Size>
1276 _GLIBCXX26_CONSTEXPR
1277 inline _ForwardIterator
1280 return std::__uninitialized_default_n(__first, __count);
1291 template <
typename _InputIterator,
typename _ForwardIterator>
1292 _GLIBCXX26_CONSTEXPR
1293 inline _ForwardIterator
1295 _ForwardIterator __result)
1298 std::make_move_iterator(__last),
1310 template <
typename _InputIterator,
typename _Size,
typename _ForwardIterator>
1311 _GLIBCXX26_CONSTEXPR
1314 _ForwardIterator __result)
1317 = std::__uninitialized_copy_n_pair(std::make_move_iterator(__first),
1319 return {__res.first.base(), __res.second};
1323#if __cplusplus >= 201103L
1326 template<
typename _Tp,
typename _Up,
typename _Allocator>
1327 _GLIBCXX20_CONSTEXPR
1329 __relocate_object_a(_Tp* __restrict __dest, _Up* __restrict __orig,
1330 _Allocator& __alloc)
1337 __traits::construct(__alloc, __dest,
std::move(*__orig));
1343 template<
typename _Tp,
typename =
void>
1344 struct __is_bitwise_relocatable
1345 : __bool_constant<__is_trivial(_Tp)>
1348 template <
typename _InputIterator,
typename _ForwardIterator,
1349 typename _Allocator>
1350 _GLIBCXX20_CONSTEXPR
1351 inline _ForwardIterator
1352 __relocate_a_1(_InputIterator __first, _InputIterator __last,
1353 _ForwardIterator __result, _Allocator& __alloc)
1354 noexcept(
noexcept(std::__relocate_object_a(
std::addressof(*__result),
1362 static_assert(std::is_same<_ValueType, _ValueType2>::value,
1363 "relocation is only possible for values of the same type");
1364 _ForwardIterator __cur = __result;
1365 for (; __first != __last; ++__first, (void)++__cur)
1372 template <
typename _Tp,
typename _Up>
1373 _GLIBCXX20_CONSTEXPR
1374 inline __enable_if_t<std::__is_bitwise_relocatable<_Tp>::value, _Tp*>
1375 __relocate_a_1(_Tp* __first, _Tp* __last,
1379 ptrdiff_t __count = __last - __first;
1382#ifdef __cpp_lib_is_constant_evaluated
1383 if (std::is_constant_evaluated())
1387 __gnu_cxx::__normal_iterator<_Tp*, void> __out(__result);
1388 __out = std::__relocate_a_1(__first, __last, __out, __alloc);
1389 return __out.base();
1392 __builtin_memcpy(__result, __first, __count *
sizeof(_Tp));
1394 return __result + __count;
1398 template <
typename _InputIterator,
typename _ForwardIterator,
1399 typename _Allocator>
1400 _GLIBCXX20_CONSTEXPR
1401 inline _ForwardIterator
1402 __relocate_a(_InputIterator __first, _InputIterator __last,
1403 _ForwardIterator __result, _Allocator& __alloc)
1404 noexcept(
noexcept(__relocate_a_1(std::__niter_base(__first),
1405 std::__niter_base(__last),
1406 std::__niter_base(__result), __alloc)))
1408 return std::__relocate_a_1(std::__niter_base(__first),
1409 std::__niter_base(__last),
1410 std::__niter_base(__result), __alloc);
1418_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.