mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-03 19:22:27 +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
49
third_party/libcxx/__iterator/distance.h
vendored
49
third_party/libcxx/__iterator/distance.h
vendored
|
@ -27,30 +27,24 @@
|
|||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _InputIter>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
|
||||
typename iterator_traits<_InputIter>::difference_type
|
||||
__distance(_InputIter __first, _InputIter __last, input_iterator_tag)
|
||||
{
|
||||
typename iterator_traits<_InputIter>::difference_type __r(0);
|
||||
for (; __first != __last; ++__first)
|
||||
++__r;
|
||||
return __r;
|
||||
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 typename iterator_traits<_InputIter>::difference_type
|
||||
__distance(_InputIter __first, _InputIter __last, input_iterator_tag) {
|
||||
typename iterator_traits<_InputIter>::difference_type __r(0);
|
||||
for (; __first != __last; ++__first)
|
||||
++__r;
|
||||
return __r;
|
||||
}
|
||||
|
||||
template <class _RandIter>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
|
||||
typename iterator_traits<_RandIter>::difference_type
|
||||
__distance(_RandIter __first, _RandIter __last, random_access_iterator_tag)
|
||||
{
|
||||
return __last - __first;
|
||||
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 typename iterator_traits<_RandIter>::difference_type
|
||||
__distance(_RandIter __first, _RandIter __last, random_access_iterator_tag) {
|
||||
return __last - __first;
|
||||
}
|
||||
|
||||
template <class _InputIter>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
|
||||
typename iterator_traits<_InputIter>::difference_type
|
||||
distance(_InputIter __first, _InputIter __last)
|
||||
{
|
||||
return _VSTD::__distance(__first, __last, typename iterator_traits<_InputIter>::iterator_category());
|
||||
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 typename iterator_traits<_InputIter>::difference_type
|
||||
distance(_InputIter __first, _InputIter __last) {
|
||||
return std::__distance(__first, __last, typename iterator_traits<_InputIter>::iterator_category());
|
||||
}
|
||||
|
||||
#if _LIBCPP_STD_VER >= 20
|
||||
|
@ -61,10 +55,9 @@ namespace ranges {
|
|||
namespace __distance {
|
||||
|
||||
struct __fn {
|
||||
template<class _Ip, sentinel_for<_Ip> _Sp>
|
||||
requires (!sized_sentinel_for<_Sp, _Ip>)
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
constexpr iter_difference_t<_Ip> operator()(_Ip __first, _Sp __last) const {
|
||||
template <class _Ip, sentinel_for<_Ip> _Sp>
|
||||
requires(!sized_sentinel_for<_Sp, _Ip>)
|
||||
_LIBCPP_HIDE_FROM_ABI constexpr iter_difference_t<_Ip> operator()(_Ip __first, _Sp __last) const {
|
||||
iter_difference_t<_Ip> __n = 0;
|
||||
while (__first != __last) {
|
||||
++__first;
|
||||
|
@ -73,9 +66,8 @@ struct __fn {
|
|||
return __n;
|
||||
}
|
||||
|
||||
template<class _Ip, sized_sentinel_for<decay_t<_Ip>> _Sp>
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
constexpr iter_difference_t<_Ip> operator()(_Ip&& __first, _Sp __last) const {
|
||||
template <class _Ip, sized_sentinel_for<decay_t<_Ip>> _Sp>
|
||||
_LIBCPP_HIDE_FROM_ABI constexpr iter_difference_t<_Ip> operator()(_Ip&& __first, _Sp __last) const {
|
||||
if constexpr (sized_sentinel_for<_Sp, __remove_cvref_t<_Ip>>) {
|
||||
return __last - __first;
|
||||
} else {
|
||||
|
@ -83,9 +75,8 @@ struct __fn {
|
|||
}
|
||||
}
|
||||
|
||||
template<range _Rp>
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
constexpr range_difference_t<_Rp> operator()(_Rp&& __r) const {
|
||||
template <range _Rp>
|
||||
_LIBCPP_HIDE_FROM_ABI constexpr range_difference_t<_Rp> operator()(_Rp&& __r) const {
|
||||
if constexpr (sized_range<_Rp>) {
|
||||
return static_cast<range_difference_t<_Rp>>(ranges::size(__r));
|
||||
} else {
|
||||
|
@ -97,7 +88,7 @@ struct __fn {
|
|||
} // namespace __distance
|
||||
|
||||
inline namespace __cpo {
|
||||
inline constexpr auto distance = __distance::__fn{};
|
||||
inline constexpr auto distance = __distance::__fn{};
|
||||
} // namespace __cpo
|
||||
} // namespace ranges
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue