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))
125 void release() { _M_cur = 0; }
127 _ForwardIterator
const _M_first;
128 _ForwardIterator* _M_cur;
131 _UninitDestroyGuard(
const _UninitDestroyGuard&);
136 template<
typename _InputIterator,
typename _Sentinel,
137 typename _ForwardIterator>
140 __do_uninit_copy(_InputIterator __first, _Sentinel __last,
141 _ForwardIterator __result)
143 _UninitDestroyGuard<_ForwardIterator> __guard(__result);
144 for (; __first != __last; ++__first, (void)++__result)
150#if __cplusplus < 201103L
153 template<
typename _Iter,
154 typename _Base = __decltype(std::__niter_base(*(_Iter*)0))>
155 struct __unwrappable_niter
156 {
enum { __value =
false }; };
158 template<
typename _Iter,
typename _Tp>
159 struct __unwrappable_niter<_Iter, _Tp*>
160 {
enum { __value =
true }; };
163 template<
bool _CanMemcpy>
164 struct __uninitialized_copy
166 template<
typename _InputIterator,
typename _ForwardIterator>
167 static _ForwardIterator
168 __uninit_copy(_InputIterator __first, _InputIterator __last,
169 _ForwardIterator __result)
170 {
return std::__do_uninit_copy(__first, __last, __result); }
174 struct __uninitialized_copy<true>
177 template<
typename _InputIterator,
typename _ForwardIterator>
178 static _ForwardIterator
179 __uninit_copy(_InputIterator __first, _InputIterator __last,
180 _ForwardIterator __result)
182 if (__unwrappable_niter<_InputIterator>::__value
183 && __unwrappable_niter<_ForwardIterator>::__value)
185 __uninit_copy(std::__niter_base(__first),
186 std::__niter_base(__last),
187 std::__niter_base(__result));
192 return std::__do_uninit_copy(__first, __last, __result);
196 template<
typename _Tp,
typename _Up>
198 __uninit_copy(_Tp* __first, _Tp* __last, _Up* __result)
202 typedef __typeof__(
static_cast<_Up
>(*__first)) __check
203 __attribute__((__unused__));
205 const ptrdiff_t __n = __last - __first;
206 if (__builtin_expect(__n > 0,
true))
208 __builtin_memcpy(__result, __first, __n *
sizeof(_Tp));
217#pragma GCC diagnostic push
218#pragma GCC diagnostic ignored "-Wc++17-extensions"
228 template<
typename _InputIterator,
typename _ForwardIterator>
229 inline _ForwardIterator
231 _ForwardIterator __result)
254#if __cplusplus >= 201103L
255 using _Dest =
decltype(std::__niter_base(__result));
256 using _Src =
decltype(std::__niter_base(__first));
259 if constexpr (!__is_trivially_constructible(_ValT,
decltype(*__first)))
260 return std::__do_uninit_copy(__first, __last, __result);
261 else if constexpr (__memcpyable<_Dest, _Src>::__value)
263 ptrdiff_t __n = __last - __first;
264 if (__n > 0) [[__likely__]]
266 using _ValT =
typename remove_pointer<_Src>::type;
267 __builtin_memcpy(std::__niter_base(__result),
268 std::__niter_base(__first),
269 __n *
sizeof(_ValT));
274#if __cpp_lib_concepts
275 else if constexpr (contiguous_iterator<_ForwardIterator>
276 && contiguous_iterator<_InputIterator>)
280 if constexpr (__memcpyable<_DestPtr, _SrcPtr>::__value)
282 if (
auto __n = __last - __first; __n > 0) [[likely]]
287 __builtin_memcpy(__dest, __src, __nbytes);
293 return std::__do_uninit_copy(__first, __last, __result);
297 return std::__do_uninit_copy(__first, __last, __result);
304 const bool __can_memcpy
305 = __memcpyable<_ValueType1*, _ValueType2*>::__value
306 && __is_trivially_constructible(_ValueType2, __decltype(*__first));
308 return __uninitialized_copy<__can_memcpy>::
309 __uninit_copy(__first, __last, __result);
312#pragma GCC diagnostic pop
317 template<
typename _ForwardIterator,
typename _Tp>
318 _GLIBCXX20_CONSTEXPR
void
319 __do_uninit_fill(_ForwardIterator __first, _ForwardIterator __last,
322 _UninitDestroyGuard<_ForwardIterator> __guard(__first);
323 for (; __first != __last; ++__first)
328#if __cplusplus < 201103L
330 template<
bool _CanMemset>
331 struct __uninitialized_fill
333 template<
typename _ForwardIterator,
typename _Tp>
335 __uninit_fill(_ForwardIterator __first, _ForwardIterator __last,
337 { std::__do_uninit_fill(__first, __last, __x); }
341 struct __uninitialized_fill<true>
344 template<
typename _ForwardIterator,
typename _Tp>
346 __uninit_fill(_ForwardIterator __first, _ForwardIterator __last,
349 if (__unwrappable_niter<_ForwardIterator>::__value)
350 __uninit_fill(std::__niter_base(__first),
351 std::__niter_base(__last),
354 std::__do_uninit_copy(__first, __last, __x);
358 template<
typename _Up,
typename _Tp>
360 __uninit_fill(_Up* __first, _Up* __last,
const _Tp& __x)
364 typedef __typeof__(
static_cast<_Up
>(__x)) __check
365 __attribute__((__unused__));
367 if (__first != __last)
368 __builtin_memset(__first, (
unsigned char)__x, __last - __first);
383 template<
typename _ForwardIterator,
typename _Tp>
400#if __cplusplus >= 201103L
401#pragma GCC diagnostic push
402#pragma GCC diagnostic ignored "-Wc++17-extensions"
403 if constexpr (__is_byte<_ValueType>::__value)
407 using _BasePtr =
decltype(std::__niter_base(__first));
410 void* __dest = std::__niter_base(__first);
411 ptrdiff_t __n = __last - __first;
412 if (__n > 0) [[__likely__]]
413 __builtin_memset(__dest, (
unsigned char)__x, __n);
416#if __cpp_lib_concepts
417 else if constexpr (contiguous_iterator<_ForwardIterator>)
420 auto __n = __last - __first;
421 if (__n > 0) [[__likely__]]
422 __builtin_memset(__dest, (
unsigned char)__x, __n);
427 std::__do_uninit_fill(__first, __last, __x);
428#pragma GCC diagnostic pop
430 const bool __can_memset = __is_byte<_ValueType>::__value
431 && __is_integer<_Tp>::__value;
433 __uninitialized_fill<__can_memset>::__uninit_fill(__first, __last, __x);
440 template<
typename _ForwardIterator,
typename _Size,
typename _Tp>
443 __do_uninit_fill_n(_ForwardIterator __first, _Size __n,
const _Tp& __x)
445 _UninitDestroyGuard<_ForwardIterator> __guard(__first);
446#if __cplusplus >= 201103L
447#pragma GCC diagnostic push
448#pragma GCC diagnostic ignored "-Wc++17-extensions"
449 if constexpr (is_integral<_Size>::value)
451 __glibcxx_assert(__n >= 0);
452 else if constexpr (is_floating_point<_Size>::value)
454 __glibcxx_assert(__n >= 0 &&
static_cast<size_t>(__n) == __n);
455#pragma GCC diagnostic pop
457 for (; __n--; ++__first)
463#if __cplusplus < 201103L
465 template<
bool _CanMemset>
466 struct __uninitialized_fill_n
468 template<
typename _ForwardIterator,
typename _Size,
typename _Tp>
469 static _ForwardIterator
470 __uninit_fill_n(_ForwardIterator __first, _Size __n,
472 {
return std::__do_uninit_fill_n(__first, __n, __x); }
476 struct __uninitialized_fill_n<true>
479 template<
typename _ForwardIterator,
typename _Size,
typename _Tp>
480 static _ForwardIterator
481 __uninit_fill_n(_ForwardIterator __first, _Size __n,
484 if (__unwrappable_niter<_ForwardIterator>::__value)
486 _ForwardIterator __last = __first;
488 __uninitialized_fill<true>::__uninit_fill(__first, __last, __x);
492 return std::__do_uninit_fill_n(__first, __n, __x);
498#pragma GCC diagnostic push
499#pragma GCC diagnostic ignored "-Wc++17-extensions"
511 template<
typename _ForwardIterator,
typename _Size,
typename _Tp>
512 inline _ForwardIterator
524#if __cplusplus >= 201103L
525 if constexpr (__is_byte<_ValueType>::__value)
529 using _BasePtr =
decltype(std::__niter_base(__first));
532 void* __dest = std::__niter_base(__first);
533 if (__n > 0) [[__likely__]]
535 __builtin_memset(__dest, (
unsigned char)__x, __n);
540#if __cpp_lib_concepts
541 else if constexpr (contiguous_iterator<_ForwardIterator>)
544 if (__n > 0) [[__likely__]]
546 __builtin_memset(__dest, (
unsigned char)__x, __n);
553 return std::__do_uninit_fill_n(__first, __n, __x);
555 const bool __can_memset = __is_byte<_ValueType>::__value
556 && __is_integer<_Tp>::__value
557 && __is_integer<_Size>::__value;
559 return __uninitialized_fill_n<__can_memset>::
560 __uninit_fill_n(__first, __n, __x);
563#pragma GCC diagnostic pop
573 template<
typename _InputIterator,
typename _Sentinel,
574 typename _ForwardIterator,
typename _Allocator>
577 __uninitialized_copy_a(_InputIterator __first, _Sentinel __last,
578 _ForwardIterator __result, _Allocator& __alloc)
580 _UninitDestroyGuard<_ForwardIterator, _Allocator>
581 __guard(__result, __alloc);
584 for (; __first != __last; ++__first, (void)++__result)
591 template<
typename _InputIterator,
typename _Sentinel,
592 typename _ForwardIterator,
typename _Tp>
594 inline _ForwardIterator
595 __uninitialized_copy_a(_InputIterator __first, _Sentinel __last,
598#ifdef __cpp_lib_is_constant_evaluated
599 if (std::is_constant_evaluated())
600 return std::__do_uninit_copy(
std::move(__first), __last, __result);
603#ifdef __glibcxx_ranges
604 if constexpr (!is_same_v<_InputIterator, _Sentinel>)
608 if constexpr (sized_sentinel_for<_Sentinel, _InputIterator>
609 && random_access_iterator<_InputIterator>)
611 __first + (__last - __first),
614 return std::__do_uninit_copy(
std::move(__first), __last, __result);
624 template<
typename _InputIterator,
typename _ForwardIterator,
627 inline _ForwardIterator
628 __uninitialized_move_a(_InputIterator __first, _InputIterator __last,
629 _ForwardIterator __result, _Allocator& __alloc)
631 return std::__uninitialized_copy_a(_GLIBCXX_MAKE_MOVE_ITERATOR(__first),
632 _GLIBCXX_MAKE_MOVE_ITERATOR(__last),
636 template<
typename _InputIterator,
typename _ForwardIterator,
639 inline _ForwardIterator
640 __uninitialized_move_if_noexcept_a(_InputIterator __first,
641 _InputIterator __last,
642 _ForwardIterator __result,
645 return std::__uninitialized_copy_a
646 (_GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(__first),
647 _GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(__last), __result, __alloc);
650 template<
typename _ForwardIterator,
typename _Tp,
typename _Allocator>
653 __uninitialized_fill_a(_ForwardIterator __first, _ForwardIterator __last,
654 const _Tp& __x, _Allocator& __alloc)
656 _UninitDestroyGuard<_ForwardIterator, _Allocator>
657 __guard(__first, __alloc);
659 typedef __gnu_cxx::__alloc_traits<_Allocator> __traits;
660 for (; __first != __last; ++__first)
667 template<
typename _ForwardIterator,
typename _Tp,
typename _Tp2>
670 __uninitialized_fill_a(_ForwardIterator __first, _ForwardIterator __last,
673#ifdef __cpp_lib_is_constant_evaluated
674 if (std::is_constant_evaluated())
675 return std::__do_uninit_fill(__first, __last, __x);
681 template<
typename _ForwardIterator,
typename _Size,
typename _Tp,
685 __uninitialized_fill_n_a(_ForwardIterator __first, _Size __n,
686 const _Tp& __x, _Allocator& __alloc)
688 _UninitDestroyGuard<_ForwardIterator, _Allocator>
689 __guard(__first, __alloc);
690 typedef __gnu_cxx::__alloc_traits<_Allocator> __traits;
691 for (; __n > 0; --__n, (void) ++__first)
698 template<
typename _ForwardIterator,
typename _Size,
typename _Tp,
701 inline _ForwardIterator
702 __uninitialized_fill_n_a(_ForwardIterator __first, _Size __n,
705#ifdef __cpp_lib_is_constant_evaluated
706 if (std::is_constant_evaluated())
707 return std::__do_uninit_fill_n(__first, __n, __x);
722 template<
typename _InputIterator1,
typename _InputIterator2,
723 typename _ForwardIterator,
typename _Allocator>
724 inline _ForwardIterator
725 __uninitialized_copy_move(_InputIterator1 __first1,
726 _InputIterator1 __last1,
727 _InputIterator2 __first2,
728 _InputIterator2 __last2,
729 _ForwardIterator __result,
732 _ForwardIterator __mid = std::__uninitialized_copy_a(__first1, __last1,
734 _UninitDestroyGuard<_ForwardIterator, _Allocator> __guard(__result,
737 __result = std::__uninitialized_move_a(__first2, __last2, __mid, __alloc);
746 template<
typename _InputIterator1,
typename _InputIterator2,
747 typename _ForwardIterator,
typename _Allocator>
748 inline _ForwardIterator
749 __uninitialized_move_copy(_InputIterator1 __first1,
750 _InputIterator1 __last1,
751 _InputIterator2 __first2,
752 _InputIterator2 __last2,
753 _ForwardIterator __result,
756 _ForwardIterator __mid = std::__uninitialized_move_a(__first1, __last1,
758 _UninitDestroyGuard<_ForwardIterator, _Allocator> __guard(__result,
761 __result = std::__uninitialized_copy_a(__first2, __last2, __mid, __alloc);
769 template<
typename _ForwardIterator,
typename _Tp,
typename _InputIterator,
771 inline _ForwardIterator
772 __uninitialized_fill_move(_ForwardIterator __result, _ForwardIterator __mid,
773 const _Tp& __x, _InputIterator __first,
774 _InputIterator __last, _Allocator& __alloc)
776 std::__uninitialized_fill_a(__result, __mid, __x, __alloc);
777 _UninitDestroyGuard<_ForwardIterator, _Allocator> __guard(__result,
780 __result = std::__uninitialized_move_a(__first, __last, __mid, __alloc);
788 template<
typename _InputIterator,
typename _ForwardIterator,
typename _Tp,
791 __uninitialized_move_fill(_InputIterator __first1, _InputIterator __last1,
792 _ForwardIterator __first2,
793 _ForwardIterator __last2,
const _Tp& __x,
796 _ForwardIterator __mid2 = std::__uninitialized_move_a(__first1, __last1,
799 _UninitDestroyGuard<_ForwardIterator, _Allocator> __guard(__first2,
802 std::__uninitialized_fill_a(__mid2, __last2, __x, __alloc);
808#if __cplusplus >= 201103L
814 template<
bool _TrivialValueType>
815 struct __uninitialized_default_1
817 template<
typename _ForwardIterator>
819 __uninit_default(_ForwardIterator __first, _ForwardIterator __last)
821 _UninitDestroyGuard<_ForwardIterator> __guard(__first);
822 for (; __first != __last; ++__first)
829 struct __uninitialized_default_1<true>
831 template<
typename _ForwardIterator>
833 __uninit_default(_ForwardIterator __first, _ForwardIterator __last)
835 if (__first == __last)
838 typename iterator_traits<_ForwardIterator>::value_type* __val
841 if (++__first != __last)
842 std::fill(__first, __last, *__val);
846 template<
bool _TrivialValueType>
847 struct __uninitialized_default_n_1
849 template<
typename _ForwardIterator,
typename _Size>
851 static _ForwardIterator
852 __uninit_default_n(_ForwardIterator __first, _Size __n)
854 _UninitDestroyGuard<_ForwardIterator> __guard(__first);
855 for (; __n > 0; --__n, (void) ++__first)
863 struct __uninitialized_default_n_1<true>
865 template<
typename _ForwardIterator,
typename _Size>
867 static _ForwardIterator
868 __uninit_default_n(_ForwardIterator __first, _Size __n)
872 typename iterator_traits<_ForwardIterator>::value_type* __val
876 __first = std::fill_n(__first, __n - 1, *__val);
884 template<
typename _ForwardIterator>
886 __uninitialized_default(_ForwardIterator __first,
887 _ForwardIterator __last)
894 std::__uninitialized_default_1<__is_trivial(_ValueType)
896 __uninit_default(__first, __last);
901 template<
typename _ForwardIterator,
typename _Size>
903 inline _ForwardIterator
904 __uninitialized_default_n(_ForwardIterator __first, _Size __n)
906#ifdef __cpp_lib_is_constant_evaluated
907 if (std::is_constant_evaluated())
908 return __uninitialized_default_n_1<false>::
909 __uninit_default_n(__first, __n);
915 constexpr bool __can_fill
918 return __uninitialized_default_n_1<__is_trivial(_ValueType)
920 __uninit_default_n(__first, __n);
927 template<
typename _ForwardIterator,
typename _Allocator>
929 __uninitialized_default_a(_ForwardIterator __first,
930 _ForwardIterator __last,
933 _UninitDestroyGuard<_ForwardIterator, _Allocator> __guard(__first,
935 typedef __gnu_cxx::__alloc_traits<_Allocator> __traits;
936 for (; __first != __last; ++__first)
942 template<
typename _ForwardIterator,
typename _Tp>
944 __uninitialized_default_a(_ForwardIterator __first,
945 _ForwardIterator __last,
947 { std::__uninitialized_default(__first, __last); }
953 template<
typename _ForwardIterator,
typename _Size,
typename _Allocator>
954 _GLIBCXX20_CONSTEXPR _ForwardIterator
955 __uninitialized_default_n_a(_ForwardIterator __first, _Size __n,
958 _UninitDestroyGuard<_ForwardIterator, _Allocator> __guard(__first,
960 typedef __gnu_cxx::__alloc_traits<_Allocator> __traits;
961 for (; __n > 0; --__n, (void) ++__first)
970 template<
typename _ForwardIterator,
typename _Size,
typename _Tp>
972 inline _ForwardIterator
973 __uninitialized_default_n_a(_ForwardIterator __first, _Size __n,
975 {
return std::__uninitialized_default_n(__first, __n); }
978 template<
bool _TrivialValueType>
979 struct __uninitialized_default_novalue_1
981 template<
typename _ForwardIterator>
983 __uninit_default_novalue(_ForwardIterator __first,
984 _ForwardIterator __last)
986 _UninitDestroyGuard<_ForwardIterator> __guard(__first);
987 for (; __first != __last; ++__first)
994 struct __uninitialized_default_novalue_1<true>
996 template<
typename _ForwardIterator>
998 __uninit_default_novalue(_ForwardIterator, _ForwardIterator)
1003 template<
bool _TrivialValueType>
1004 struct __uninitialized_default_novalue_n_1
1006 template<
typename _ForwardIterator,
typename _Size>
1007 static _ForwardIterator
1008 __uninit_default_novalue_n(_ForwardIterator __first, _Size __n)
1010 _UninitDestroyGuard<_ForwardIterator> __guard(__first);
1011 for (; __n > 0; --__n, (void) ++__first)
1019 struct __uninitialized_default_novalue_n_1<true>
1021 template<
typename _ForwardIterator,
typename _Size>
1022 static _ForwardIterator
1023 __uninit_default_novalue_n(_ForwardIterator __first, _Size __n)
1024 {
return std::next(__first, __n); }
1029 template<
typename _ForwardIterator>
1031 __uninitialized_default_novalue(_ForwardIterator __first,
1032 _ForwardIterator __last)
1037 std::__uninitialized_default_novalue_1<
1039 __uninit_default_novalue(__first, __last);
1044 template<
typename _ForwardIterator,
typename _Size>
1045 inline _ForwardIterator
1046 __uninitialized_default_novalue_n(_ForwardIterator __first, _Size __n)
1051 return __uninitialized_default_novalue_n_1<
1053 __uninit_default_novalue_n(__first, __n);
1056 template<
typename _InputIterator,
typename _Size,
1057 typename _ForwardIterator>
1059 __uninitialized_copy_n(_InputIterator __first, _Size __n,
1062 _UninitDestroyGuard<_ForwardIterator> __guard(__result);
1063 for (; __n > 0; --__n, (void) ++__first, ++__result)
1069 template<
typename _RandomAccessIterator,
typename _Size,
1070 typename _ForwardIterator>
1071 inline _ForwardIterator
1072 __uninitialized_copy_n(_RandomAccessIterator __first, _Size __n,
1073 _ForwardIterator __result,
1077 template<
typename _InputIterator,
typename _Size,
1078 typename _ForwardIterator>
1080 __uninitialized_copy_n_pair(_InputIterator __first, _Size __n,
1083 _UninitDestroyGuard<_ForwardIterator> __guard(__result);
1084 for (; __n > 0; --__n, (void) ++__first, ++__result)
1087 return {__first, __result};
1090 template<
typename _RandomAccessIterator,
typename _Size,
1091 typename _ForwardIterator>
1093 __uninitialized_copy_n_pair(_RandomAccessIterator __first, _Size __n,
1094 _ForwardIterator __result,
1098 auto __first_res = std::next(__first, __n);
1099 return {__first_res, __second_res};
1114 template<
typename _InputIterator,
typename _Size,
typename _ForwardIterator>
1115 inline _ForwardIterator
1117 _ForwardIterator __result)
1118 {
return std::__uninitialized_copy_n(__first, __n, __result,
1122 template<
typename _InputIterator,
typename _Size,
typename _ForwardIterator>
1124 __uninitialized_copy_n_pair(_InputIterator __first, _Size __n,
1125 _ForwardIterator __result)
1128 std::__uninitialized_copy_n_pair(__first, __n, __result,
1134#ifdef __glibcxx_raw_memory_algorithms
1141 template <
typename _ForwardIterator>
1144 _ForwardIterator __last)
1146 std::__uninitialized_default_novalue(__first, __last);
1156 template <
typename _ForwardIterator,
typename _Size>
1157 inline _ForwardIterator
1160 return std::__uninitialized_default_novalue_n(__first, __count);
1169 template <
typename _ForwardIterator>
1172 _ForwardIterator __last)
1174 return std::__uninitialized_default(__first, __last);
1184 template <
typename _ForwardIterator,
typename _Size>
1185 inline _ForwardIterator
1188 return std::__uninitialized_default_n(__first, __count);
1199 template <
typename _InputIterator,
typename _ForwardIterator>
1200 inline _ForwardIterator
1202 _ForwardIterator __result)
1205 (_GLIBCXX_MAKE_MOVE_ITERATOR(__first),
1206 _GLIBCXX_MAKE_MOVE_ITERATOR(__last), __result);
1217 template <
typename _InputIterator,
typename _Size,
typename _ForwardIterator>
1220 _ForwardIterator __result)
1222 auto __res = std::__uninitialized_copy_n_pair
1223 (_GLIBCXX_MAKE_MOVE_ITERATOR(__first),
1225 return {__res.first.base(), __res.second};
1229#if __cplusplus >= 201103L
1232 template<
typename _Tp,
typename _Up,
typename _Allocator>
1233 _GLIBCXX20_CONSTEXPR
1235 __relocate_object_a(_Tp* __restrict __dest, _Up* __restrict __orig,
1236 _Allocator& __alloc)
1243 __traits::construct(__alloc, __dest,
std::move(*__orig));
1249 template<
typename _Tp,
typename =
void>
1250 struct __is_bitwise_relocatable
1251 : __bool_constant<__is_trivial(_Tp)>
1254 template <
typename _InputIterator,
typename _ForwardIterator,
1255 typename _Allocator>
1256 _GLIBCXX20_CONSTEXPR
1257 inline _ForwardIterator
1258 __relocate_a_1(_InputIterator __first, _InputIterator __last,
1259 _ForwardIterator __result, _Allocator& __alloc)
1260 noexcept(
noexcept(std::__relocate_object_a(
std::addressof(*__result),
1268 static_assert(std::is_same<_ValueType, _ValueType2>::value,
1269 "relocation is only possible for values of the same type");
1270 _ForwardIterator __cur = __result;
1271 for (; __first != __last; ++__first, (void)++__cur)
1278 template <
typename _Tp,
typename _Up>
1279 _GLIBCXX20_CONSTEXPR
1280 inline __enable_if_t<std::__is_bitwise_relocatable<_Tp>::value, _Tp*>
1281 __relocate_a_1(_Tp* __first, _Tp* __last,
1285 ptrdiff_t __count = __last - __first;
1288#ifdef __cpp_lib_is_constant_evaluated
1289 if (std::is_constant_evaluated())
1293 __gnu_cxx::__normal_iterator<_Tp*, void> __out(__result);
1294 __out = std::__relocate_a_1(__first, __last, __out, __alloc);
1295 return __out.base();
1298 __builtin_memcpy(__result, __first, __count *
sizeof(_Tp));
1300 return __result + __count;
1304 template <
typename _InputIterator,
typename _ForwardIterator,
1305 typename _Allocator>
1306 _GLIBCXX20_CONSTEXPR
1307 inline _ForwardIterator
1308 __relocate_a(_InputIterator __first, _InputIterator __last,
1309 _ForwardIterator __result, _Allocator& __alloc)
1310 noexcept(
noexcept(__relocate_a_1(std::__niter_base(__first),
1311 std::__niter_base(__last),
1312 std::__niter_base(__result), __alloc)))
1314 return std::__relocate_a_1(std::__niter_base(__first),
1315 std::__niter_base(__last),
1316 std::__niter_base(__result), __alloc);
1324_GLIBCXX_END_NAMESPACE_VERSION
_ForwardIterator uninitialized_copy_n(_InputIterator __first, _Size __n, _ForwardIterator __result)
Copies the range [first,first+n) into result.
void uninitialized_fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp &__x)
Copies the value x into the range [first,last).
_ForwardIterator uninitialized_value_construct_n(_ForwardIterator __first, _Size __count)
Value-initializes objects in the range [first,first+count).
_ForwardIterator uninitialized_move(_InputIterator __first, _InputIterator __last, _ForwardIterator __result)
Move-construct from the range [first,last) into result.
_ForwardIterator uninitialized_fill_n(_ForwardIterator __first, _Size __n, const _Tp &__x)
Copies the value x into the range [first,first+n).
_ForwardIterator uninitialized_default_construct_n(_ForwardIterator __first, _Size __count)
Default-initializes objects in the range [first,first+count).
void uninitialized_default_construct(_ForwardIterator __first, _ForwardIterator __last)
Default-initializes objects in the range [first,last).
_ForwardIterator uninitialized_copy(_InputIterator __first, _InputIterator __last, _ForwardIterator __result)
Copies the range [first,last) into result.
void uninitialized_value_construct(_ForwardIterator __first, _ForwardIterator __last)
Value-initializes objects in the range [first,last).
pair< _InputIterator, _ForwardIterator > uninitialized_move_n(_InputIterator __first, _Size __count, _ForwardIterator __result)
Move-construct from the range [first,first+count) into result.
constexpr _Tp * to_address(_Tp *__ptr) noexcept
Obtain address referenced by a pointer to an object.
typename remove_pointer< _Tp >::type remove_pointer_t
Alias template for remove_pointer.
pair(_T1, _T2) -> pair< _T1, _T2 >
Two pairs are equal iff their members are equal.
constexpr _Tp * addressof(_Tp &__r) noexcept
Returns the actual address of the object or function referenced by r, even in the presence of an over...
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
constexpr _Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
constexpr iterator_traits< _Iter >::iterator_category __iterator_category(const _Iter &)
ISO C++ entities toplevel namespace is std.
constexpr iterator_traits< _InputIterator >::difference_type distance(_InputIterator __first, _InputIterator __last)
A generalization of pointer arithmetic.
constexpr void _Construct(_Tp *__p, _Args &&... __args)
constexpr void advance(_InputIterator &__i, _Distance __n)
A generalization of pointer arithmetic.
constexpr void _Destroy(_ForwardIterator __first, _ForwardIterator __last)
is_trivially_default_constructible
Uniform interface to all allocator types.
static constexpr void construct(_Alloc &__a, _Tp *__p, _Args &&... __args) noexcept(_S_nothrow_construct< _Tp, _Args... >())
Construct an object of type _Tp
static constexpr void destroy(_Alloc &__a, _Tp *__p) noexcept(_S_nothrow_destroy< _Tp >())
Destroy an object of type _Tp.
The standard allocator, as per C++03 [20.4.1].
Struct holding two objects of arbitrary type.
Random-access iterators support a superset of bidirectional iterator operations.
Traits class for iterators.
Uniform interface to C++98 and C++11 allocators.