diff options
Diffstat (limited to 'contrib/libs/cxxsupp/libcxx/include/__ranges/drop_view.h')
-rw-r--r-- | contrib/libs/cxxsupp/libcxx/include/__ranges/drop_view.h | 55 |
1 files changed, 45 insertions, 10 deletions
diff --git a/contrib/libs/cxxsupp/libcxx/include/__ranges/drop_view.h b/contrib/libs/cxxsupp/libcxx/include/__ranges/drop_view.h index 8f3564a8c7..f10476f001 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__ranges/drop_view.h +++ b/contrib/libs/cxxsupp/libcxx/include/__ranges/drop_view.h @@ -30,13 +30,19 @@ #include <__ranges/iota_view.h> #include <__ranges/non_propagating_cache.h> #include <__ranges/range_adaptor.h> +#include <__ranges/repeat_view.h> #include <__ranges/size.h> #include <__ranges/subrange.h> #include <__ranges/view_interface.h> +#include <__type_traits/conditional.h> +#include <__type_traits/decay.h> +#include <__type_traits/is_nothrow_constructible.h> +#include <__type_traits/make_unsigned.h> +#include <__type_traits/remove_cvref.h> #include <__utility/auto_cast.h> #include <__utility/forward.h> #include <__utility/move.h> -#include <type_traits> +#include <cstddef> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -47,7 +53,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 +#if _LIBCPP_STD_VER >= 20 namespace ranges { template<view _View> @@ -66,14 +72,14 @@ namespace ranges { _View __base_ = _View(); public: - drop_view() requires default_initializable<_View> = default; + _LIBCPP_HIDE_FROM_ABI drop_view() requires default_initializable<_View> = default; _LIBCPP_HIDE_FROM_ABI - constexpr drop_view(_View __base, range_difference_t<_View> __count) + constexpr _LIBCPP_EXPLICIT_SINCE_CXX23 drop_view(_View __base, range_difference_t<_View> __count) : __count_(__count) , __base_(std::move(__base)) { - _LIBCPP_ASSERT(__count_ >= 0, "count must be greater than or equal to zero."); + _LIBCPP_ASSERT_UNCATEGORIZED(__count_ >= 0, "count must be greater than or equal to zero."); } _LIBCPP_HIDE_FROM_ABI constexpr _View base() const& requires copy_constructible<_View> { return __base_; } @@ -255,13 +261,39 @@ struct __fn { { // 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)); + auto __dist = ranges::distance(__rng); + auto __clamped = std::min<_Dist>(__dist, std::forward<_Np>(__n)); return _RawRange( - ranges::begin(__rng) + clamped, + ranges::begin(__rng) + __clamped, ranges::end(__rng), - std::__to_unsigned_like(dist - clamped) + std::__to_unsigned_like(__dist - __clamped) );} +// clang-format off +#if _LIBCPP_STD_VER >= 23 + // [range.drop.overview]: the `repeat_view` "_RawRange models sized_range" 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_repeat_specialization<_RawRange> && sized_range<_RawRange>) + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Range&& __range, _Np&& __n) const + noexcept(noexcept(views::repeat(*__range.__value_, ranges::distance(__range) - std::min<_Dist>(ranges::distance(__range), std::forward<_Np>(__n))))) + -> decltype( views::repeat(*__range.__value_, ranges::distance(__range) - std::min<_Dist>(ranges::distance(__range), std::forward<_Np>(__n)))) + { return views::repeat(*__range.__value_, ranges::distance(__range) - std::min<_Dist>(ranges::distance(__range), std::forward<_Np>(__n))); } + + // [range.drop.overview]: the `repeat_view` "otherwise" 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_repeat_specialization<_RawRange> && !sized_range<_RawRange>) + _LIBCPP_NODISCARD_EXT _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)); } +#endif +// clang-format on // [range.drop.overview]: the "otherwise" case. template <class _Range, convertible_to<range_difference_t<_Range>> _Np, @@ -269,6 +301,9 @@ struct __fn { // Note: without specifically excluding the other cases, GCC sees this overload as ambiguous with the other // overloads. requires (!(__is_empty_view<_RawRange> || +#if _LIBCPP_STD_VER >= 23 + __is_repeat_specialization<_RawRange> || +#endif (__is_subrange_specialization_with_store_size<_RawRange> && sized_range<_RawRange> && random_access_range<_RawRange>) || @@ -299,7 +334,7 @@ inline namespace __cpo { } // namespace ranges -#endif // _LIBCPP_STD_VER > 17 +#endif // _LIBCPP_STD_VER >= 20 _LIBCPP_END_NAMESPACE_STD |