diff options
Diffstat (limited to 'contrib/llvm-project/libcxx/include/__memory/construct_at.h')
-rw-r--r-- | contrib/llvm-project/libcxx/include/__memory/construct_at.h | 65 |
1 files changed, 29 insertions, 36 deletions
diff --git a/contrib/llvm-project/libcxx/include/__memory/construct_at.h b/contrib/llvm-project/libcxx/include/__memory/construct_at.h index 6797a3862973..91d17134db01 100644 --- a/contrib/llvm-project/libcxx/include/__memory/construct_at.h +++ b/contrib/llvm-project/libcxx/include/__memory/construct_at.h @@ -59,71 +59,64 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp* __construct_at(_Tp* __location, _Ar // taking an array). template <class _ForwardIterator> -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 -_ForwardIterator __destroy(_ForwardIterator, _ForwardIterator); +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator __destroy(_ForwardIterator, _ForwardIterator); template <class _Tp, __enable_if_t<!is_array<_Tp>::value, int> = 0> -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 -void __destroy_at(_Tp* __loc) { - _LIBCPP_ASSERT_NON_NULL(__loc != nullptr, "null pointer given to destroy_at"); - __loc->~_Tp(); +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __destroy_at(_Tp* __loc) { + _LIBCPP_ASSERT_NON_NULL(__loc != nullptr, "null pointer given to destroy_at"); + __loc->~_Tp(); } #if _LIBCPP_STD_VER >= 20 template <class _Tp, __enable_if_t<is_array<_Tp>::value, int> = 0> -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 -void __destroy_at(_Tp* __loc) { - _LIBCPP_ASSERT_NON_NULL(__loc != nullptr, "null pointer given to destroy_at"); - std::__destroy(std::begin(*__loc), std::end(*__loc)); +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __destroy_at(_Tp* __loc) { + _LIBCPP_ASSERT_NON_NULL(__loc != nullptr, "null pointer given to destroy_at"); + std::__destroy(std::begin(*__loc), std::end(*__loc)); } #endif template <class _ForwardIterator> -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 -_ForwardIterator __destroy(_ForwardIterator __first, _ForwardIterator __last) { - for (; __first != __last; ++__first) - std::__destroy_at(std::addressof(*__first)); - return __first; +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator +__destroy(_ForwardIterator __first, _ForwardIterator __last) { + for (; __first != __last; ++__first) + std::__destroy_at(std::addressof(*__first)); + return __first; } template <class _BidirectionalIterator> -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 -_BidirectionalIterator __reverse_destroy(_BidirectionalIterator __first, _BidirectionalIterator __last) { - while (__last != __first) { - --__last; - std::__destroy_at(std::addressof(*__last)); - } - return __last; +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _BidirectionalIterator +__reverse_destroy(_BidirectionalIterator __first, _BidirectionalIterator __last) { + while (__last != __first) { + --__last; + std::__destroy_at(std::addressof(*__last)); + } + return __last; } #if _LIBCPP_STD_VER >= 17 template <class _Tp, enable_if_t<!is_array_v<_Tp>, int> = 0> -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 -void destroy_at(_Tp* __loc) { - std::__destroy_at(__loc); +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void destroy_at(_Tp* __loc) { + std::__destroy_at(__loc); } -#if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 template <class _Tp, enable_if_t<is_array_v<_Tp>, int> = 0> -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 -void destroy_at(_Tp* __loc) { +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void destroy_at(_Tp* __loc) { std::__destroy_at(__loc); } -#endif +# endif template <class _ForwardIterator> -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 -void destroy(_ForwardIterator __first, _ForwardIterator __last) { +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void destroy(_ForwardIterator __first, _ForwardIterator __last) { (void)std::__destroy(std::move(__first), std::move(__last)); } template <class _ForwardIterator, class _Size> -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 -_ForwardIterator destroy_n(_ForwardIterator __first, _Size __n) { - for (; __n > 0; (void)++__first, --__n) - std::__destroy_at(std::addressof(*__first)); - return __first; +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator destroy_n(_ForwardIterator __first, _Size __n) { + for (; __n > 0; (void)++__first, --__n) + std::__destroy_at(std::addressof(*__first)); + return __first; } #endif // _LIBCPP_STD_VER >= 17 |