mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-03 03:02:28 +00:00
Release Cosmopolitan v3.6.0
This release is an atomic upgrade to GCC 14.1.0 with C23 and C++23
This commit is contained in:
parent
62ace3623a
commit
5660ec4741
1585 changed files with 117353 additions and 271644 deletions
86
third_party/libcxx/__memory/construct_at.h
vendored
86
third_party/libcxx/__memory/construct_at.h
vendored
|
@ -26,6 +26,9 @@
|
|||
# pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
// construct_at
|
||||
|
@ -34,18 +37,18 @@ _LIBCPP_BEGIN_NAMESPACE_STD
|
|||
|
||||
template <class _Tp, class... _Args, class = decltype(::new(std::declval<void*>()) _Tp(std::declval<_Args>()...))>
|
||||
_LIBCPP_HIDE_FROM_ABI constexpr _Tp* construct_at(_Tp* __location, _Args&&... __args) {
|
||||
_LIBCPP_ASSERT(__location != nullptr, "null pointer given to construct_at");
|
||||
_LIBCPP_ASSERT_NON_NULL(__location != nullptr, "null pointer given to construct_at");
|
||||
return ::new (std::__voidify(*__location)) _Tp(std::forward<_Args>(__args)...);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
template <class _Tp, class... _Args, class = decltype(::new(std::declval<void*>()) _Tp(std::declval<_Args>()...))>
|
||||
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp* __construct_at(_Tp* __location, _Args&&... __args) {
|
||||
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp* __construct_at(_Tp* __location, _Args&&... __args) {
|
||||
#if _LIBCPP_STD_VER >= 20
|
||||
return std::construct_at(__location, std::forward<_Args>(__args)...);
|
||||
#else
|
||||
return _LIBCPP_ASSERT(__location != nullptr, "null pointer given to construct_at"),
|
||||
return _LIBCPP_ASSERT_NON_NULL(__location != nullptr, "null pointer given to construct_at"),
|
||||
::new (std::__voidify(*__location)) _Tp(std::forward<_Args>(__args)...);
|
||||
#endif
|
||||
}
|
||||
|
@ -56,75 +59,70 @@ _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, typename enable_if<!is_array<_Tp>::value, int>::type = 0>
|
||||
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
|
||||
void __destroy_at(_Tp* __loc) {
|
||||
_LIBCPP_ASSERT(__loc != nullptr, "null pointer given to destroy_at");
|
||||
__loc->~_Tp();
|
||||
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();
|
||||
}
|
||||
|
||||
#if _LIBCPP_STD_VER >= 20
|
||||
template <class _Tp, typename enable_if<is_array<_Tp>::value, int>::type = 0>
|
||||
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
|
||||
void __destroy_at(_Tp* __loc) {
|
||||
_LIBCPP_ASSERT(__loc != nullptr, "null pointer given to destroy_at");
|
||||
std::__destroy(std::begin(*__loc), std::end(*__loc));
|
||||
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));
|
||||
}
|
||||
#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);
|
||||
}
|
||||
|
||||
#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
|
||||
|
||||
# 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) {
|
||||
std::__destroy_at(__loc);
|
||||
}
|
||||
# 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
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___MEMORY_CONSTRUCT_AT_H
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue