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>
109 { ::new(
static_cast<void*
>(__p)) _Tp(std::forward<_Args>(__args)...); }
111 template<
typename _T1,
typename _T2>
117 ::new(
static_cast<void*
>(__p)) _T1(__value);
121 template<
typename _T1>
123 _Construct_novalue(_T1* __p)
124 { ::new(
static_cast<void*
>(__p)) _T1; }
126 template<
typename _ForwardIterator>
127 _GLIBCXX20_CONSTEXPR
void
128 _Destroy(_ForwardIterator __first, _ForwardIterator __last);
133 template<
typename _Tp>
134 _GLIBCXX14_CONSTEXPR
inline void
137 #if __cplusplus > 201703L
138 std::destroy_at(__pointer);
147 template<
typename _ForwardIterator>
148 static _GLIBCXX20_CONSTEXPR
void
149 __destroy(_ForwardIterator __first, _ForwardIterator __last)
151 for (; __first != __last; ++__first)
157 struct _Destroy_aux<true>
159 template<
typename _ForwardIterator>
161 __destroy(_ForwardIterator, _ForwardIterator) { }
169 template<
typename _ForwardIterator>
170 _GLIBCXX20_CONSTEXPR
inline void
171 _Destroy(_ForwardIterator __first, _ForwardIterator __last)
175 #if __cplusplus >= 201103L
178 "value type is destructible");
180 #if __cplusplus > 201703L && defined __cpp_lib_is_constant_evaluated
181 if (std::is_constant_evaluated())
182 return _Destroy_aux<false>::__destroy(__first, __last);
184 std::_Destroy_aux<__has_trivial_destructor(_Value_type)>::
185 __destroy(__first, __last);
189 struct _Destroy_n_aux
191 template<
typename _ForwardIterator,
typename _Size>
192 static _GLIBCXX20_CONSTEXPR _ForwardIterator
193 __destroy_n(_ForwardIterator __first, _Size __count)
195 for (; __count > 0; (void)++__first, --__count)
202 struct _Destroy_n_aux<true>
204 template<
typename _ForwardIterator,
typename _Size>
205 static _ForwardIterator
206 __destroy_n(_ForwardIterator __first, _Size __count)
218 template<
typename _ForwardIterator,
typename _Size>
219 _GLIBCXX20_CONSTEXPR
inline _ForwardIterator
224 #if __cplusplus >= 201103L
227 "value type is destructible");
229 #if __cplusplus > 201703L && defined __cpp_lib_is_constant_evaluated
230 if (std::is_constant_evaluated())
231 return _Destroy_n_aux<false>::__destroy_n(__first, __count);
233 return std::_Destroy_n_aux<__has_trivial_destructor(_Value_type)>::
234 __destroy_n(__first, __count);
237 #if __cplusplus >= 201703L
238 template <
typename _ForwardIterator>
239 _GLIBCXX20_CONSTEXPR
inline void
240 destroy(_ForwardIterator __first, _ForwardIterator __last)
245 template <
typename _ForwardIterator,
typename _Size>
246 _GLIBCXX20_CONSTEXPR
inline _ForwardIterator
247 destroy_n(_ForwardIterator __first, _Size __count)
253 _GLIBCXX_END_NAMESPACE_VERSION
constexpr _Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
ISO C++ entities toplevel namespace is std.
void _Construct(_Tp *__p, _Args &&... __args)
constexpr _ForwardIterator _Destroy_n(_ForwardIterator __first, _Size __count)
constexpr void advance(_InputIterator &__i, _Distance __n)
A generalization of pointer arithmetic.
void _Destroy(_ForwardIterator __first, _ForwardIterator __last, _Allocator &__alloc)
Traits class for iterators.