#endif
}
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wc++17-extensions" // for if-constexpr
+
+#if __cplusplus < 201103L
template<bool>
struct _Destroy_aux
{
static void
__destroy(_ForwardIterator, _ForwardIterator) { }
};
+#endif
/**
* Destroy a range of objects. If the value_type of the object has
// A deleted destructor is trivial, this ensures we reject such types:
static_assert(is_destructible<_Value_type>::value,
"value type is destructible");
-#endif
+ if constexpr (!__has_trivial_destructor(_Value_type))
+ for (; __first != __last; ++__first)
+ std::_Destroy(std::__addressof(*__first));
#if __cpp_constexpr_dynamic_alloc // >= C++20
- if (std::__is_constant_evaluated())
- return std::_Destroy_aux<false>::__destroy(__first, __last);
+ else if (std::__is_constant_evaluated())
+ for (; __first != __last; ++__first)
+ std::destroy_at(std::__addressof(*__first));
#endif
+#else
std::_Destroy_aux<__has_trivial_destructor(_Value_type)>::
__destroy(__first, __last);
+#endif
}
+#if __cplusplus < 201103L
template<bool>
struct _Destroy_n_aux
{
return __first;
}
};
+#endif
/**
* Destroy a range of objects. If the value_type of the object has
// A deleted destructor is trivial, this ensures we reject such types:
static_assert(is_destructible<_Value_type>::value,
"value type is destructible");
-#endif
+ if constexpr (!__has_trivial_destructor(_Value_type))
+ for (; __count > 0; (void)++__first, --__count)
+ std::_Destroy(std::__addressof(*__first));
#if __cpp_constexpr_dynamic_alloc // >= C++20
- if (std::__is_constant_evaluated())
- return std::_Destroy_n_aux<false>::__destroy_n(__first, __count);
+ else if (std::__is_constant_evaluated())
+ for (; __count > 0; (void)++__first, --__count)
+ std::destroy_at(std::__addressof(*__first));
#endif
+ else
+ std::advance(__first, __count);
+ return __first;
+#else
return std::_Destroy_n_aux<__has_trivial_destructor(_Value_type)>::
__destroy_n(__first, __count);
+#endif
}
+#pragma GCC diagnostic pop
#if __glibcxx_raw_memory_algorithms // >= C++17
template <typename _ForwardIterator>