mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-10-04 13:41:02 +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
85
third_party/libcxx/__algorithm/search_n.h
vendored
85
third_party/libcxx/__algorithm/search_n.h
vendored
|
@ -31,12 +31,8 @@
|
|||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _AlgPolicy, class _Pred, class _Iter, class _Sent, class _SizeT, class _Type, class _Proj>
|
||||
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
|
||||
pair<_Iter, _Iter> __search_n_forward_impl(_Iter __first, _Sent __last,
|
||||
_SizeT __count,
|
||||
const _Type& __value,
|
||||
_Pred& __pred,
|
||||
_Proj& __proj) {
|
||||
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Iter, _Iter> __search_n_forward_impl(
|
||||
_Iter __first, _Sent __last, _SizeT __count, const _Type& __value, _Pred& __pred, _Proj& __proj) {
|
||||
if (__count <= 0)
|
||||
return std::make_pair(__first, __first);
|
||||
while (true) {
|
||||
|
@ -62,8 +58,7 @@ pair<_Iter, _Iter> __search_n_forward_impl(_Iter __first, _Sent __last,
|
|||
}
|
||||
|
||||
// if there is a mismatch, restart with a new __first
|
||||
if (!std::__invoke(__pred, std::__invoke(__proj, *__m), __value))
|
||||
{
|
||||
if (!std::__invoke(__pred, std::__invoke(__proj, *__m), __value)) {
|
||||
__first = __m;
|
||||
++__first;
|
||||
break;
|
||||
|
@ -73,13 +68,8 @@ pair<_Iter, _Iter> __search_n_forward_impl(_Iter __first, _Sent __last,
|
|||
}
|
||||
|
||||
template <class _AlgPolicy, class _Pred, class _Iter, class _Sent, class _SizeT, class _Type, class _Proj, class _DiffT>
|
||||
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
|
||||
std::pair<_Iter, _Iter> __search_n_random_access_impl(_Iter __first, _Sent __last,
|
||||
_SizeT __count,
|
||||
const _Type& __value,
|
||||
_Pred& __pred,
|
||||
_Proj& __proj,
|
||||
_DiffT __size1) {
|
||||
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 std::pair<_Iter, _Iter> __search_n_random_access_impl(
|
||||
_Iter __first, _Sent __last, _SizeT __count, const _Type& __value, _Pred& __pred, _Proj& __proj, _DiffT __size1) {
|
||||
using difference_type = typename iterator_traits<_Iter>::difference_type;
|
||||
if (__count == 0)
|
||||
return std::make_pair(__first, __first);
|
||||
|
@ -109,8 +99,7 @@ std::pair<_Iter, _Iter> __search_n_random_access_impl(_Iter __first, _Sent __las
|
|||
++__m; // no need to check range on __m because __s guarantees we have enough source
|
||||
|
||||
// if there is a mismatch, restart with a new __first
|
||||
if (!std::__invoke(__pred, std::__invoke(__proj, *__m), __value))
|
||||
{
|
||||
if (!std::__invoke(__pred, std::__invoke(__proj, *__m), __value)) {
|
||||
__first = __m;
|
||||
++__first;
|
||||
break;
|
||||
|
@ -119,61 +108,45 @@ std::pair<_Iter, _Iter> __search_n_random_access_impl(_Iter __first, _Sent __las
|
|||
}
|
||||
}
|
||||
|
||||
template <class _Iter, class _Sent,
|
||||
template <class _Iter,
|
||||
class _Sent,
|
||||
class _DiffT,
|
||||
class _Type,
|
||||
class _Pred,
|
||||
class _Proj>
|
||||
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
|
||||
pair<_Iter, _Iter> __search_n_impl(_Iter __first, _Sent __last,
|
||||
_DiffT __count,
|
||||
const _Type& __value,
|
||||
_Pred& __pred,
|
||||
_Proj& __proj,
|
||||
__enable_if_t<__has_random_access_iterator_category<_Iter>::value>* = nullptr) {
|
||||
return std::__search_n_random_access_impl<_ClassicAlgPolicy>(__first, __last,
|
||||
__count,
|
||||
__value,
|
||||
__pred,
|
||||
__proj,
|
||||
__last - __first);
|
||||
class _Proj,
|
||||
__enable_if_t<__has_random_access_iterator_category<_Iter>::value, int> = 0>
|
||||
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Iter, _Iter>
|
||||
__search_n_impl(_Iter __first, _Sent __last, _DiffT __count, const _Type& __value, _Pred& __pred, _Proj& __proj) {
|
||||
return std::__search_n_random_access_impl<_ClassicAlgPolicy>(
|
||||
__first, __last, __count, __value, __pred, __proj, __last - __first);
|
||||
}
|
||||
|
||||
template <class _Iter1, class _Sent1,
|
||||
template <class _Iter1,
|
||||
class _Sent1,
|
||||
class _DiffT,
|
||||
class _Type,
|
||||
class _Pred,
|
||||
class _Proj>
|
||||
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
|
||||
pair<_Iter1, _Iter1> __search_n_impl(_Iter1 __first, _Sent1 __last,
|
||||
_DiffT __count,
|
||||
const _Type& __value,
|
||||
_Pred& __pred,
|
||||
_Proj& __proj,
|
||||
__enable_if_t<__has_forward_iterator_category<_Iter1>::value
|
||||
&& !__has_random_access_iterator_category<_Iter1>::value>* = nullptr) {
|
||||
return std::__search_n_forward_impl<_ClassicAlgPolicy>(__first, __last,
|
||||
__count,
|
||||
__value,
|
||||
__pred,
|
||||
__proj);
|
||||
class _Proj,
|
||||
__enable_if_t<__has_forward_iterator_category<_Iter1>::value &&
|
||||
!__has_random_access_iterator_category<_Iter1>::value,
|
||||
int> = 0>
|
||||
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Iter1, _Iter1>
|
||||
__search_n_impl(_Iter1 __first, _Sent1 __last, _DiffT __count, const _Type& __value, _Pred& __pred, _Proj& __proj) {
|
||||
return std::__search_n_forward_impl<_ClassicAlgPolicy>(__first, __last, __count, __value, __pred, __proj);
|
||||
}
|
||||
|
||||
template <class _ForwardIterator, class _Size, class _Tp, class _BinaryPredicate>
|
||||
_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
|
||||
_ForwardIterator search_n(_ForwardIterator __first, _ForwardIterator __last,
|
||||
_Size __count,
|
||||
const _Tp& __value,
|
||||
_BinaryPredicate __pred) {
|
||||
static_assert(__is_callable<_BinaryPredicate, decltype(*__first), const _Tp&>::value,
|
||||
"BinaryPredicate has to be callable");
|
||||
_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator search_n(
|
||||
_ForwardIterator __first, _ForwardIterator __last, _Size __count, const _Tp& __value, _BinaryPredicate __pred) {
|
||||
static_assert(
|
||||
__is_callable<_BinaryPredicate, decltype(*__first), const _Tp&>::value, "BinaryPredicate has to be callable");
|
||||
auto __proj = __identity();
|
||||
return std::__search_n_impl(__first, __last, std::__convert_to_integral(__count), __value, __pred, __proj).first;
|
||||
}
|
||||
|
||||
template <class _ForwardIterator, class _Size, class _Tp>
|
||||
_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
|
||||
_ForwardIterator search_n(_ForwardIterator __first, _ForwardIterator __last, _Size __count, const _Tp& __value) {
|
||||
_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
|
||||
search_n(_ForwardIterator __first, _ForwardIterator __last, _Size __count, const _Tp& __value) {
|
||||
return std::search_n(__first, __last, std::__convert_to_integral(__count), __value, __equal_to());
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue