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
111
third_party/libcxx/__ranges/view_interface.h
vendored
111
third_party/libcxx/__ranges/view_interface.h
vendored
|
@ -21,6 +21,7 @@
|
|||
#include <__ranges/access.h>
|
||||
#include <__ranges/concepts.h>
|
||||
#include <__ranges/empty.h>
|
||||
#include <__ranges/size.h>
|
||||
#include <__type_traits/is_class.h>
|
||||
#include <__type_traits/make_unsigned.h>
|
||||
#include <__type_traits/remove_cv.h>
|
||||
|
@ -35,135 +36,127 @@ _LIBCPP_BEGIN_NAMESPACE_STD
|
|||
|
||||
namespace ranges {
|
||||
|
||||
template<class _Derived>
|
||||
template <class _Derived>
|
||||
requires is_class_v<_Derived> && same_as<_Derived, remove_cv_t<_Derived>>
|
||||
class view_interface {
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
constexpr _Derived& __derived() noexcept {
|
||||
_LIBCPP_HIDE_FROM_ABI constexpr _Derived& __derived() noexcept {
|
||||
static_assert(sizeof(_Derived) && derived_from<_Derived, view_interface> && view<_Derived>);
|
||||
return static_cast<_Derived&>(*this);
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
constexpr _Derived const& __derived() const noexcept {
|
||||
_LIBCPP_HIDE_FROM_ABI constexpr _Derived const& __derived() const noexcept {
|
||||
static_assert(sizeof(_Derived) && derived_from<_Derived, view_interface> && view<_Derived>);
|
||||
return static_cast<_Derived const&>(*this);
|
||||
}
|
||||
|
||||
public:
|
||||
template<class _D2 = _Derived>
|
||||
template <class _D2 = _Derived>
|
||||
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool empty()
|
||||
requires forward_range<_D2>
|
||||
requires sized_range<_D2> || forward_range<_D2>
|
||||
{
|
||||
return ranges::begin(__derived()) == ranges::end(__derived());
|
||||
if constexpr (sized_range<_D2>) {
|
||||
return ranges::size(__derived()) == 0;
|
||||
} else {
|
||||
return ranges::begin(__derived()) == ranges::end(__derived());
|
||||
}
|
||||
}
|
||||
|
||||
template<class _D2 = _Derived>
|
||||
template <class _D2 = _Derived>
|
||||
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool empty() const
|
||||
requires forward_range<const _D2>
|
||||
requires sized_range<const _D2> || forward_range<const _D2>
|
||||
{
|
||||
return ranges::begin(__derived()) == ranges::end(__derived());
|
||||
if constexpr (sized_range<const _D2>) {
|
||||
return ranges::size(__derived()) == 0;
|
||||
} else {
|
||||
return ranges::begin(__derived()) == ranges::end(__derived());
|
||||
}
|
||||
}
|
||||
|
||||
template<class _D2 = _Derived>
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
constexpr explicit operator bool()
|
||||
requires requires (_D2& __t) { ranges::empty(__t); }
|
||||
template <class _D2 = _Derived>
|
||||
_LIBCPP_HIDE_FROM_ABI constexpr explicit operator bool()
|
||||
requires requires(_D2& __t) { ranges::empty(__t); }
|
||||
{
|
||||
return !ranges::empty(__derived());
|
||||
}
|
||||
|
||||
template<class _D2 = _Derived>
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
constexpr explicit operator bool() const
|
||||
requires requires (const _D2& __t) { ranges::empty(__t); }
|
||||
template <class _D2 = _Derived>
|
||||
_LIBCPP_HIDE_FROM_ABI constexpr explicit operator bool() const
|
||||
requires requires(const _D2& __t) { ranges::empty(__t); }
|
||||
{
|
||||
return !ranges::empty(__derived());
|
||||
}
|
||||
|
||||
template<class _D2 = _Derived>
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
constexpr auto data()
|
||||
template <class _D2 = _Derived>
|
||||
_LIBCPP_HIDE_FROM_ABI constexpr auto data()
|
||||
requires contiguous_iterator<iterator_t<_D2>>
|
||||
{
|
||||
return std::to_address(ranges::begin(__derived()));
|
||||
}
|
||||
|
||||
template<class _D2 = _Derived>
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
constexpr auto data() const
|
||||
template <class _D2 = _Derived>
|
||||
_LIBCPP_HIDE_FROM_ABI constexpr auto data() const
|
||||
requires range<const _D2> && contiguous_iterator<iterator_t<const _D2>>
|
||||
{
|
||||
return std::to_address(ranges::begin(__derived()));
|
||||
}
|
||||
|
||||
template<class _D2 = _Derived>
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
constexpr auto size()
|
||||
template <class _D2 = _Derived>
|
||||
_LIBCPP_HIDE_FROM_ABI constexpr auto size()
|
||||
requires forward_range<_D2> && sized_sentinel_for<sentinel_t<_D2>, iterator_t<_D2>>
|
||||
{
|
||||
return std::__to_unsigned_like(ranges::end(__derived()) - ranges::begin(__derived()));
|
||||
}
|
||||
|
||||
template<class _D2 = _Derived>
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
constexpr auto size() const
|
||||
template <class _D2 = _Derived>
|
||||
_LIBCPP_HIDE_FROM_ABI constexpr auto size() const
|
||||
requires forward_range<const _D2> && sized_sentinel_for<sentinel_t<const _D2>, iterator_t<const _D2>>
|
||||
{
|
||||
return std::__to_unsigned_like(ranges::end(__derived()) - ranges::begin(__derived()));
|
||||
}
|
||||
|
||||
template<class _D2 = _Derived>
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
constexpr decltype(auto) front()
|
||||
template <class _D2 = _Derived>
|
||||
_LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) front()
|
||||
requires forward_range<_D2>
|
||||
{
|
||||
_LIBCPP_ASSERT(!empty(),
|
||||
"Precondition `!empty()` not satisfied. `.front()` called on an empty view.");
|
||||
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
|
||||
!empty(), "Precondition `!empty()` not satisfied. `.front()` called on an empty view.");
|
||||
return *ranges::begin(__derived());
|
||||
}
|
||||
|
||||
template<class _D2 = _Derived>
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
constexpr decltype(auto) front() const
|
||||
template <class _D2 = _Derived>
|
||||
_LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) front() const
|
||||
requires forward_range<const _D2>
|
||||
{
|
||||
_LIBCPP_ASSERT(!empty(),
|
||||
"Precondition `!empty()` not satisfied. `.front()` called on an empty view.");
|
||||
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
|
||||
!empty(), "Precondition `!empty()` not satisfied. `.front()` called on an empty view.");
|
||||
return *ranges::begin(__derived());
|
||||
}
|
||||
|
||||
template<class _D2 = _Derived>
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
constexpr decltype(auto) back()
|
||||
template <class _D2 = _Derived>
|
||||
_LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) back()
|
||||
requires bidirectional_range<_D2> && common_range<_D2>
|
||||
{
|
||||
_LIBCPP_ASSERT(!empty(),
|
||||
"Precondition `!empty()` not satisfied. `.back()` called on an empty view.");
|
||||
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
|
||||
!empty(), "Precondition `!empty()` not satisfied. `.back()` called on an empty view.");
|
||||
return *ranges::prev(ranges::end(__derived()));
|
||||
}
|
||||
|
||||
template<class _D2 = _Derived>
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
constexpr decltype(auto) back() const
|
||||
template <class _D2 = _Derived>
|
||||
_LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) back() const
|
||||
requires bidirectional_range<const _D2> && common_range<const _D2>
|
||||
{
|
||||
_LIBCPP_ASSERT(!empty(),
|
||||
"Precondition `!empty()` not satisfied. `.back()` called on an empty view.");
|
||||
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
|
||||
!empty(), "Precondition `!empty()` not satisfied. `.back()` called on an empty view.");
|
||||
return *ranges::prev(ranges::end(__derived()));
|
||||
}
|
||||
|
||||
template<random_access_range _RARange = _Derived>
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
constexpr decltype(auto) operator[](range_difference_t<_RARange> __index)
|
||||
{
|
||||
template <random_access_range _RARange = _Derived>
|
||||
_LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator[](range_difference_t<_RARange> __index) {
|
||||
return ranges::begin(__derived())[__index];
|
||||
}
|
||||
|
||||
template<random_access_range _RARange = const _Derived>
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
constexpr decltype(auto) operator[](range_difference_t<_RARange> __index) const
|
||||
{
|
||||
template <random_access_range _RARange = const _Derived>
|
||||
_LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator[](range_difference_t<_RARange> __index) const {
|
||||
return ranges::begin(__derived())[__index];
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue