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:
Justine Tunney 2024-07-23 03:16:17 -07:00
parent 62ace3623a
commit 5660ec4741
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
1585 changed files with 117353 additions and 271644 deletions

View file

@ -47,79 +47,82 @@
# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
#include <__undef_macros>
_LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER >= 20
namespace ranges {
template <auto> struct __require_constant;
template <auto>
struct __require_constant;
template <class _Range>
concept __tiny_range =
sized_range<_Range> &&
requires { typename __require_constant<remove_reference_t<_Range>::size()>; } &&
(remove_reference_t<_Range>::size() <= 1);
concept __tiny_range = sized_range<_Range> && requires {
typename __require_constant<remove_reference_t<_Range>::size()>;
} && (remove_reference_t<_Range>::size() <= 1);
template <input_range _View, forward_range _Pattern>
requires view<_View> && view<_Pattern> &&
indirectly_comparable<iterator_t<_View>, iterator_t<_Pattern>, ranges::equal_to> &&
(forward_range<_View> || __tiny_range<_Pattern>)
class lazy_split_view : public view_interface<lazy_split_view<_View, _Pattern>> {
_LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View();
_LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View();
_LIBCPP_NO_UNIQUE_ADDRESS _Pattern __pattern_ = _Pattern();
using _MaybeCurrent = _If<!forward_range<_View>, __non_propagating_cache<iterator_t<_View>>, __empty_cache>;
_LIBCPP_NO_UNIQUE_ADDRESS _MaybeCurrent __current_ = _MaybeCurrent();
template <bool> struct __outer_iterator;
template <bool> struct __inner_iterator;
template <bool>
struct __outer_iterator;
template <bool>
struct __inner_iterator;
public:
_LIBCPP_HIDE_FROM_ABI
lazy_split_view()
requires default_initializable<_View> && default_initializable<_Pattern> = default;
_LIBCPP_HIDE_FROM_ABI lazy_split_view()
requires default_initializable<_View> && default_initializable<_Pattern>
= default;
_LIBCPP_HIDE_FROM_ABI
constexpr _LIBCPP_EXPLICIT_SINCE_CXX23 lazy_split_view(_View __base, _Pattern __pattern)
: __base_(std::move(__base)), __pattern_(std::move(__pattern)) {}
_LIBCPP_HIDE_FROM_ABI constexpr _LIBCPP_EXPLICIT_SINCE_CXX23 lazy_split_view(_View __base, _Pattern __pattern)
: __base_(std::move(__base)), __pattern_(std::move(__pattern)) {}
template <input_range _Range>
requires constructible_from<_View, views::all_t<_Range>> &&
constructible_from<_Pattern, single_view<range_value_t<_Range>>>
_LIBCPP_HIDE_FROM_ABI
constexpr _LIBCPP_EXPLICIT_SINCE_CXX23 lazy_split_view(_Range&& __r, range_value_t<_Range> __e)
: __base_(views::all(std::forward<_Range>(__r)))
, __pattern_(views::single(std::move(__e))) {}
constructible_from<_Pattern, single_view<range_value_t<_Range>>>
_LIBCPP_HIDE_FROM_ABI constexpr _LIBCPP_EXPLICIT_SINCE_CXX23 lazy_split_view(_Range&& __r, range_value_t<_Range> __e)
: __base_(views::all(std::forward<_Range>(__r))), __pattern_(views::single(std::move(__e))) {}
_LIBCPP_HIDE_FROM_ABI
constexpr _View base() const& requires copy_constructible<_View> { return __base_; }
_LIBCPP_HIDE_FROM_ABI
constexpr _View base() && { return std::move(__base_); }
_LIBCPP_HIDE_FROM_ABI constexpr _View base() const&
requires copy_constructible<_View>
{
return __base_;
}
_LIBCPP_HIDE_FROM_ABI constexpr _View base() && { return std::move(__base_); }
_LIBCPP_HIDE_FROM_ABI
constexpr auto begin() {
_LIBCPP_HIDE_FROM_ABI constexpr auto begin() {
if constexpr (forward_range<_View>) {
return __outer_iterator<__simple_view<_View> && __simple_view<_Pattern>>{*this, ranges::begin(__base_)};
return __outer_iterator < __simple_view<_View> && __simple_view < _Pattern >> {*this, ranges::begin(__base_)};
} else {
__current_.__emplace(ranges::begin(__base_));
return __outer_iterator<false>{*this};
}
}
_LIBCPP_HIDE_FROM_ABI
constexpr auto begin() const requires forward_range<_View> && forward_range<const _View> {
_LIBCPP_HIDE_FROM_ABI constexpr auto begin() const
requires forward_range<_View> && forward_range<const _View>
{
return __outer_iterator<true>{*this, ranges::begin(__base_)};
}
_LIBCPP_HIDE_FROM_ABI
constexpr auto end() requires forward_range<_View> && common_range<_View> {
return __outer_iterator<__simple_view<_View> && __simple_view<_Pattern>>{*this, ranges::end(__base_)};
_LIBCPP_HIDE_FROM_ABI constexpr auto end()
requires forward_range<_View> && common_range<_View>
{
return __outer_iterator < __simple_view<_View> && __simple_view < _Pattern >> {*this, ranges::end(__base_)};
}
_LIBCPP_HIDE_FROM_ABI
constexpr auto end() const {
_LIBCPP_HIDE_FROM_ABI constexpr auto end() const {
if constexpr (forward_range<_View> && forward_range<const _View> && common_range<const _View>) {
return __outer_iterator<true>{*this, ranges::end(__base_)};
} else {
@ -128,7 +131,6 @@ public:
}
private:
template <class>
struct __outer_iterator_category {};
@ -145,15 +147,14 @@ private:
friend __outer_iterator<true>;
using _Parent = __maybe_const<_Const, lazy_split_view>;
using _Base = __maybe_const<_Const, _View>;
using _Base = __maybe_const<_Const, _View>;
_Parent* __parent_ = nullptr;
using _MaybeCurrent = _If<forward_range<_View>, iterator_t<_Base>, __empty_cache>;
_Parent* __parent_ = nullptr;
using _MaybeCurrent = _If<forward_range<_View>, iterator_t<_Base>, __empty_cache>;
_LIBCPP_NO_UNIQUE_ADDRESS _MaybeCurrent __current_ = _MaybeCurrent();
bool __trailing_empty_ = false;
bool __trailing_empty_ = false;
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI
constexpr auto& __current() noexcept {
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto& __current() noexcept {
if constexpr (forward_range<_View>) {
return __current_;
} else {
@ -161,8 +162,7 @@ private:
}
}
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI
constexpr const auto& __current() const noexcept {
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const auto& __current() const noexcept {
if constexpr (forward_range<_View>) {
return __current_;
} else {
@ -172,56 +172,42 @@ private:
// Workaround for the GCC issue that doesn't allow calling `__parent_->__base_` from friend functions (because
// `__base_` is private).
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI
constexpr auto& __parent_base() const noexcept {
return __parent_->__base_;
}
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto& __parent_base() const noexcept { return __parent_->__base_; }
public:
// using iterator_category = inherited;
using iterator_concept = conditional_t<forward_range<_Base>, forward_iterator_tag, input_iterator_tag>;
using difference_type = range_difference_t<_Base>;
using difference_type = range_difference_t<_Base>;
struct value_type : view_interface<value_type> {
private:
__outer_iterator __i_ = __outer_iterator();
public:
_LIBCPP_HIDE_FROM_ABI
value_type() = default;
_LIBCPP_HIDE_FROM_ABI
constexpr explicit value_type(__outer_iterator __i)
: __i_(std::move(__i)) {}
_LIBCPP_HIDE_FROM_ABI value_type() = default;
_LIBCPP_HIDE_FROM_ABI constexpr explicit value_type(__outer_iterator __i) : __i_(std::move(__i)) {}
_LIBCPP_HIDE_FROM_ABI
constexpr __inner_iterator<_Const> begin() const { return __inner_iterator<_Const>{__i_}; }
_LIBCPP_HIDE_FROM_ABI
constexpr default_sentinel_t end() const noexcept { return default_sentinel; }
_LIBCPP_HIDE_FROM_ABI constexpr __inner_iterator<_Const> begin() const { return __inner_iterator<_Const>{__i_}; }
_LIBCPP_HIDE_FROM_ABI constexpr default_sentinel_t end() const noexcept { return default_sentinel; }
};
_LIBCPP_HIDE_FROM_ABI
__outer_iterator() = default;
_LIBCPP_HIDE_FROM_ABI __outer_iterator() = default;
_LIBCPP_HIDE_FROM_ABI
constexpr explicit __outer_iterator(_Parent& __parent)
requires (!forward_range<_Base>)
: __parent_(std::addressof(__parent)) {}
_LIBCPP_HIDE_FROM_ABI constexpr explicit __outer_iterator(_Parent& __parent)
requires(!forward_range<_Base>)
: __parent_(std::addressof(__parent)) {}
_LIBCPP_HIDE_FROM_ABI
constexpr __outer_iterator(_Parent& __parent, iterator_t<_Base> __current)
_LIBCPP_HIDE_FROM_ABI constexpr __outer_iterator(_Parent& __parent, iterator_t<_Base> __current)
requires forward_range<_Base>
: __parent_(std::addressof(__parent)), __current_(std::move(__current)) {}
: __parent_(std::addressof(__parent)), __current_(std::move(__current)) {}
_LIBCPP_HIDE_FROM_ABI
constexpr __outer_iterator(__outer_iterator<!_Const> __i)
_LIBCPP_HIDE_FROM_ABI constexpr __outer_iterator(__outer_iterator<!_Const> __i)
requires _Const && convertible_to<iterator_t<_View>, iterator_t<_Base>>
: __parent_(__i.__parent_), __current_(std::move(__i.__current_)) {}
: __parent_(__i.__parent_), __current_(std::move(__i.__current_)) {}
_LIBCPP_HIDE_FROM_ABI
constexpr value_type operator*() const { return value_type{*this}; }
_LIBCPP_HIDE_FROM_ABI constexpr value_type operator*() const { return value_type{*this}; }
_LIBCPP_HIDE_FROM_ABI
constexpr __outer_iterator& operator++() {
_LIBCPP_HIDE_FROM_ABI constexpr __outer_iterator& operator++() {
const auto __end = ranges::end(__parent_->__base_);
if (__current() == __end) {
__trailing_empty_ = false;
@ -260,8 +246,7 @@ private:
return *this;
}
_LIBCPP_HIDE_FROM_ABI
constexpr decltype(auto) operator++(int) {
_LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator++(int) {
if constexpr (forward_range<_Base>) {
auto __tmp = *this;
++*this;
@ -272,15 +257,14 @@ private:
}
}
_LIBCPP_HIDE_FROM_ABI
friend constexpr bool operator==(const __outer_iterator& __x, const __outer_iterator& __y)
requires forward_range<_Base> {
_LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const __outer_iterator& __x, const __outer_iterator& __y)
requires forward_range<_Base>
{
return __x.__current_ == __y.__current_ && __x.__trailing_empty_ == __y.__trailing_empty_;
}
_LIBCPP_HIDE_FROM_ABI
friend constexpr bool operator==(const __outer_iterator& __x, default_sentinel_t) {
_LIBCPP_ASSERT(__x.__parent_, "Cannot call comparison on a default-constructed iterator.");
_LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const __outer_iterator& __x, default_sentinel_t) {
_LIBCPP_ASSERT_NON_NULL(__x.__parent_ != nullptr, "Cannot call comparison on a default-constructed iterator.");
return __x.__current() == ranges::end(__x.__parent_base()) && !__x.__trailing_empty_;
}
};
@ -290,11 +274,10 @@ private:
template <forward_range _Tp>
struct __inner_iterator_category<_Tp> {
using iterator_category = _If<
derived_from<typename iterator_traits<iterator_t<_Tp>>::iterator_category, forward_iterator_tag>,
forward_iterator_tag,
typename iterator_traits<iterator_t<_Tp>>::iterator_category
>;
using iterator_category =
_If< derived_from<typename iterator_traits<iterator_t<_Tp>>::iterator_category, forward_iterator_tag>,
forward_iterator_tag,
typename iterator_traits<iterator_t<_Tp>>::iterator_category >;
};
template <bool _Const>
@ -303,18 +286,17 @@ private:
using _Base = __maybe_const<_Const, _View>;
// Workaround for a GCC issue.
static constexpr bool _OuterConst = _Const;
__outer_iterator<_Const> __i_ = __outer_iterator<_OuterConst>();
bool __incremented_ = false;
__outer_iterator<_Const> __i_ = __outer_iterator<_OuterConst>();
bool __incremented_ = false;
// Note: these private functions are necessary because GCC doesn't allow calls to private members of `__i_` from
// free functions that are friends of `inner-iterator`.
_LIBCPP_HIDE_FROM_ABI
constexpr bool __is_done() const {
_LIBCPP_ASSERT(__i_.__parent_, "Cannot call comparison on a default-constructed iterator.");
_LIBCPP_HIDE_FROM_ABI constexpr bool __is_done() const {
_LIBCPP_ASSERT_NON_NULL(__i_.__parent_ != nullptr, "Cannot call comparison on a default-constructed iterator.");
auto [__pcur, __pend] = ranges::subrange{__i_.__parent_->__pattern_};
auto __end = ranges::end(__i_.__parent_->__base_);
auto __end = ranges::end(__i_.__parent_->__base_);
if constexpr (__tiny_range<_Pattern>) {
const auto& __cur = __i_.__current();
@ -343,40 +325,32 @@ private:
}
}
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI
constexpr auto& __outer_current() noexcept {
return __i_.__current();
}
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto& __outer_current() noexcept { return __i_.__current(); }
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI
constexpr const auto& __outer_current() const noexcept {
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const auto& __outer_current() const noexcept {
return __i_.__current();
}
public:
// using iterator_category = inherited;
using iterator_concept = typename __outer_iterator<_Const>::iterator_concept;
using value_type = range_value_t<_Base>;
using difference_type = range_difference_t<_Base>;
using value_type = range_value_t<_Base>;
using difference_type = range_difference_t<_Base>;
_LIBCPP_HIDE_FROM_ABI
__inner_iterator() = default;
_LIBCPP_HIDE_FROM_ABI __inner_iterator() = default;
_LIBCPP_HIDE_FROM_ABI
constexpr explicit __inner_iterator(__outer_iterator<_Const> __i)
: __i_(std::move(__i)) {}
_LIBCPP_HIDE_FROM_ABI constexpr explicit __inner_iterator(__outer_iterator<_Const> __i) : __i_(std::move(__i)) {}
_LIBCPP_HIDE_FROM_ABI
constexpr const iterator_t<_Base>& base() const& noexcept { return __i_.__current(); }
_LIBCPP_HIDE_FROM_ABI
constexpr iterator_t<_Base> base() &&
requires forward_range<_View> { return std::move(__i_.__current()); }
_LIBCPP_HIDE_FROM_ABI constexpr const iterator_t<_Base>& base() const& noexcept { return __i_.__current(); }
_LIBCPP_HIDE_FROM_ABI constexpr iterator_t<_Base> base() &&
requires forward_range<_View>
{
return std::move(__i_.__current());
}
_LIBCPP_HIDE_FROM_ABI
constexpr decltype(auto) operator*() const { return *__i_.__current(); }
_LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator*() const { return *__i_.__current(); }
_LIBCPP_HIDE_FROM_ABI
constexpr __inner_iterator& operator++() {
_LIBCPP_HIDE_FROM_ABI constexpr __inner_iterator& operator++() {
__incremented_ = true;
if constexpr (!forward_range<_Base>) {
@ -389,8 +363,7 @@ private:
return *this;
}
_LIBCPP_HIDE_FROM_ABI
constexpr decltype(auto) operator++(int) {
_LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator++(int) {
if constexpr (forward_range<_Base>) {
auto __tmp = *this;
++*this;
@ -401,54 +374,51 @@ private:
}
}
_LIBCPP_HIDE_FROM_ABI
friend constexpr bool operator==(const __inner_iterator& __x, const __inner_iterator& __y)
requires forward_range<_Base> {
_LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const __inner_iterator& __x, const __inner_iterator& __y)
requires forward_range<_Base>
{
return __x.__outer_current() == __y.__outer_current();
}
_LIBCPP_HIDE_FROM_ABI
friend constexpr bool operator==(const __inner_iterator& __x, default_sentinel_t) {
_LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const __inner_iterator& __x, default_sentinel_t) {
return __x.__is_done();
}
_LIBCPP_HIDE_FROM_ABI
friend constexpr decltype(auto) iter_move(const __inner_iterator& __i)
noexcept(noexcept(ranges::iter_move(__i.__outer_current()))) {
_LIBCPP_HIDE_FROM_ABI friend constexpr decltype(auto)
iter_move(const __inner_iterator& __i) noexcept(noexcept(ranges::iter_move(__i.__outer_current()))) {
return ranges::iter_move(__i.__outer_current());
}
_LIBCPP_HIDE_FROM_ABI
friend constexpr void iter_swap(const __inner_iterator& __x, const __inner_iterator& __y)
noexcept(noexcept(ranges::iter_swap(__x.__outer_current(), __y.__outer_current())))
requires indirectly_swappable<iterator_t<_Base>> {
_LIBCPP_HIDE_FROM_ABI friend constexpr void iter_swap(
const __inner_iterator& __x,
const __inner_iterator& __y) noexcept(noexcept(ranges::iter_swap(__x.__outer_current(), __y.__outer_current())))
requires indirectly_swappable<iterator_t<_Base>>
{
ranges::iter_swap(__x.__outer_current(), __y.__outer_current());
}
};
};
template <class _Range, class _Pattern>
lazy_split_view(_Range&&, _Pattern&&) -> lazy_split_view<views::all_t<_Range>, views::all_t<_Pattern>>;
template <input_range _Range>
lazy_split_view(_Range&&, range_value_t<_Range>)
-> lazy_split_view<views::all_t<_Range>, single_view<range_value_t<_Range>>>;
lazy_split_view(_Range&&,
range_value_t<_Range>) -> lazy_split_view<views::all_t<_Range>, single_view<range_value_t<_Range>>>;
namespace views {
namespace __lazy_split_view {
struct __fn : __range_adaptor_closure<__fn> {
struct __fn {
template <class _Range, class _Pattern>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI
constexpr auto operator()(_Range&& __range, _Pattern&& __pattern) const
noexcept(noexcept(lazy_split_view(std::forward<_Range>(__range), std::forward<_Pattern>(__pattern))))
-> decltype( lazy_split_view(std::forward<_Range>(__range), std::forward<_Pattern>(__pattern)))
{ return lazy_split_view(std::forward<_Range>(__range), std::forward<_Pattern>(__pattern)); }
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Range&& __range, _Pattern&& __pattern) const
noexcept(noexcept(lazy_split_view(std::forward<_Range>(__range), std::forward<_Pattern>(__pattern))))
-> decltype(lazy_split_view(std::forward<_Range>(__range), std::forward<_Pattern>(__pattern))) {
return lazy_split_view(std::forward<_Range>(__range), std::forward<_Pattern>(__pattern));
}
template <class _Pattern>
requires constructible_from<decay_t<_Pattern>, _Pattern>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI
constexpr auto operator()(_Pattern&& __pattern) const
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Pattern&& __pattern) const
noexcept(is_nothrow_constructible_v<decay_t<_Pattern>, _Pattern>) {
return __range_adaptor_closure_t(std::__bind_back(*this, std::forward<_Pattern>(__pattern)));
}
@ -456,7 +426,7 @@ struct __fn : __range_adaptor_closure<__fn> {
} // namespace __lazy_split_view
inline namespace __cpo {
inline constexpr auto lazy_split = __lazy_split_view::__fn{};
inline constexpr auto lazy_split = __lazy_split_view::__fn{};
} // namespace __cpo
} // namespace views
@ -466,4 +436,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
#endif // _LIBCPP___RANGES_LAZY_SPLIT_VIEW_H