aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/cxxsupp/libcxx/include/__ranges
diff options
context:
space:
mode:
authormikhnenko <mikhnenko@yandex-team.com>2023-10-16 00:19:28 +0300
committermikhnenko <mikhnenko@yandex-team.com>2023-10-16 00:40:55 +0300
commit03562c20be10d96a02cbd83773bf2f3a17c70142 (patch)
tree3762df6744c5c017b011997a08aeb20d2f92f1a5 /contrib/libs/cxxsupp/libcxx/include/__ranges
parent6851965da19965a2680cfea6815b486fb14e739d (diff)
downloadydb-03562c20be10d96a02cbd83773bf2f3a17c70142.tar.gz
Revert commit rXXXXXX, Upd libc++ to 18 May 4ac0589122830fc6d90e0ea091300c0b979a42dc
Diffstat (limited to 'contrib/libs/cxxsupp/libcxx/include/__ranges')
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/__ranges/drop_view.h182
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/__ranges/iota_view.h96
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/__ranges/lazy_split_view.h3
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/__ranges/single_view.h24
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/__ranges/subrange.h5
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/__ranges/take_view.h154
6 files changed, 58 insertions, 406 deletions
diff --git a/contrib/libs/cxxsupp/libcxx/include/__ranges/drop_view.h b/contrib/libs/cxxsupp/libcxx/include/__ranges/drop_view.h
index 962bc4e900..93f4b9f188 100644
--- a/contrib/libs/cxxsupp/libcxx/include/__ranges/drop_view.h
+++ b/contrib/libs/cxxsupp/libcxx/include/__ranges/drop_view.h
@@ -9,29 +9,18 @@
#ifndef _LIBCPP___RANGES_DROP_VIEW_H
#define _LIBCPP___RANGES_DROP_VIEW_H
-#include <__algorithm/min.h>
#include <__assert>
#include <__config>
-#include <__functional/bind_back.h>
-#include <__fwd/span.h>
-#include <__fwd/string_view.h>
#include <__iterator/concepts.h>
-#include <__iterator/distance.h>
#include <__iterator/iterator_traits.h>
#include <__iterator/next.h>
#include <__ranges/access.h>
#include <__ranges/all.h>
#include <__ranges/concepts.h>
-#include <__ranges/empty_view.h>
#include <__ranges/enable_borrowed_range.h>
-#include <__ranges/iota_view.h>
#include <__ranges/non_propagating_cache.h>
-#include <__ranges/range_adaptor.h>
#include <__ranges/size.h>
-#include <__ranges/subrange.h>
#include <__ranges/view_interface.h>
-#include <__utility/auto_cast.h>
-#include <__utility/forward.h>
#include <__utility/move.h>
#include <concepts>
#include <type_traits>
@@ -124,174 +113,11 @@ public:
{ return __size(*this); }
};
-template<class _Range>
-drop_view(_Range&&, range_difference_t<_Range>) -> drop_view<views::all_t<_Range>>;
-
-template<class _Tp>
-inline constexpr bool enable_borrowed_range<drop_view<_Tp>> = enable_borrowed_range<_Tp>;
-
-namespace views {
-namespace __drop {
-
-template <class _Tp>
-inline constexpr bool __is_empty_view = false;
-
-template <class _Tp>
-inline constexpr bool __is_empty_view<empty_view<_Tp>> = true;
-
-template <class _Tp>
-inline constexpr bool __is_passthrough_specialization = false;
-
-template <class _Tp, size_t _Extent>
-inline constexpr bool __is_passthrough_specialization<span<_Tp, _Extent>> = true;
-
-template <class _CharT, class _Traits>
-inline constexpr bool __is_passthrough_specialization<basic_string_view<_CharT, _Traits>> = true;
-
-template <class _Np, class _Bound>
-inline constexpr bool __is_passthrough_specialization<iota_view<_Np, _Bound>> = true;
-
-template <class _Iter, class _Sent, subrange_kind _Kind>
-inline constexpr bool __is_passthrough_specialization<subrange<_Iter, _Sent, _Kind>> =
- !subrange<_Iter, _Sent, _Kind>::_StoreSize;
-
-template <class _Tp>
-inline constexpr bool __is_subrange_specialization_with_store_size = false;
-
-template <class _Iter, class _Sent, subrange_kind _Kind>
-inline constexpr bool __is_subrange_specialization_with_store_size<subrange<_Iter, _Sent, _Kind>> =
- subrange<_Iter, _Sent, _Kind>::_StoreSize;
-
-template <class _Tp>
-struct __passthrough_type;
-
-template <class _Tp, size_t _Extent>
-struct __passthrough_type<span<_Tp, _Extent>> {
- using type = span<_Tp>;
-};
-
-template <class _CharT, class _Traits>
-struct __passthrough_type<basic_string_view<_CharT, _Traits>> {
- using type = basic_string_view<_CharT, _Traits>;
-};
-
-template <class _Np, class _Bound>
-struct __passthrough_type<iota_view<_Np, _Bound>> {
- using type = iota_view<_Np, _Bound>;
-};
-
-template <class _Iter, class _Sent, subrange_kind _Kind>
-struct __passthrough_type<subrange<_Iter, _Sent, _Kind>> {
- using type = subrange<_Iter, _Sent, _Kind>;
-};
-
-template <class _Tp>
-using __passthrough_type_t = typename __passthrough_type<_Tp>::type;
-
-struct __fn {
- // [range.drop.overview]: the `empty_view` case.
- template <class _Range, convertible_to<range_difference_t<_Range>> _Np>
- requires __is_empty_view<remove_cvref_t<_Range>>
- [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
- constexpr auto operator()(_Range&& __range, _Np&&) const
- noexcept(noexcept(_LIBCPP_AUTO_CAST(std::forward<_Range>(__range))))
- -> decltype( _LIBCPP_AUTO_CAST(std::forward<_Range>(__range)))
- { return _LIBCPP_AUTO_CAST(std::forward<_Range>(__range)); }
-
- // [range.drop.overview]: the `span | basic_string_view | iota_view | subrange (StoreSize == false)` case.
- template <class _Range,
- convertible_to<range_difference_t<_Range>> _Np,
- class _RawRange = remove_cvref_t<_Range>,
- class _Dist = range_difference_t<_Range>>
- requires (!__is_empty_view<_RawRange> &&
- random_access_range<_RawRange> &&
- sized_range<_RawRange> &&
- __is_passthrough_specialization<_RawRange>)
- [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
- constexpr auto operator()(_Range&& __rng, _Np&& __n) const
- noexcept(noexcept(__passthrough_type_t<_RawRange>(
- ranges::begin(__rng) + std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n)),
- ranges::end(__rng)
- )))
- -> decltype( __passthrough_type_t<_RawRange>(
- // Note: deliberately not forwarding `__rng` to guard against double moves.
- ranges::begin(__rng) + std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n)),
- ranges::end(__rng)
- ))
- { return __passthrough_type_t<_RawRange>(
- ranges::begin(__rng) + std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n)),
- ranges::end(__rng)
- ); }
-
- // [range.drop.overview]: the `subrange (StoreSize == true)` case.
- template <class _Range,
- convertible_to<range_difference_t<_Range>> _Np,
- class _RawRange = remove_cvref_t<_Range>,
- class _Dist = range_difference_t<_Range>>
- requires (!__is_empty_view<_RawRange> &&
- random_access_range<_RawRange> &&
- sized_range<_RawRange> &&
- __is_subrange_specialization_with_store_size<_RawRange>)
- [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
- constexpr auto operator()(_Range&& __rng, _Np&& __n) const
- noexcept(noexcept(_RawRange(
- ranges::begin(__rng) + std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n)),
- ranges::end(__rng),
- std::__to_unsigned_like(ranges::distance(__rng) -
- std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n)))
- )))
- -> decltype( _RawRange(
- // Note: deliberately not forwarding `__rng` to guard against double moves.
- ranges::begin(__rng) + std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n)),
- ranges::end(__rng),
- std::__to_unsigned_like(ranges::distance(__rng) -
- std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n)))
- ))
- {
- // Introducing local variables avoids calculating `min` and `distance` twice (at the cost of diverging from the
- // expression used in the `noexcept` clause and the return statement).
- auto dist = ranges::distance(__rng);
- auto clamped = std::min<_Dist>(dist, std::forward<_Np>(__n));
- return _RawRange(
- ranges::begin(__rng) + clamped,
- ranges::end(__rng),
- std::__to_unsigned_like(dist - clamped)
- );}
-
- // [range.drop.overview]: the "otherwise" case.
- template <class _Range, convertible_to<range_difference_t<_Range>> _Np,
- class _RawRange = remove_cvref_t<_Range>>
- // Note: without specifically excluding the other cases, GCC sees this overload as ambiguous with the other
- // overloads.
- requires (!(__is_empty_view<_RawRange> ||
- (__is_subrange_specialization_with_store_size<_RawRange> &&
- sized_range<_RawRange> &&
- random_access_range<_RawRange>) ||
- (__is_passthrough_specialization<_RawRange> &&
- sized_range<_RawRange> &&
- random_access_range<_RawRange>)
- ))
- [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
- constexpr auto operator()(_Range&& __range, _Np&& __n) const
- noexcept(noexcept(drop_view(std::forward<_Range>(__range), std::forward<_Np>(__n))))
- -> decltype( drop_view(std::forward<_Range>(__range), std::forward<_Np>(__n)))
- { return drop_view(std::forward<_Range>(__range), std::forward<_Np>(__n)); }
-
- template <class _Np>
- requires constructible_from<decay_t<_Np>, _Np>
- [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
- constexpr auto operator()(_Np&& __n) const
- noexcept(is_nothrow_constructible_v<decay_t<_Np>, _Np>)
- { return __range_adaptor_closure_t(std::__bind_back(*this, std::forward<_Np>(__n))); }
-};
-
-} // namespace __drop
-
-inline namespace __cpo {
- inline constexpr auto drop = __drop::__fn{};
-} // namespace __cpo
-} // namespace views
+ template<class _Range>
+ drop_view(_Range&&, range_difference_t<_Range>) -> drop_view<views::all_t<_Range>>;
+ template<class _Tp>
+ inline constexpr bool enable_borrowed_range<drop_view<_Tp>> = enable_borrowed_range<_Tp>;
} // namespace ranges
#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
diff --git a/contrib/libs/cxxsupp/libcxx/include/__ranges/iota_view.h b/contrib/libs/cxxsupp/libcxx/include/__ranges/iota_view.h
index e1f03bafa0..62e98d475b 100644
--- a/contrib/libs/cxxsupp/libcxx/include/__ranges/iota_view.h
+++ b/contrib/libs/cxxsupp/libcxx/include/__ranges/iota_view.h
@@ -90,9 +90,9 @@ namespace ranges {
using iterator_category = input_iterator_tag;
};
- template <weakly_incrementable _Start, semiregular _BoundSentinel = unreachable_sentinel_t>
- requires __weakly_equality_comparable_with<_Start, _BoundSentinel> && copyable<_Start>
- class iota_view : public view_interface<iota_view<_Start, _BoundSentinel>> {
+ template<weakly_incrementable _Start, semiregular _Bound = unreachable_sentinel_t>
+ requires __weakly_equality_comparable_with<_Start, _Bound> && copyable<_Start>
+ class iota_view : public view_interface<iota_view<_Start, _Bound>> {
struct __iterator : public __iota_iterator_category<_Start> {
friend class iota_view;
@@ -271,35 +271,35 @@ namespace ranges {
friend class iota_view;
private:
- _BoundSentinel __bound_sentinel_ = _BoundSentinel();
+ _Bound __bound_ = _Bound();
public:
_LIBCPP_HIDE_FROM_ABI
__sentinel() = default;
- constexpr explicit __sentinel(_BoundSentinel __bound_sentinel) : __bound_sentinel_(std::move(__bound_sentinel)) {}
+ constexpr explicit __sentinel(_Bound __bound) : __bound_(std::move(__bound)) {}
_LIBCPP_HIDE_FROM_ABI
friend constexpr bool operator==(const __iterator& __x, const __sentinel& __y) {
- return __x.__value_ == __y.__bound_sentinel_;
+ return __x.__value_ == __y.__bound_;
}
_LIBCPP_HIDE_FROM_ABI
friend constexpr iter_difference_t<_Start> operator-(const __iterator& __x, const __sentinel& __y)
- requires sized_sentinel_for<_BoundSentinel, _Start>
+ requires sized_sentinel_for<_Bound, _Start>
{
- return __x.__value_ - __y.__bound_sentinel_;
+ return __x.__value_ - __y.__bound_;
}
_LIBCPP_HIDE_FROM_ABI
friend constexpr iter_difference_t<_Start> operator-(const __sentinel& __x, const __iterator& __y)
- requires sized_sentinel_for<_BoundSentinel, _Start>
+ requires sized_sentinel_for<_Bound, _Start>
{
return -(__y - __x);
}
};
_Start __value_ = _Start();
- _BoundSentinel __bound_sentinel_ = _BoundSentinel();
+ _Bound __bound_ = _Bound();
public:
_LIBCPP_HIDE_FROM_ABI
@@ -309,76 +309,75 @@ namespace ranges {
constexpr explicit iota_view(_Start __value) : __value_(std::move(__value)) { }
_LIBCPP_HIDE_FROM_ABI
- constexpr iota_view(type_identity_t<_Start> __value, type_identity_t<_BoundSentinel> __bound_sentinel)
- : __value_(std::move(__value)), __bound_sentinel_(std::move(__bound_sentinel)) {
+ constexpr iota_view(type_identity_t<_Start> __value, type_identity_t<_Bound> __bound)
+ : __value_(std::move(__value)), __bound_(std::move(__bound)) {
// Validate the precondition if possible.
- if constexpr (totally_ordered_with<_Start, _BoundSentinel>) {
- _LIBCPP_ASSERT(ranges::less_equal()(__value_, __bound_sentinel_),
+ if constexpr (totally_ordered_with<_Start, _Bound>) {
+ _LIBCPP_ASSERT(ranges::less_equal()(__value_, __bound_),
"Precondition violated: value is greater than bound.");
}
}
_LIBCPP_HIDE_FROM_ABI
constexpr iota_view(__iterator __first, __iterator __last)
- requires same_as<_Start, _BoundSentinel>
- : iota_view(std::move(__first.__value_), std::move(__last.__value_)) {}
+ requires same_as<_Start, _Bound>
+ : iota_view(std::move(__first.__value_), std::move(__last.__value_)) {}
_LIBCPP_HIDE_FROM_ABI
- constexpr iota_view(__iterator __first, _BoundSentinel __last)
- requires same_as<_BoundSentinel, unreachable_sentinel_t>
- : iota_view(std::move(__first.__value_), std::move(__last)) {}
+ constexpr iota_view(__iterator __first, _Bound __last)
+ requires same_as<_Bound, unreachable_sentinel_t>
+ : iota_view(std::move(__first.__value_), std::move(__last)) {}
_LIBCPP_HIDE_FROM_ABI
constexpr iota_view(__iterator __first, __sentinel __last)
- requires(!same_as<_Start, _BoundSentinel> && !same_as<_Start, unreachable_sentinel_t>)
- : iota_view(std::move(__first.__value_), std::move(__last.__bound_sentinel_)) {}
+ requires (!same_as<_Start, _Bound> && !same_as<_Start, unreachable_sentinel_t>)
+ : iota_view(std::move(__first.__value_), std::move(__last.__bound_)) {}
_LIBCPP_HIDE_FROM_ABI
constexpr __iterator begin() const { return __iterator{__value_}; }
_LIBCPP_HIDE_FROM_ABI
constexpr auto end() const {
- if constexpr (same_as<_BoundSentinel, unreachable_sentinel_t>)
+ if constexpr (same_as<_Bound, unreachable_sentinel_t>)
return unreachable_sentinel;
else
- return __sentinel{__bound_sentinel_};
+ return __sentinel{__bound_};
}
_LIBCPP_HIDE_FROM_ABI
- constexpr __iterator end() const
- requires same_as<_Start, _BoundSentinel>
- {
- return __iterator{__bound_sentinel_};
+ constexpr __iterator end() const requires same_as<_Start, _Bound> {
+ return __iterator{__bound_};
}
_LIBCPP_HIDE_FROM_ABI
constexpr auto size() const
- requires(same_as<_Start, _BoundSentinel> && __advanceable<_Start>) ||
- (integral<_Start> && integral<_BoundSentinel>) || sized_sentinel_for<_BoundSentinel, _Start>
+ requires (same_as<_Start, _Bound> && __advanceable<_Start>) ||
+ (integral<_Start> && integral<_Bound>) ||
+ sized_sentinel_for<_Bound, _Start>
{
- if constexpr (__integer_like<_Start> && __integer_like<_BoundSentinel>) {
+ if constexpr (__integer_like<_Start> && __integer_like<_Bound>) {
if (__value_ < 0) {
- if (__bound_sentinel_ < 0) {
- return std::__to_unsigned_like(-__value_) - std::__to_unsigned_like(-__bound_sentinel_);
+ if (__bound_ < 0) {
+ return std::__to_unsigned_like(-__value_) - std::__to_unsigned_like(-__bound_);
}
- return std::__to_unsigned_like(__bound_sentinel_) + std::__to_unsigned_like(-__value_);
+ return std::__to_unsigned_like(__bound_) + std::__to_unsigned_like(-__value_);
}
- return std::__to_unsigned_like(__bound_sentinel_) - std::__to_unsigned_like(__value_);
+ return std::__to_unsigned_like(__bound_) - std::__to_unsigned_like(__value_);
}
- return std::__to_unsigned_like(__bound_sentinel_ - __value_);
+ return std::__to_unsigned_like(__bound_ - __value_);
}
};
- template <class _Start, class _BoundSentinel>
- requires(!__integer_like<_Start> || !__integer_like<_BoundSentinel> ||
- (__signed_integer_like<_Start> == __signed_integer_like<_BoundSentinel>))
- iota_view(_Start, _BoundSentinel) -> iota_view<_Start, _BoundSentinel>;
+ template<class _Start, class _Bound>
+ requires (!__integer_like<_Start> || !__integer_like<_Bound> ||
+ (__signed_integer_like<_Start> == __signed_integer_like<_Bound>))
+ iota_view(_Start, _Bound) -> iota_view<_Start, _Bound>;
- template <class _Start, class _BoundSentinel>
- inline constexpr bool enable_borrowed_range<iota_view<_Start, _BoundSentinel>> = true;
+ template<class _Start, class _Bound>
+ inline constexpr bool enable_borrowed_range<iota_view<_Start, _Bound>> = true;
- namespace views {
- namespace __iota {
+namespace views {
+namespace __iota {
struct __fn {
template<class _Start>
_LIBCPP_HIDE_FROM_ABI
@@ -387,11 +386,12 @@ namespace ranges {
-> decltype( ranges::iota_view(std::forward<_Start>(__start)))
{ return ranges::iota_view(std::forward<_Start>(__start)); }
- template <class _Start, class _BoundSentinel>
- _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Start&& __start, _BoundSentinel&& __bound_sentinel) const
- noexcept(noexcept(ranges::iota_view(std::forward<_Start>(__start), std::forward<_BoundSentinel>(__bound_sentinel))))
- -> decltype( ranges::iota_view(std::forward<_Start>(__start), std::forward<_BoundSentinel>(__bound_sentinel)))
- { return ranges::iota_view(std::forward<_Start>(__start), std::forward<_BoundSentinel>(__bound_sentinel)); }
+ template<class _Start, class _Bound>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto operator()(_Start&& __start, _Bound&& __bound) const
+ noexcept(noexcept(ranges::iota_view(std::forward<_Start>(__start), std::forward<_Bound>(__bound))))
+ -> decltype( ranges::iota_view(std::forward<_Start>(__start), std::forward<_Bound>(__bound)))
+ { return ranges::iota_view(std::forward<_Start>(__start), std::forward<_Bound>(__bound)); }
};
} // namespace __iota
diff --git a/contrib/libs/cxxsupp/libcxx/include/__ranges/lazy_split_view.h b/contrib/libs/cxxsupp/libcxx/include/__ranges/lazy_split_view.h
index e559a76ef7..68617c48f8 100644
--- a/contrib/libs/cxxsupp/libcxx/include/__ranges/lazy_split_view.h
+++ b/contrib/libs/cxxsupp/libcxx/include/__ranges/lazy_split_view.h
@@ -87,7 +87,8 @@ public:
_LIBCPP_HIDE_FROM_ABI
constexpr lazy_split_view(_Range&& __r, range_value_t<_Range> __e)
: __base_(views::all(std::forward<_Range>(__r)))
- , __pattern_(views::single(std::move(__e))) {}
+ // TODO(varconst): use `views::single` once it's implemented.
+ , __pattern_(ranges::single_view(std::move(__e))) {}
_LIBCPP_HIDE_FROM_ABI
constexpr _View base() const& requires copy_constructible<_View> { return __base_; }
diff --git a/contrib/libs/cxxsupp/libcxx/include/__ranges/single_view.h b/contrib/libs/cxxsupp/libcxx/include/__ranges/single_view.h
index 98ebe5f383..e6a873058f 100644
--- a/contrib/libs/cxxsupp/libcxx/include/__ranges/single_view.h
+++ b/contrib/libs/cxxsupp/libcxx/include/__ranges/single_view.h
@@ -11,7 +11,6 @@
#include <__config>
#include <__ranges/copyable_box.h>
-#include <__ranges/range_adaptor.h>
#include <__ranges/view_interface.h>
#include <__utility/forward.h>
#include <__utility/in_place.h>
@@ -71,27 +70,8 @@ namespace ranges {
constexpr const _Tp* data() const noexcept { return __value_.operator->(); }
};
-template<class _Tp>
-single_view(_Tp) -> single_view<_Tp>;
-
-namespace views {
-namespace __single_view {
-
-struct __fn : __range_adaptor_closure<__fn> {
- template<class _Range>
- [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
- constexpr auto operator()(_Range&& __range) const
- noexcept(noexcept(single_view<decay_t<_Range&&>>(std::forward<_Range>(__range))))
- -> decltype( single_view<decay_t<_Range&&>>(std::forward<_Range>(__range)))
- { return single_view<decay_t<_Range&&>>(std::forward<_Range>(__range)); }
-};
-} // namespace __single_view
-
-inline namespace __cpo {
- inline constexpr auto single = __single_view::__fn{};
-} // namespace __cpo
-
-} // namespace views
+ template<class _Tp>
+ single_view(_Tp) -> single_view<_Tp>;
} // namespace ranges
#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
diff --git a/contrib/libs/cxxsupp/libcxx/include/__ranges/subrange.h b/contrib/libs/cxxsupp/libcxx/include/__ranges/subrange.h
index 7e42da6ce7..24e5eff3f8 100644
--- a/contrib/libs/cxxsupp/libcxx/include/__ranges/subrange.h
+++ b/contrib/libs/cxxsupp/libcxx/include/__ranges/subrange.h
@@ -77,11 +77,8 @@ namespace ranges {
class _LIBCPP_TEMPLATE_VIS subrange
: public view_interface<subrange<_Iter, _Sent, _Kind>>
{
- public:
- // Note: this is an internal implementation detail that is public only for internal usage.
- static constexpr bool _StoreSize = (_Kind == subrange_kind::sized && !sized_sentinel_for<_Sent, _Iter>);
-
private:
+ static constexpr bool _StoreSize = (_Kind == subrange_kind::sized && !sized_sentinel_for<_Sent, _Iter>);
static constexpr bool _MustProvideSizeAtConstruction = !_StoreSize; // just to improve compiler diagnostics
struct _Empty { constexpr _Empty(auto) noexcept { } };
using _Size = conditional_t<_StoreSize, make_unsigned_t<iter_difference_t<_Iter>>, _Empty>;
diff --git a/contrib/libs/cxxsupp/libcxx/include/__ranges/take_view.h b/contrib/libs/cxxsupp/libcxx/include/__ranges/take_view.h
index 11d5c9fc36..3ad7810a9c 100644
--- a/contrib/libs/cxxsupp/libcxx/include/__ranges/take_view.h
+++ b/contrib/libs/cxxsupp/libcxx/include/__ranges/take_view.h
@@ -9,29 +9,18 @@
#ifndef _LIBCPP___RANGES_TAKE_VIEW_H
#define _LIBCPP___RANGES_TAKE_VIEW_H
-#include <__algorithm/min.h>
#include <__algorithm/ranges_min.h>
#include <__config>
-#include <__functional/bind_back.h>
-#include <__fwd/span.h>
-#include <__fwd/string_view.h>
#include <__iterator/concepts.h>
#include <__iterator/counted_iterator.h>
#include <__iterator/default_sentinel.h>
-#include <__iterator/distance.h>
#include <__iterator/iterator_traits.h>
#include <__ranges/access.h>
#include <__ranges/all.h>
#include <__ranges/concepts.h>
-#include <__ranges/empty_view.h>
#include <__ranges/enable_borrowed_range.h>
-#include <__ranges/iota_view.h>
-#include <__ranges/range_adaptor.h>
#include <__ranges/size.h>
-#include <__ranges/subrange.h>
#include <__ranges/view_interface.h>
-#include <__utility/auto_cast.h>
-#include <__utility/forward.h>
#include <__utility/move.h>
#include <concepts>
#include <type_traits>
@@ -126,6 +115,7 @@ public:
}
}
+
_LIBCPP_HIDE_FROM_ABI
constexpr auto size() requires sized_range<_View> {
auto __n = ranges::size(__base_);
@@ -184,148 +174,6 @@ take_view(_Range&&, range_difference_t<_Range>) -> take_view<views::all_t<_Range
template<class _Tp>
inline constexpr bool enable_borrowed_range<take_view<_Tp>> = enable_borrowed_range<_Tp>;
-namespace views {
-namespace __take {
-
-template <class _Tp>
-inline constexpr bool __is_empty_view = false;
-
-template <class _Tp>
-inline constexpr bool __is_empty_view<empty_view<_Tp>> = true;
-
-template <class _Tp>
-inline constexpr bool __is_passthrough_specialization = false;
-
-template <class _Tp, size_t _Extent>
-inline constexpr bool __is_passthrough_specialization<span<_Tp, _Extent>> = true;
-
-template <class _CharT, class _Traits>
-inline constexpr bool __is_passthrough_specialization<basic_string_view<_CharT, _Traits>> = true;
-
-template <class _Iter, class _Sent, subrange_kind _Kind>
-inline constexpr bool __is_passthrough_specialization<subrange<_Iter, _Sent, _Kind>> = true;
-
-template <class _Tp>
-inline constexpr bool __is_iota_specialization = false;
-
-template <class _Np, class _Bound>
-inline constexpr bool __is_iota_specialization<iota_view<_Np, _Bound>> = true;
-
-template <class _Tp>
-struct __passthrough_type;
-
-template <class _Tp, size_t _Extent>
-struct __passthrough_type<span<_Tp, _Extent>> {
- using type = span<_Tp>;
-};
-
-template <class _CharT, class _Traits>
-struct __passthrough_type<basic_string_view<_CharT, _Traits>> {
- using type = basic_string_view<_CharT, _Traits>;
-};
-
-template <class _Iter, class _Sent, subrange_kind _Kind>
-struct __passthrough_type<subrange<_Iter, _Sent, _Kind>> {
- using type = subrange<_Iter>;
-};
-
-template <class _Tp>
-using __passthrough_type_t = typename __passthrough_type<_Tp>::type;
-
-struct __fn {
- // [range.take.overview]: the `empty_view` case.
- template <class _Range, convertible_to<range_difference_t<_Range>> _Np>
- requires __is_empty_view<remove_cvref_t<_Range>>
- [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
- constexpr auto operator()(_Range&& __range, _Np&&) const
- noexcept(noexcept(_LIBCPP_AUTO_CAST(std::forward<_Range>(__range))))
- -> decltype( _LIBCPP_AUTO_CAST(std::forward<_Range>(__range)))
- { return _LIBCPP_AUTO_CAST(std::forward<_Range>(__range)); }
-
- // [range.take.overview]: the `span | basic_string_view | subrange` case.
- template <class _Range,
- convertible_to<range_difference_t<_Range>> _Np,
- class _RawRange = remove_cvref_t<_Range>,
- class _Dist = range_difference_t<_Range>>
- requires (!__is_empty_view<_RawRange> &&
- random_access_range<_RawRange> &&
- sized_range<_RawRange> &&
- __is_passthrough_specialization<_RawRange>)
- [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
- constexpr auto operator()(_Range&& __rng, _Np&& __n) const
- noexcept(noexcept(__passthrough_type_t<_RawRange>(
- ranges::begin(__rng),
- ranges::begin(__rng) + std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n))
- )))
- -> decltype( __passthrough_type_t<_RawRange>(
- // Note: deliberately not forwarding `__rng` to guard against double moves.
- ranges::begin(__rng),
- ranges::begin(__rng) + std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n))
- ))
- { return __passthrough_type_t<_RawRange>(
- ranges::begin(__rng),
- ranges::begin(__rng) + std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n))
- ); }
-
- // [range.take.overview]: the `iota_view` case.
- template <class _Range,
- convertible_to<range_difference_t<_Range>> _Np,
- class _RawRange = remove_cvref_t<_Range>,
- class _Dist = range_difference_t<_Range>>
- requires (!__is_empty_view<_RawRange> &&
- random_access_range<_RawRange> &&
- sized_range<_RawRange> &&
- __is_iota_specialization<_RawRange>)
- [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
- constexpr auto operator()(_Range&& __rng, _Np&& __n) const
- noexcept(noexcept(ranges::iota_view(
- *ranges::begin(__rng),
- *ranges::begin(__rng) + std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n))
- )))
- -> decltype( ranges::iota_view(
- // Note: deliberately not forwarding `__rng` to guard against double moves.
- *ranges::begin(__rng),
- *ranges::begin(__rng) + std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n))
- ))
- { return ranges::iota_view(
- *ranges::begin(__rng),
- *ranges::begin(__rng) + std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n))
- ); }
-
- // [range.take.overview]: the "otherwise" case.
- template <class _Range, convertible_to<range_difference_t<_Range>> _Np,
- class _RawRange = remove_cvref_t<_Range>>
- // Note: without specifically excluding the other cases, GCC sees this overload as ambiguous with the other
- // overloads.
- requires (!(__is_empty_view<_RawRange> ||
- (__is_iota_specialization<_RawRange> &&
- sized_range<_RawRange> &&
- random_access_range<_RawRange>) ||
- (__is_passthrough_specialization<_RawRange> &&
- sized_range<_RawRange> &&
- random_access_range<_RawRange>)
- ))
- [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
- constexpr auto operator()(_Range&& __range, _Np&& __n) const
- noexcept(noexcept(take_view(std::forward<_Range>(__range), std::forward<_Np>(__n))))
- -> decltype( take_view(std::forward<_Range>(__range), std::forward<_Np>(__n)))
- { return take_view(std::forward<_Range>(__range), std::forward<_Np>(__n)); }
-
- template <class _Np>
- requires constructible_from<decay_t<_Np>, _Np>
- [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
- constexpr auto operator()(_Np&& __n) const
- noexcept(is_nothrow_constructible_v<decay_t<_Np>, _Np>)
- { return __range_adaptor_closure_t(std::__bind_back(*this, std::forward<_Np>(__n))); }
-};
-
-} // namespace __take
-
-inline namespace __cpo {
- inline constexpr auto take = __take::__fn{};
-} // namespace __cpo
-} // namespace views
-
} // namespace ranges
#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)