56 #ifndef _STL_CONSTRUCT_H
57 #define _STL_CONSTRUCT_H 1
73 namespace std _GLIBCXX_VISIBILITY(default)
75 _GLIBCXX_BEGIN_NAMESPACE_VERSION
77 #if __cplusplus >= 201703L
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 __cplusplus > 201703L
92 template<
typename _Tp,
typename... _Args>
94 construct_at(_Tp* __location, _Args&&... __args)
95 noexcept(noexcept(::
new((
void*)0) _Tp(std::declval<_Args>()...)))
96 -> decltype(::
new((
void*)0) _Tp(std::declval<_Args>()...))
97 { return ::new((
void*)__location) _Tp(std::forward<_Args>(__args)...); }
105 #if __cplusplus >= 201103L
106 template<
typename _Tp,
typename... _Args>
110 #if __cplusplus > 201703L
111 return std::construct_at(__p, std::forward<_Args>(__args)...);
113 return ::new(
static_cast<void*
>(__p)) _Tp(std::forward<_Args>(__args)...);
117 template<
typename _T1,
typename _T2>
123 return ::new(
static_cast<void*
>(__p)) _T1(__value);
127 template<
typename _T1>
129 _Construct_novalue(_T1* __p)
130 { ::new(
static_cast<void*
>(__p)) _T1; }
132 template<
typename _ForwardIterator>
133 _GLIBCXX20_CONSTEXPR
void
134 _Destroy(_ForwardIterator __first, _ForwardIterator __last);
139 template<
typename _Tp>
140 _GLIBCXX14_CONSTEXPR
inline void
143 #if __cplusplus > 201703L
144 std::destroy_at(__pointer);
153 template<
typename _ForwardIterator>
154 static _GLIBCXX20_CONSTEXPR
void
155 __destroy(_ForwardIterator __first, _ForwardIterator __last)
157 for (; __first != __last; ++__first)
163 struct _Destroy_aux<true>
165 template<
typename _ForwardIterator>
167 __destroy(_ForwardIterator, _ForwardIterator) { }
175 template<
typename _ForwardIterator>
176 _GLIBCXX20_CONSTEXPR
inline void
177 _Destroy(_ForwardIterator __first, _ForwardIterator __last)
181 #if __cplusplus >= 201103L
184 "value type is destructible");
186 #if __cplusplus > 201703L && defined __cpp_lib_is_constant_evaluated
187 if (std::is_constant_evaluated())
188 return _Destroy_aux<false>::__destroy(__first, __last);
190 std::_Destroy_aux<__has_trivial_destructor(_Value_type)>::
191 __destroy(__first, __last);
195 struct _Destroy_n_aux
197 template<
typename _ForwardIterator,
typename _Size>
198 static _GLIBCXX20_CONSTEXPR _ForwardIterator
199 __destroy_n(_ForwardIterator __first, _Size __count)
201 for (; __count > 0; (void)++__first, --__count)
208 struct _Destroy_n_aux<true>
210 template<
typename _ForwardIterator,
typename _Size>
211 static _ForwardIterator
212 __destroy_n(_ForwardIterator __first, _Size __count)
224 template<
typename _ForwardIterator,
typename _Size>
225 _GLIBCXX20_CONSTEXPR
inline _ForwardIterator
230 #if __cplusplus >= 201103L
233 "value type is destructible");
235 #if __cplusplus > 201703L && defined __cpp_lib_is_constant_evaluated
236 if (std::is_constant_evaluated())
237 return _Destroy_n_aux<false>::__destroy_n(__first, __count);
239 return std::_Destroy_n_aux<__has_trivial_destructor(_Value_type)>::
240 __destroy_n(__first, __count);
243 #if __cplusplus >= 201703L
244 template <
typename _ForwardIterator>
245 _GLIBCXX20_CONSTEXPR
inline void
246 destroy(_ForwardIterator __first, _ForwardIterator __last)
251 template <
typename _ForwardIterator,
typename _Size>
252 _GLIBCXX20_CONSTEXPR
inline _ForwardIterator
253 destroy_n(_ForwardIterator __first, _Size __count)
259 _GLIBCXX_END_NAMESPACE_VERSION