56#ifndef _STL_CONSTRUCT_H
57#define _STL_CONSTRUCT_H 1
73namespace std _GLIBCXX_VISIBILITY(default)
75_GLIBCXX_BEGIN_NAMESPACE_VERSION
77#if __glibcxx_raw_memory_algorithms
78 template <
typename _Tp>
79 _GLIBCXX20_CONSTEXPR
inline void
80 destroy_at(_Tp* __location)
82 if constexpr (__cplusplus > 201703L && is_array_v<_Tp>)
84 for (
auto& __x : *__location)
91#if __cpp_constexpr_dynamic_alloc
92 template<
typename _Tp,
typename... _Args>
93 requires (!is_unbounded_array_v<_Tp>)
94 &&
requires { ::new((
void*)0) _Tp(std::declval<_Args>()...); }
96 construct_at(_Tp* __location, _Args&&... __args)
97 noexcept(
noexcept(::new((
void*)0) _Tp(std::declval<_Args>()...)))
99 void* __loc = __location;
102 if constexpr (is_array_v<_Tp>)
104 static_assert(
sizeof...(_Args) == 0,
"std::construct_at for array "
105 "types must not use any arguments to initialize the "
107 return ::new(__loc) _Tp[1]();
110 return ::new(__loc) _Tp(std::forward<_Args>(__args)...);
119#if __cplusplus >= 201103L
120 template<
typename _Tp,
typename... _Args>
125#if __cpp_constexpr_dynamic_alloc
126 if (std::__is_constant_evaluated())
129 std::construct_at(__p, std::forward<_Args>(__args)...);
133 ::new(
static_cast<void*
>(__p)) _Tp(std::forward<_Args>(__args)...);
136 template<
typename _T1,
typename _T2>
142 ::new(
static_cast<void*
>(__p)) _T1(__value);
146 template<
typename _T1>
148 _Construct_novalue(_T1* __p)
149 { ::new(
static_cast<void*
>(__p)) _T1; }
151 template<
typename _ForwardIterator>
152 _GLIBCXX20_CONSTEXPR
void
153 _Destroy(_ForwardIterator __first, _ForwardIterator __last);
158 template<
typename _Tp>
159 _GLIBCXX14_CONSTEXPR
inline void
162#if __cpp_constexpr_dynamic_alloc
163 std::destroy_at(__pointer);
172 template<
typename _ForwardIterator>
173 static _GLIBCXX20_CONSTEXPR
void
174 __destroy(_ForwardIterator __first, _ForwardIterator __last)
176 for (; __first != __last; ++__first)
182 struct _Destroy_aux<true>
184 template<
typename _ForwardIterator>
186 __destroy(_ForwardIterator, _ForwardIterator) { }
194 template<
typename _ForwardIterator>
195 _GLIBCXX20_CONSTEXPR
inline void
196 _Destroy(_ForwardIterator __first, _ForwardIterator __last)
200#if __cplusplus >= 201103L
203 "value type is destructible");
205#if __cpp_constexpr_dynamic_alloc
206 if (std::__is_constant_evaluated())
207 return std::_Destroy_aux<false>::__destroy(__first, __last);
209 std::_Destroy_aux<__has_trivial_destructor(_Value_type)>::
210 __destroy(__first, __last);
214 struct _Destroy_n_aux
216 template<
typename _ForwardIterator,
typename _Size>
217 static _GLIBCXX20_CONSTEXPR _ForwardIterator
218 __destroy_n(_ForwardIterator __first, _Size __count)
220 for (; __count > 0; (void)++__first, --__count)
227 struct _Destroy_n_aux<true>
229 template<
typename _ForwardIterator,
typename _Size>
230 static _ForwardIterator
231 __destroy_n(_ForwardIterator __first, _Size __count)
243 template<
typename _ForwardIterator,
typename _Size>
244 _GLIBCXX20_CONSTEXPR
inline _ForwardIterator
249#if __cplusplus >= 201103L
252 "value type is destructible");
254#if __cpp_constexpr_dynamic_alloc
255 if (std::__is_constant_evaluated())
256 return std::_Destroy_n_aux<false>::__destroy_n(__first, __count);
258 return std::_Destroy_n_aux<__has_trivial_destructor(_Value_type)>::
259 __destroy_n(__first, __count);
262#if __glibcxx_raw_memory_algorithms
263 template <
typename _ForwardIterator>
264 _GLIBCXX20_CONSTEXPR
inline void
265 destroy(_ForwardIterator __first, _ForwardIterator __last)
270 template <
typename _ForwardIterator,
typename _Size>
271 _GLIBCXX20_CONSTEXPR
inline _ForwardIterator
272 destroy_n(_ForwardIterator __first, _Size __count)
278_GLIBCXX_END_NAMESPACE_VERSION
constexpr _Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
ISO C++ entities toplevel namespace is std.
constexpr _ForwardIterator _Destroy_n(_ForwardIterator __first, _Size __count)
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)
Traits class for iterators.