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#if __cplusplus >= 201103L
666 template<
typename _ITp,
typename _IRef,
typename _IPtr,
typename _OTp,
668 _GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*>
669 __uninitialized_copy_a(
670 _GLIBCXX_STD_C::_Deque_iterator<_ITp, _IRef, _IPtr> __first,
671 _GLIBCXX_STD_C::_Deque_iterator<_ITp, _IRef, _IPtr> __last,
672 _GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*> __result,
675 template<
typename _Iter,
typename _OTp,
typename _Tp>
676 __enable_if_t<__is_random_access_iter<_Iter>::value,
677 _GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*>>
678 __uninitialized_copy_a(_Iter __first, _Iter __last,
679 _GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*> __result,
682 template<
typename _ITp,
typename _IRef,
typename _IPtr,
typename _OTp,
684 _GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*>
685 __uninitialized_move_a(
686 _GLIBCXX_STD_C::_Deque_iterator<_ITp, _IRef, _IPtr> __first,
687 _GLIBCXX_STD_C::_Deque_iterator<_ITp, _IRef, _IPtr> __last,
688 _GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*> __result,
692 template<
typename _InputIterator,
typename _ForwardIterator,
695 inline _ForwardIterator
696 __uninitialized_move_a(_InputIterator __first, _InputIterator __last,
697 _ForwardIterator __result, _Allocator& __alloc)
699 return std::__uninitialized_copy_a(_GLIBCXX_MAKE_MOVE_ITERATOR(__first),
700 _GLIBCXX_MAKE_MOVE_ITERATOR(__last),
704 template<
typename _InputIterator,
typename _ForwardIterator,
707 inline _ForwardIterator
708 __uninitialized_move_if_noexcept_a(_InputIterator __first,
709 _InputIterator __last,
710 _ForwardIterator __result,
713 return std::__uninitialized_copy_a
714 (_GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(__first),
715 _GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(__last), __result, __alloc);
718 template<
typename _ForwardIterator,
typename _Tp,
typename _Allocator>
721 __uninitialized_fill_a(_ForwardIterator __first, _ForwardIterator __last,
722 const _Tp& __x, _Allocator& __alloc)
724 _UninitDestroyGuard<_ForwardIterator, _Allocator>
725 __guard(__first, __alloc);
727 typedef __gnu_cxx::__alloc_traits<_Allocator> __traits;
728 for (; __first != __last; ++__first)
735 template<
typename _ForwardIterator,
typename _Tp,
typename _Tp2>
738 __uninitialized_fill_a(_ForwardIterator __first, _ForwardIterator __last,
741#ifdef __cpp_lib_is_constant_evaluated
742 if (std::is_constant_evaluated())
743 return std::__do_uninit_fill(__first, __last, __x);
749 template<
typename _ForwardIterator,
typename _Size,
typename _Tp,
753 __uninitialized_fill_n_a(_ForwardIterator __first, _Size __n,
754 const _Tp& __x, _Allocator& __alloc)
756 _UninitDestroyGuard<_ForwardIterator, _Allocator>
757 __guard(__first, __alloc);
758 typedef __gnu_cxx::__alloc_traits<_Allocator> __traits;
759 for (; __n > 0; --__n, (void) ++__first)
766 template<
typename _ForwardIterator,
typename _Size,
typename _Tp,
769 inline _ForwardIterator
770 __uninitialized_fill_n_a(_ForwardIterator __first, _Size __n,
773#ifdef __cpp_lib_is_constant_evaluated
774 if (std::is_constant_evaluated())
775 return std::__do_uninit_fill_n(__first, __n, __x);
790 template<
typename _InputIterator1,
typename _InputIterator2,
791 typename _ForwardIterator,
typename _Allocator>
792 inline _ForwardIterator
793 __uninitialized_copy_move(_InputIterator1 __first1,
794 _InputIterator1 __last1,
795 _InputIterator2 __first2,
796 _InputIterator2 __last2,
797 _ForwardIterator __result,
800 _ForwardIterator __mid = std::__uninitialized_copy_a(__first1, __last1,
802 _UninitDestroyGuard<_ForwardIterator, _Allocator> __guard(__result,
805 __result = std::__uninitialized_move_a(__first2, __last2, __mid, __alloc);
814 template<
typename _InputIterator1,
typename _InputIterator2,
815 typename _ForwardIterator,
typename _Allocator>
816 inline _ForwardIterator
817 __uninitialized_move_copy(_InputIterator1 __first1,
818 _InputIterator1 __last1,
819 _InputIterator2 __first2,
820 _InputIterator2 __last2,
821 _ForwardIterator __result,
824 _ForwardIterator __mid = std::__uninitialized_move_a(__first1, __last1,
826 _UninitDestroyGuard<_ForwardIterator, _Allocator> __guard(__result,
829 __result = std::__uninitialized_copy_a(__first2, __last2, __mid, __alloc);
837 template<
typename _ForwardIterator,
typename _Tp,
typename _InputIterator,
839 inline _ForwardIterator
840 __uninitialized_fill_move(_ForwardIterator __result, _ForwardIterator __mid,
841 const _Tp& __x, _InputIterator __first,
842 _InputIterator __last, _Allocator& __alloc)
844 std::__uninitialized_fill_a(__result, __mid, __x, __alloc);
845 _UninitDestroyGuard<_ForwardIterator, _Allocator> __guard(__result,
848 __result = std::__uninitialized_move_a(__first, __last, __mid, __alloc);
856 template<
typename _InputIterator,
typename _ForwardIterator,
typename _Tp,
859 __uninitialized_move_fill(_InputIterator __first1, _InputIterator __last1,
860 _ForwardIterator __first2,
861 _ForwardIterator __last2,
const _Tp& __x,
864 _ForwardIterator __mid2 = std::__uninitialized_move_a(__first1, __last1,
867 _UninitDestroyGuard<_ForwardIterator, _Allocator> __guard(__first2,
870 std::__uninitialized_fill_a(__mid2, __last2, __x, __alloc);
876#if __cplusplus >= 201103L
882 template<
bool _TrivialValueType>
883 struct __uninitialized_default_1
885 template<
typename _ForwardIterator>
888 __uninit_default(_ForwardIterator __first, _ForwardIterator __last)
890 _UninitDestroyGuard<_ForwardIterator> __guard(__first);
891 for (; __first != __last; ++__first)
898 struct __uninitialized_default_1<true>
900 template<
typename _ForwardIterator>
903 __uninit_default(_ForwardIterator __first, _ForwardIterator __last)
905 if (__first == __last)
908 typename iterator_traits<_ForwardIterator>::value_type* __val
911 if (++__first != __last)
912 std::fill(__first, __last, *__val);
916 template<
bool _TrivialValueType>
917 struct __uninitialized_default_n_1
919 template<
typename _ForwardIterator,
typename _Size>
921 static _ForwardIterator
922 __uninit_default_n(_ForwardIterator __first, _Size __n)
924 _UninitDestroyGuard<_ForwardIterator> __guard(__first);
925 for (; __n > 0; --__n, (void) ++__first)
933 struct __uninitialized_default_n_1<true>
935 template<
typename _ForwardIterator,
typename _Size>
937 static _ForwardIterator
938 __uninit_default_n(_ForwardIterator __first, _Size __n)
942 typename iterator_traits<_ForwardIterator>::value_type* __val
946 __first = std::fill_n(__first, __n - 1, *__val);
954 template<
typename _ForwardIterator>
957 __uninitialized_default(_ForwardIterator __first,
958 _ForwardIterator __last)
960#ifdef __cpp_lib_is_constant_evaluated
961 if (std::is_constant_evaluated())
962 return __uninitialized_default_1<false>::
963 __uninit_default(__first, __last);
971 std::__uninitialized_default_1<__is_trivial(_ValueType)
973 __uninit_default(__first, __last);
978 template<
typename _ForwardIterator,
typename _Size>
980 inline _ForwardIterator
981 __uninitialized_default_n(_ForwardIterator __first, _Size __n)
983#ifdef __cpp_lib_is_constant_evaluated
984 if (std::is_constant_evaluated())
985 return __uninitialized_default_n_1<false>::
986 __uninit_default_n(__first, __n);
992 constexpr bool __can_fill
995 return __uninitialized_default_n_1<__is_trivial(_ValueType)
997 __uninit_default_n(__first, __n);
1004 template<
typename _ForwardIterator,
typename _Allocator>
1006 __uninitialized_default_a(_ForwardIterator __first,
1007 _ForwardIterator __last,
1008 _Allocator& __alloc)
1010 _UninitDestroyGuard<_ForwardIterator, _Allocator> __guard(__first,
1012 typedef __gnu_cxx::__alloc_traits<_Allocator> __traits;
1013 for (; __first != __last; ++__first)
1019 template<
typename _ForwardIterator,
typename _Tp>
1021 __uninitialized_default_a(_ForwardIterator __first,
1022 _ForwardIterator __last,
1024 { std::__uninitialized_default(__first, __last); }
1030 template<
typename _ForwardIterator,
typename _Size,
typename _Allocator>
1031 _GLIBCXX20_CONSTEXPR _ForwardIterator
1032 __uninitialized_default_n_a(_ForwardIterator __first, _Size __n,
1033 _Allocator& __alloc)
1035 _UninitDestroyGuard<_ForwardIterator, _Allocator> __guard(__first,
1037 typedef __gnu_cxx::__alloc_traits<_Allocator> __traits;
1038 for (; __n > 0; --__n, (void) ++__first)
1047 template<
typename _ForwardIterator,
typename _Size,
typename _Tp>
1048 _GLIBCXX20_CONSTEXPR
1049 inline _ForwardIterator
1050 __uninitialized_default_n_a(_ForwardIterator __first, _Size __n,
1052 {
return std::__uninitialized_default_n(__first, __n); }
1055 template<
bool _TrivialValueType>
1056 struct __uninitialized_default_novalue_1
1058 template<
typename _ForwardIterator>
1059 _GLIBCXX26_CONSTEXPR
1061 __uninit_default_novalue(_ForwardIterator __first,
1062 _ForwardIterator __last)
1064 _UninitDestroyGuard<_ForwardIterator> __guard(__first);
1065 for (; __first != __last; ++__first)
1072 struct __uninitialized_default_novalue_1<true>
1074 template<
typename _ForwardIterator>
1075 _GLIBCXX26_CONSTEXPR
1077 __uninit_default_novalue(_ForwardIterator, _ForwardIterator)
1082 template<
bool _TrivialValueType>
1083 struct __uninitialized_default_novalue_n_1
1085 template<
typename _ForwardIterator,
typename _Size>
1086 _GLIBCXX26_CONSTEXPR
1087 static _ForwardIterator
1088 __uninit_default_novalue_n(_ForwardIterator __first, _Size __n)
1090 _UninitDestroyGuard<_ForwardIterator> __guard(__first);
1091 for (; __n > 0; --__n, (void) ++__first)
1099 struct __uninitialized_default_novalue_n_1<true>
1101 template<
typename _ForwardIterator,
typename _Size>
1102 _GLIBCXX26_CONSTEXPR
1103 static _ForwardIterator
1104 __uninit_default_novalue_n(_ForwardIterator __first, _Size __n)
1105 {
return std::next(__first, __n); }
1110 template<
typename _ForwardIterator>
1111 _GLIBCXX26_CONSTEXPR
1113 __uninitialized_default_novalue(_ForwardIterator __first,
1114 _ForwardIterator __last)
1119 std::__uninitialized_default_novalue_1<
1121 __uninit_default_novalue(__first, __last);
1126 template<
typename _ForwardIterator,
typename _Size>
1127 _GLIBCXX26_CONSTEXPR
1128 inline _ForwardIterator
1129 __uninitialized_default_novalue_n(_ForwardIterator __first, _Size __n)
1134 return __uninitialized_default_novalue_n_1<
1136 __uninit_default_novalue_n(__first, __n);
1139 template<
typename _InputIterator,
typename _Size,
1140 typename _ForwardIterator>
1141 _GLIBCXX26_CONSTEXPR
1143 __uninitialized_copy_n(_InputIterator __first, _Size __n,
1146 _UninitDestroyGuard<_ForwardIterator> __guard(__result);
1147 for (; __n > 0; --__n, (void) ++__first, ++__result)
1153 template<
typename _RandomAccessIterator,
typename _Size,
1154 typename _ForwardIterator>
1155 _GLIBCXX26_CONSTEXPR
1156 inline _ForwardIterator
1157 __uninitialized_copy_n(_RandomAccessIterator __first, _Size __n,
1158 _ForwardIterator __result,
1162 template<
typename _InputIterator,
typename _Size,
1163 typename _ForwardIterator>
1164 _GLIBCXX26_CONSTEXPR
1166 __uninitialized_copy_n_pair(_InputIterator __first, _Size __n,
1169 _UninitDestroyGuard<_ForwardIterator> __guard(__result);
1170 for (; __n > 0; --__n, (void) ++__first, ++__result)
1173 return {__first, __result};
1176 template<
typename _RandomAccessIterator,
typename _Size,
1177 typename _ForwardIterator>
1178 _GLIBCXX26_CONSTEXPR
1180 __uninitialized_copy_n_pair(_RandomAccessIterator __first, _Size __n,
1181 _ForwardIterator __result,
1185 auto __first_res = std::next(__first, __n);
1186 return {__first_res, __second_res};
1201 template<
typename _InputIterator,
typename _Size,
typename _ForwardIterator>
1202 _GLIBCXX26_CONSTEXPR
1203 inline _ForwardIterator
1205 _ForwardIterator __result)
1206 {
return std::__uninitialized_copy_n(__first, __n, __result,
1207 std::__iter_concept_or_category(__first)); }
1210 template<
typename _InputIterator,
typename _Size,
typename _ForwardIterator>
1211 _GLIBCXX26_CONSTEXPR
1213 __uninitialized_copy_n_pair(_InputIterator __first, _Size __n,
1214 _ForwardIterator __result)
1217 std::__uninitialized_copy_n_pair(__first, __n, __result,
1218 std::__iter_concept_or_category(__first));
1223#ifdef __glibcxx_raw_memory_algorithms
1230 template <
typename _ForwardIterator>
1231 _GLIBCXX26_CONSTEXPR
1234 _ForwardIterator __last)
1236 std::__uninitialized_default_novalue(__first, __last);
1246 template <
typename _ForwardIterator,
typename _Size>
1247 _GLIBCXX26_CONSTEXPR
1248 inline _ForwardIterator
1251 return std::__uninitialized_default_novalue_n(__first, __count);
1260 template <
typename _ForwardIterator>
1261 _GLIBCXX26_CONSTEXPR
1264 _ForwardIterator __last)
1266 return std::__uninitialized_default(__first, __last);
1276 template <
typename _ForwardIterator,
typename _Size>
1277 _GLIBCXX26_CONSTEXPR
1278 inline _ForwardIterator
1281 return std::__uninitialized_default_n(__first, __count);
1292 template <
typename _InputIterator,
typename _ForwardIterator>
1293 _GLIBCXX26_CONSTEXPR
1294 inline _ForwardIterator
1296 _ForwardIterator __result)
1299 std::make_move_iterator(__last),
1311 template <
typename _InputIterator,
typename _Size,
typename _ForwardIterator>
1312 _GLIBCXX26_CONSTEXPR
1315 _ForwardIterator __result)
1318 = std::__uninitialized_copy_n_pair(std::make_move_iterator(__first),
1320 return {__res.first.base(), __res.second};
1324#if __cplusplus >= 201103L
1327 template<
typename _Tp,
typename _Up,
typename _Allocator>
1328 _GLIBCXX20_CONSTEXPR
1330 __relocate_object_a(_Tp* __restrict __dest, _Up* __restrict __orig,
1331 _Allocator& __alloc)
1338 __traits::construct(__alloc, __dest,
std::move(*__orig));
1344 template<
typename _Tp,
typename =
void>
1345 struct __is_bitwise_relocatable
1346 : __bool_constant<__is_trivial(_Tp)>
1349 template <
typename _InputIterator,
typename _ForwardIterator,
1350 typename _Allocator>
1351 _GLIBCXX20_CONSTEXPR
1352 inline _ForwardIterator
1353 __relocate_a_1(_InputIterator __first, _InputIterator __last,
1354 _ForwardIterator __result, _Allocator& __alloc)
1355 noexcept(
noexcept(std::__relocate_object_a(
std::addressof(*__result),
1363 static_assert(std::is_same<_ValueType, _ValueType2>::value,
1364 "relocation is only possible for values of the same type");
1365 _ForwardIterator __cur = __result;
1366 for (; __first != __last; ++__first, (void)++__cur)
1373 template <
typename _Tp,
typename _Up>
1374 _GLIBCXX20_CONSTEXPR
1375 inline __enable_if_t<std::__is_bitwise_relocatable<_Tp>::value, _Tp*>
1376 __relocate_a_1(_Tp* __first, _Tp* __last,
1380 ptrdiff_t __count = __last - __first;
1383#ifdef __cpp_lib_is_constant_evaluated
1384 if (std::is_constant_evaluated())
1388 __gnu_cxx::__normal_iterator<_Tp*, void> __out(__result);
1389 __out = std::__relocate_a_1(__first, __last, __out, __alloc);
1390 return __out.base();
1393 __builtin_memcpy(__result, __first, __count *
sizeof(_Tp));
1395 return __result + __count;
1399 template <
typename _InputIterator,
typename _ForwardIterator,
1400 typename _Allocator>
1401 _GLIBCXX20_CONSTEXPR
1402 inline _ForwardIterator
1403 __relocate_a(_InputIterator __first, _InputIterator __last,
1404 _ForwardIterator __result, _Allocator& __alloc)
1405 noexcept(
noexcept(__relocate_a_1(std::__niter_base(__first),
1406 std::__niter_base(__last),
1407 std::__niter_base(__result), __alloc)))
1409 return std::__relocate_a_1(std::__niter_base(__first),
1410 std::__niter_base(__last),
1411 std::__niter_base(__result), __alloc);
1419_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.
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 of arbitrary type.
Random-access iterators support a superset of bidirectional iterator operations.
Uniform interface to C++98 and C++11 allocators.