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>)
96 construct_at(_Tp* __location, _Args&&... __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]();
119#if __cplusplus >= 201103L
120 template<
typename _Tp,
typename... _Args>
125#if __cpp_constexpr_dynamic_alloc
126 if (std::is_constant_evaluated())
136 template<
typename _T1,
typename _T2>
142 ::new(
static_cast<void*
>(__p)) _T1(__value);
146 template<
typename _T1>
149 _Construct_novalue(_T1* __p)
150 { ::new(
static_cast<void*
>(__p)) _T1; }
152 template<
typename _ForwardIterator>
153 _GLIBCXX20_CONSTEXPR
void
154 _Destroy(_ForwardIterator __first, _ForwardIterator __last);
159 template<
typename _Tp>
160 _GLIBCXX14_CONSTEXPR
inline void
163#if __cpp_constexpr_dynamic_alloc
164 std::destroy_at(__pointer);
170#pragma GCC diagnostic push
171#pragma GCC diagnostic ignored "-Wc++17-extensions"
173#if __cplusplus < 201103L
177 template<
typename _ForwardIterator>
178 static _GLIBCXX20_CONSTEXPR
void
179 __destroy(_ForwardIterator __first, _ForwardIterator __last)
181 for (; __first != __last; ++__first)
185 template<
typename _ForwardIterator,
typename _Size>
186 static _GLIBCXX20_CONSTEXPR _ForwardIterator
187 __destroy_n(_ForwardIterator __first, _Size __count)
189 for (; __count > 0; (void)++__first, --__count)
196 struct _Destroy_aux<true>
198 template<
typename _ForwardIterator>
200 __destroy(_ForwardIterator, _ForwardIterator) { }
202 template<
typename _ForwardIterator,
typename _Size>
203 static _ForwardIterator
204 __destroy_n(_ForwardIterator __first, _Size __count)
217 template<
typename _ForwardIterator>
218 _GLIBCXX20_CONSTEXPR
inline void
219 _Destroy(_ForwardIterator __first, _ForwardIterator __last)
223#if __cplusplus >= 201103L
225 for (; __first != __last; ++__first)
227#if __cpp_constexpr_dynamic_alloc
228 else if (std::is_constant_evaluated())
229 for (; __first != __last; ++__first)
233 std::_Destroy_aux<__has_trivial_destructor(_Value_type)>::
234 __destroy(__first, __last);
243 template<
typename _ForwardIterator,
typename _Size>
244 _GLIBCXX20_CONSTEXPR
inline _ForwardIterator
249#if __cplusplus >= 201103L
251 for (; __count > 0; (void)++__first, --__count)
253#if __cpp_constexpr_dynamic_alloc
254 else if (std::is_constant_evaluated())
255 for (; __count > 0; (void)++__first, --__count)
262 return std::_Destroy_aux<__has_trivial_destructor(_Value_type)>::
263 __destroy_n(__first, __count);
266#pragma GCC diagnostic pop
268#if __glibcxx_raw_memory_algorithms
269 template <
typename _ForwardIterator>
270 _GLIBCXX20_CONSTEXPR
inline void
271 destroy(_ForwardIterator __first, _ForwardIterator __last)
276 template <
typename _ForwardIterator,
typename _Size>
277 _GLIBCXX20_CONSTEXPR
inline _ForwardIterator
278 destroy_n(_ForwardIterator __first, _Size __count)
284_GLIBCXX_END_NAMESPACE_VERSION
auto declval() noexcept -> decltype(__declval< _Tp >(0))
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 _Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
constexpr _Tp && forward(typename std::remove_reference< _Tp >::type &__t) noexcept
Forward an lvalue.
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)
is_trivially_destructible
Traits class for iterators.