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 >= 202002L
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>
111 #if __cplusplus >= 202002L
112 if (std::__is_constant_evaluated())
115 std::construct_at(__p, std::forward<_Args>(__args)...);
119 ::new((
void*)__p) _Tp(std::forward<_Args>(__args)...);
122 template<
typename _T1,
typename _T2>
128 ::new(
static_cast<void*
>(__p)) _T1(__value);
132 template<
typename _T1>
134 _Construct_novalue(_T1* __p)
135 { ::new((
void*)__p) _T1; }
137 template<
typename _ForwardIterator>
138 _GLIBCXX20_CONSTEXPR
void
139 _Destroy(_ForwardIterator __first, _ForwardIterator __last);
144 template<
typename _Tp>
145 _GLIBCXX14_CONSTEXPR
inline void
148 #if __cplusplus > 201703L
149 std::destroy_at(__pointer);
158 template<
typename _ForwardIterator>
159 static _GLIBCXX20_CONSTEXPR
void
160 __destroy(_ForwardIterator __first, _ForwardIterator __last)
162 for (; __first != __last; ++__first)
168 struct _Destroy_aux<true>
170 template<
typename _ForwardIterator>
172 __destroy(_ForwardIterator, _ForwardIterator) { }
180 template<
typename _ForwardIterator>
181 _GLIBCXX20_CONSTEXPR
inline void
182 _Destroy(_ForwardIterator __first, _ForwardIterator __last)
186 #if __cplusplus >= 201103L
189 "value type is destructible");
191 #if __cplusplus >= 202002L
192 if (std::__is_constant_evaluated())
193 return _Destroy_aux<false>::__destroy(__first, __last);
195 std::_Destroy_aux<__has_trivial_destructor(_Value_type)>::
196 __destroy(__first, __last);
200 struct _Destroy_n_aux
202 template<
typename _ForwardIterator,
typename _Size>
203 static _GLIBCXX20_CONSTEXPR _ForwardIterator
204 __destroy_n(_ForwardIterator __first, _Size __count)
206 for (; __count > 0; (void)++__first, --__count)
213 struct _Destroy_n_aux<true>
215 template<
typename _ForwardIterator,
typename _Size>
216 static _ForwardIterator
217 __destroy_n(_ForwardIterator __first, _Size __count)
229 template<
typename _ForwardIterator,
typename _Size>
230 _GLIBCXX20_CONSTEXPR
inline _ForwardIterator
235 #if __cplusplus >= 201103L
238 "value type is destructible");
240 #if __cplusplus >= 202002L
241 if (std::__is_constant_evaluated())
242 return _Destroy_n_aux<false>::__destroy_n(__first, __count);
244 return std::_Destroy_n_aux<__has_trivial_destructor(_Value_type)>::
245 __destroy_n(__first, __count);
248 #if __cplusplus >= 201703L
249 template <
typename _ForwardIterator>
250 _GLIBCXX20_CONSTEXPR
inline void
251 destroy(_ForwardIterator __first, _ForwardIterator __last)
256 template <
typename _ForwardIterator,
typename _Size>
257 _GLIBCXX20_CONSTEXPR
inline _ForwardIterator
258 destroy_n(_ForwardIterator __first, _Size __count)
264 _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, _Allocator &__alloc)
Traits class for iterators.