[libcxx-commits] [libcxx] [libc++] Implement P2442R1 `std::views::slide` (PR #172948)
via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Dec 18 20:10:35 PST 2025
https://github.com/anonymouspc updated https://github.com/llvm/llvm-project/pull/172948
>From 5d2b4d35c0a4650a4b67d07b3579f45b48617e43 Mon Sep 17 00:00:00 2001
From: anonymouspc <shyeyian at petalmail.com>
Date: Fri, 19 Dec 2025 11:00:46 +0800
Subject: [PATCH 1/3] Generate meta info of libc++
This commit updates docs, status, release-notes, <version> and other meta info in libc++.
---
libcxx/docs/FeatureTestMacroTable.rst | 2 +-
libcxx/docs/ReleaseNotes/22.rst | 1 +
libcxx/docs/Status/Cxx23Papers.csv | 2 +-
libcxx/include/CMakeLists.txt | 1 +
libcxx/include/module.modulemap.in | 4 ++++
libcxx/include/ranges | 8 ++++++++
libcxx/include/version | 2 +-
libcxx/modules/std/ranges.inc | 2 ++
libcxx/utils/generate_feature_test_macro_components.py | 1 -
9 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/libcxx/docs/FeatureTestMacroTable.rst b/libcxx/docs/FeatureTestMacroTable.rst
index 756bdf71f8b22..82198ac37509c 100644
--- a/libcxx/docs/FeatureTestMacroTable.rst
+++ b/libcxx/docs/FeatureTestMacroTable.rst
@@ -384,7 +384,7 @@ Status
---------------------------------------------------------- -----------------
``__cpp_lib_ranges_repeat`` ``202207L``
---------------------------------------------------------- -----------------
- ``__cpp_lib_ranges_slide`` *unimplemented*
+ ``__cpp_lib_ranges_slide`` ``202202L``
---------------------------------------------------------- -----------------
``__cpp_lib_ranges_starts_ends_with`` ``202106L``
---------------------------------------------------------- -----------------
diff --git a/libcxx/docs/ReleaseNotes/22.rst b/libcxx/docs/ReleaseNotes/22.rst
index 603551cb0f603..aea8e3157032c 100644
--- a/libcxx/docs/ReleaseNotes/22.rst
+++ b/libcxx/docs/ReleaseNotes/22.rst
@@ -49,6 +49,7 @@ Implemented Papers
- P2835R7: Expose ``std::atomic_ref``'s object address (`Github <https://llvm.org/PR118377>`__)
- P2944R3: Comparisons for ``reference_wrapper`` (`Github <https://llvm.org/PR105424>`__)
- P3168R2: Give ``std::optional`` Range Support (`Github <https://llvm.org/PR105430>`__)
+- P2442R1: P2442R1: Windowing range adaptors: ``views::chunk`` and ``views::slide`` (`Github <https://llvm.org/PR171234>`__) (Implemented ``views::slide`` only)
Improvements and New Features
-----------------------------
diff --git a/libcxx/docs/Status/Cxx23Papers.csv b/libcxx/docs/Status/Cxx23Papers.csv
index b655384bad7f2..05b9d3cdc695a 100644
--- a/libcxx/docs/Status/Cxx23Papers.csv
+++ b/libcxx/docs/Status/Cxx23Papers.csv
@@ -48,7 +48,7 @@
"`P2387R3 <https://wg21.link/P2387R3>`__","Pipe support for user-defined range adaptors","2022-02 (Virtual)","|Complete|","19","`#105183 <https://github.com/llvm/llvm-project/issues/105183>`__",""
"`P2440R1 <https://wg21.link/P2440R1>`__","``ranges::iota``, ``ranges::shift_left`` and ``ranges::shift_right``","2022-02 (Virtual)","|Partial|","","`#105184 <https://github.com/llvm/llvm-project/issues/105184>`__","Only ``ranges::iota`` is implemented."
"`P2441R2 <https://wg21.link/P2441R2>`__","``views::join_with``","2022-02 (Virtual)","|Complete|","21","`#105185 <https://github.com/llvm/llvm-project/issues/105185>`__",""
-"`P2442R1 <https://wg21.link/P2442R1>`__","Windowing range adaptors: ``views::chunk`` and ``views::slide``","2022-02 (Virtual)","","","`#105187 <https://github.com/llvm/llvm-project/issues/105187>`__",""
+"`P2442R1 <https://wg21.link/P2442R1>`__","Windowing range adaptors: ``views::chunk`` and ``views::slide``","2022-02 (Virtual)","|Partial|","22","`#105187 <https://github.com/llvm/llvm-project/issues/105187>`__","Only ``views::slide`` is implemented."
"`P2443R1 <https://wg21.link/P2443R1>`__","``views::chunk_by``","2022-02 (Virtual)","|Complete|","18","`#105188 <https://github.com/llvm/llvm-project/issues/105188>`__",""
"","","","","","",""
"`P0009R18 <https://wg21.link/P0009R18>`__","mdspan: A Non-Owning Multidimensional Array Reference","2022-07 (Virtual)","|Complete|","18","`#105189 <https://github.com/llvm/llvm-project/issues/105189>`__",""
diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index e6d5d444cc1c2..5bb528a35b08e 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -737,6 +737,7 @@ set(files
__ranges/reverse_view.h
__ranges/single_view.h
__ranges/size.h
+ __ranges/slide.h
__ranges/split_view.h
__ranges/subrange.h
__ranges/take_view.h
diff --git a/libcxx/include/module.modulemap.in b/libcxx/include/module.modulemap.in
index feb6249e1e6db..9d84456ef55c8 100644
--- a/libcxx/include/module.modulemap.in
+++ b/libcxx/include/module.modulemap.in
@@ -1913,6 +1913,10 @@ module std [system] {
module reverse_view { header "__ranges/reverse_view.h" }
module single_view { header "__ranges/single_view.h" }
module size { header "__ranges/size.h" }
+ module slide_view {
+ header "__ranges/slide_view.h"
+ export std.functional.bind_back
+ }
module split_view {
header "__ranges/split_view.h"
export std.functional.bind_back
diff --git a/libcxx/include/ranges b/libcxx/include/ranges
index aa7f0b36c3877..6a07e0312da46 100644
--- a/libcxx/include/ranges
+++ b/libcxx/include/ranges
@@ -385,6 +385,13 @@ namespace std::ranges {
class chunk_by_view; // C++23
namespace views { inline constexpr unspecified chunk_by = unspecified; } // C++23
+
+ // [range.slide]
+ template <forward_range V>
+ requires view<V>
+ class slide_view<V>; // C++23
+
+ namespace views { inline constexpr unspecified slide = unspecified; } // C++23
}
namespace std {
@@ -470,6 +477,7 @@ namespace std {
# include <__ranges/adjacent_view.h>
# include <__ranges/as_rvalue_view.h>
# include <__ranges/chunk_by_view.h>
+# include <__ranges/chunk_view.h>
# include <__ranges/from_range.h>
# include <__ranges/join_with_view.h>
# include <__ranges/repeat_view.h>
diff --git a/libcxx/include/version b/libcxx/include/version
index 05532ea731ff3..632d7a50c7b30 100644
--- a/libcxx/include/version
+++ b/libcxx/include/version
@@ -529,7 +529,7 @@ __cpp_lib_void_t 201411L <type_traits>
# define __cpp_lib_ranges_iota 202202L
# define __cpp_lib_ranges_join_with 202202L
# define __cpp_lib_ranges_repeat 202207L
-// # define __cpp_lib_ranges_slide 202202L
+# define __cpp_lib_ranges_slide 202202L
# define __cpp_lib_ranges_starts_ends_with 202106L
# define __cpp_lib_ranges_to_container 202202L
// # define __cpp_lib_ranges_zip 202110L
diff --git a/libcxx/modules/std/ranges.inc b/libcxx/modules/std/ranges.inc
index 67e571b9567dd..2c16460679f33 100644
--- a/libcxx/modules/std/ranges.inc
+++ b/libcxx/modules/std/ranges.inc
@@ -325,7 +325,9 @@ export namespace std {
namespace views {
using std::ranges::views::chunk;
}
+#endif
+#if _LIBCPP_STD_VER >= 23
using std::ranges::slide_view;
namespace views {
diff --git a/libcxx/utils/generate_feature_test_macro_components.py b/libcxx/utils/generate_feature_test_macro_components.py
index 0802f865f9406..29986e50ff635 100644
--- a/libcxx/utils/generate_feature_test_macro_components.py
+++ b/libcxx/utils/generate_feature_test_macro_components.py
@@ -1150,7 +1150,6 @@ def add_version_header(tc):
"name": "__cpp_lib_ranges_slide",
"values": {"c++23": 202202},
"headers": ["ranges"],
- "unimplemented": True,
},
{
"name": "__cpp_lib_ranges_starts_ends_with",
>From c6db51296acfa0b3936772e6c9752e5656817ebb Mon Sep 17 00:00:00 2001
From: anonymouspc <shyeyian at petalmail.com>
Date: Fri, 19 Dec 2025 12:00:34 +0800
Subject: [PATCH 2/3] Implement views::slide in <__ranges/slide_view.h>
Add header file <__ranges/slide_view.h>.
Note currently (until this commit) `view::chunk` is not tested.
Tests will be added later.
---
libcxx/include/__ranges/slide_view.h | 392 +++++++++++++++++++++++++++
1 file changed, 392 insertions(+)
create mode 100644 libcxx/include/__ranges/slide_view.h
diff --git a/libcxx/include/__ranges/slide_view.h b/libcxx/include/__ranges/slide_view.h
new file mode 100644
index 0000000000000..7f79daecc6ba9
--- /dev/null
+++ b/libcxx/include/__ranges/slide_view.h
@@ -0,0 +1,392 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___RANGES_SLIDE_VIEW_H
+#define _LIBCPP___RANGES_SLIDE_VIEW_H
+
+#include <__algorithm/ranges_min.h>
+#include <__assert>
+#include <__concepts/constructible.h>
+#include <__concepts/convertible_to.h>
+#include <__config>
+#include <__functional/bind_back.h>
+#include <__iterator/advance.h>
+#include <__iterator/concepts.h>
+#include <__iterator/default_sentinel.h>
+#include <__iterator/distance.h>
+#include <__iterator/iter_move.h>
+#include <__iterator/iter_swap.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/next.h>
+#include <__memory/addressof.h>
+#include <__ranges/access.h>
+#include <__ranges/all.h>
+#include <__ranges/concepts.h>
+#include <__ranges/counted.h>
+#include <__ranges/enable_borrowed_range.h>
+#include <__ranges/non_propagating_cache.h>
+#include <__ranges/range_adaptor.h>
+#include <__ranges/take_view.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 <__utility/forward.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER >= 23
+
+namespace ranges {
+
+template <class _View>
+concept __slide_caches_nothing = random_access_range<_View> && sized_range<_View>;
+
+template <class _View>
+concept __slide_caches_last = !__slide_caches_nothing<_View> && bidirectional_range<_View> && common_range<_View>;
+
+template <class _View>
+concept __slide_caches_first = !__slide_caches_nothing<_View> && !__slide_caches_last<_View>;
+
+template <forward_range _View>
+ requires view<_View>
+class slide_view : public view_interface<slide_view<_View>> {
+ _LIBCPP_NO_UNIQUE_ADDRESS _View __base_;
+ _LIBCPP_NO_UNIQUE_ADDRESS range_difference_t<_View> __n_;
+ _LIBCPP_NO_UNIQUE_ADDRESS _If<__slide_caches_first<_View>, __non_propagating_cache<iterator_t<_View>>, __empty_cache> __cached_begin_;
+ _LIBCPP_NO_UNIQUE_ADDRESS _If<__slide_caches_last<_View>, __non_propagating_cache<iterator_t<_View>>, __empty_cache> __cached_end_;
+
+ template <bool _Const>
+ class __iterator;
+ class __sentinel;
+
+public:
+ _LIBCPP_HIDE_FROM_ABI constexpr explicit slide_view(_View __base, range_difference_t<_View> __n)
+ : __base_(std::move(__base)), __n_(__n) {}
+
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto begin()
+ requires (!(__simple_view<_View> && __slide_caches_nothing<const _View>))
+ {
+ if constexpr (__slide_caches_first<_View>) {
+ __cached_begin_ = __iterator<false>(
+ ranges::begin(__base_),
+ ranges::next(ranges::begin(__base_), __n_ - 1, ranges::end(__base_)),
+ __n_
+ );
+ return __cached_begin_;
+ }
+ else
+ return __iterator<false>(ranges::begin(__base_), __n_);
+ }
+
+ [[nodiscard]] _LIBCPP_HIDDEN constexpr auto begin() const
+ requires __slide_caches_nothing<const _View>
+ {
+ return __iterator<true>(ranges::begin(__base_), __n_);
+ }
+
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto end()
+ requires (!(__simple_view<_View> && __slide_caches_nothing<const _View>))
+ {
+ if constexpr (__slide_caches_nothing<_View>)
+ return __iterator<false>(ranges::begin(__base_) + range_difference_t<_View>(size()), __n_);
+ else if constexpr (__slide_caches_last<_View>) {
+ __cached_end_ = __iterator<false>(ranges::prev(ranges::end(__base_), __n_ - 1, ranges::begin(__base_)), __n_);
+ return __cached_end_;
+ }
+ else if constexpr (common_range<_View>)
+ return __iterator<false>(ranges::end(__base_), ranges::end(__base_), __n_);
+ else
+ return __sentinel(ranges::end(__base_));
+ }
+
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto end() const
+ requires __slide_caches_nothing<const _View>
+ {
+ return begin() + ange_difference_t<const _View>(size());
+ }
+
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto size()
+ requires sized_range<_View>
+ {
+ auto __sz = ranges::distance(__base_) - __n_ + 1;
+ if (__sz < 0)
+ __sz = 0;
+ return __to_unsigned_like(__sz);
+ }
+
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto size() const
+ requires sized_range<const _View>
+ {
+ auto __sz = ranges::distance(__base_) - __n_ + 1;
+ if (__sz < 0)
+ __sz = 0;
+ return __to_unsigned_like(__sz);
+ }
+};
+
+template <forward_range _View>
+ requires view<_View>
+template <bool _Const>
+class slide_view<_View>::__iterator {
+ friend slide_view;
+ using _Base = _If<_Const, const _View, _View>;
+
+ _LIBCPP_NO_UNIQUE_ADDRESS iterator_t<_Base> __current_;
+ _LIBCPP_NO_UNIQUE_ADDRESS _If<__slide_caches_first<_Base>, iterator_t<_Base>, __empty_cache> __last_ele_;
+ _LIBCPP_NO_UNIQUE_ADDRESS range_difference_t<_Base> __n_;
+
+ _LIBCPP_HIDE_FROM_ABI constexpr __iterator(iterator_t<_Base> __current, range_difference_t<_Base> __n)
+ requires (!__slide_caches_first<_Base>)
+ : __current_(__current),
+ __n_(__n) {}
+
+ _LIBCPP_HIDE_FROM_ABI constexpr __iterator(iterator_t<_Base> __current, iterator_t<_Base> __last_ele, range_difference_t<_Base> __n)
+ requires __slide_caches_first<_Base>
+ : __current_(__current),
+ __last_ele_(__last_ele),
+ __n_(__n) {}
+
+ [[nodiscard]] static consteval auto __get_iterator_concept() {
+ if constexpr (random_access_range<_Base>)
+ return random_access_iterator_tag{};
+ else if constexpr (bidirectional_range<_Base>)
+ return bidirectional_iterator_tag{};
+ else
+ return forward_iterator_tag{};
+ }
+
+public:
+ using iterator_category = std::input_iterator_tag;
+ using iterator_concept = decltype(__get_iterator_concept());
+ using value_type = decltype(views::counted(__current_, __n_));
+ using difference_type = range_difference_t<_Base>;
+
+ _LIBCPP_HIDE_FROM_ABI __iterator()
+ : __current_(iterator_t<_Base>()),
+ __last_ele_(_If<__slide_caches_first<_Base>, iterator_t<_Base>, __empty_cache>()),
+ __n_(0) {}
+
+ _LIBCPP_HIDE_FROM_ABI __iterator(__iterator<!_Const> __i)
+ requires _Const && convertible_to<iterator_t<_View>, iterator_t<_Base>>
+ : __current_(std::move(__i.__current_)),
+ __n_(__i.__n_) {}
+
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator*() const {
+ return views::counted(__current_, __n_);
+ }
+
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator[](difference_type __pos) const
+ requires random_access_range<_Base>
+ {
+ return views::counted(__current_ + __pos, __n_);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr __iterator& operator++() {
+ __current_ = ranges::next(__current_);
+ if constexpr (__slide_caches_first<_Base>)
+ __last_ele_ = ranges::next(__last_ele_);
+ return *this;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr __iterator operator++(int) {
+ auto __tmp = *this;
+ ++*this;
+ return __tmp;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr __iterator operator--()
+ requires bidirectional_range<_Base>
+ {
+ __current_ = ranges::prev(__current_);
+ if constexpr (__slide_caches_first<_Base>)
+ __last_ele_ = ranges::prev(__last_ele_);
+ return *this;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr __iterator operator--(int)
+ requires bidirectional_range<_Base>
+ {
+ auto __tmp = *this;
+ --*this;
+ return __tmp;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr __iterator& operator+=(difference_type __n)
+ requires random_access_range<_Base>
+ {
+ __current_ = __current_ + __n;
+ if constexpr (__slide_caches_first<_Base>)
+ __last_ele_ = __last_ele_ + __n;
+ return *this;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr __iterator& operator-=(difference_type __n)
+ requires random_access_range<_Base>
+ {
+ __current_ = __current_ - __n;
+ if constexpr (__slide_caches_first<_Base>)
+ __last_ele_ = __last_ele_ - __n;
+ return *this;
+ }
+
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const __iterator& __x, const __iterator& __y) {
+ if constexpr (__slide_caches_first<_Base>)
+ return __x.__last_ele_ == __y.__last_ele_;
+ else
+ return __x.__current_ == __y.__current_;
+ }
+
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator<(const __iterator& __x, const __iterator& __y)
+ requires random_access_range<_Base>
+ {
+ return __x.__current_ < __y.__current_;
+ }
+
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator>(const __iterator& __x, const __iterator& __y)
+ requires random_access_range<_Base>
+ {
+ return __y < __x;
+ }
+
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator<=(const __iterator& __x, const __iterator& __y)
+ requires random_access_range<_Base>
+ {
+ return !(__y < __x);
+ }
+
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator>=(const __iterator& __x, const __iterator& __y)
+ requires random_access_range<_Base>
+ {
+ return !(__x < __y);
+ }
+
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr auto operator<=>(const __iterator& __x, const __iterator& __y)
+ requires random_access_range<_Base> && three_way_comparable<iterator_t<_Base>>
+ {
+ return __x.__current_ <=> __y.__current_;
+ }
+
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator
+ operator+(const __iterator& __i, difference_type __pos)
+ requires random_access_range<_Base>
+ {
+ auto __r = __i;
+ __r += __pos;
+ return __r;
+ }
+
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator
+ operator+(difference_type __pos, const __iterator& __i)
+ requires random_access_range<_Base>
+ {
+ auto __r = __i;
+ __r += __pos;
+ return __r;
+ }
+
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator
+ operator-(const __iterator& __i, difference_type __pos)
+ requires random_access_range<_Base>
+ {
+ auto __r = __i;
+ __r -= __pos;
+ return __r;
+ }
+
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr difference_type
+ operator-(const __iterator& __i, const __iterator& __j)
+ requires sized_sentinel_for<iterator_t<_Base>, iterator_t<_Base>>
+ {
+ if constexpr (__slide_caches_first<_View>)
+ return __i.__last_ele_ - __j.__last_ele_;
+ else
+ return __i.__current_ - __j.__current_;
+ }
+};
+
+template <forward_range _View>
+ requires view<_View>
+class slide_view<_View>::__sentinel {
+ sentinel_t<_View> __end_;
+
+ _LIBCPP_HIDE_FROM_ABI constexpr __sentinel(sentinel_t<_View> __end)
+ : __end_(__end) {}
+
+public:
+ _LIBCPP_HIDE_FROM_ABI constexpr __sentinel() = default;
+
+ template <bool _Const>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const __iterator<_Const>& __x, const __sentinel& __y) {
+ return __x.__last_ele_ == __y.__end_;
+ }
+
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr range_difference_t<_View> operator-(const __iterator<false>& __x, const __sentinel& __y)
+ requires disable_sized_sentinel_for<sentinel_t<_View>, iterator_t<_View>>
+ {
+ return __x.__last_ele_ - __y.__end_;
+ }
+
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr range_difference_t<_View> operator-(const __sentinel& __y, const __iterator<false>& __x)
+ requires disable_sized_sentinel_for<sentinel_t<_View>, iterator_t<_View>>
+ {
+ return __y.__end_ - __x.__last_ele_;
+ }
+};
+
+template <class _Range>
+slide_view(_Range&&, range_difference_t<_Range>) -> slide_view<views::all_t<_Range>>;
+
+template <class _View>
+inline constexpr bool enable_borrowed_range<slide_view<_View>> = enable_borrowed_range<_View>;
+
+namespace views {
+namespace __slide {
+struct __fn {
+ template <viewable_range _Range>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto
+ operator()(_Range&& __range, range_difference_t<_Range> __n) noexcept(
+ noexcept(/*-----*/ slide_view(std::forward<_Range>(__range), std::forward<range_difference_t<_Range>>(__n))))
+ -> decltype(/*--*/ slide_view(std::forward<_Range>(__range), std::forward<range_difference_t<_Range>>(__n))) {
+ return /*---------*/ slide_view(std::forward<_Range>(__range), std::forward<range_difference_t<_Range>>(__n));
+ }
+
+ template <class _DifferenceType>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto
+ operator()(_DifferenceType __n) noexcept(is_nothrow_constructible_v<decay_t<_DifferenceType>, _DifferenceType>) {
+ return __pipeable(std::__bind_back(__fn{}, std::forward<_DifferenceType>(__n)));
+ }
+};
+
+} // namespace __slide
+
+inline namespace __cpo {
+inline constexpr auto slide = __slide::__fn{};
+
+} // namespace __cpo
+} // namespace views
+
+} // namespace ranges
+
+#endif // _LIBCPP_STD_VER >= 23
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___RANGES_SLIDE_VIEW_H
>From 2edbccb746572b983052f841352566c296adaf38 Mon Sep 17 00:00:00 2001
From: anonymouspc <shyeyian at petalmail.com>
Date: Fri, 19 Dec 2025 12:10:22 +0800
Subject: [PATCH 3/3] Small fix over the past 2 commits
Tiny fix on PR-number and <ranges>.
---
libcxx/docs/ReleaseNotes/22.rst | 2 +-
libcxx/include/ranges | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/libcxx/docs/ReleaseNotes/22.rst b/libcxx/docs/ReleaseNotes/22.rst
index aea8e3157032c..40207d2157777 100644
--- a/libcxx/docs/ReleaseNotes/22.rst
+++ b/libcxx/docs/ReleaseNotes/22.rst
@@ -49,7 +49,7 @@ Implemented Papers
- P2835R7: Expose ``std::atomic_ref``'s object address (`Github <https://llvm.org/PR118377>`__)
- P2944R3: Comparisons for ``reference_wrapper`` (`Github <https://llvm.org/PR105424>`__)
- P3168R2: Give ``std::optional`` Range Support (`Github <https://llvm.org/PR105430>`__)
-- P2442R1: P2442R1: Windowing range adaptors: ``views::chunk`` and ``views::slide`` (`Github <https://llvm.org/PR171234>`__) (Implemented ``views::slide`` only)
+- P2442R1: P2442R1: Windowing range adaptors: ``views::chunk`` and ``views::slide`` (`Github <https://llvm.org/PR172948>`__) (Implemented ``views::slide`` only)
Improvements and New Features
-----------------------------
diff --git a/libcxx/include/ranges b/libcxx/include/ranges
index 6a07e0312da46..7d37dabfd6e19 100644
--- a/libcxx/include/ranges
+++ b/libcxx/include/ranges
@@ -477,10 +477,10 @@ namespace std {
# include <__ranges/adjacent_view.h>
# include <__ranges/as_rvalue_view.h>
# include <__ranges/chunk_by_view.h>
-# include <__ranges/chunk_view.h>
# include <__ranges/from_range.h>
# include <__ranges/join_with_view.h>
# include <__ranges/repeat_view.h>
+# include <__ranges/slide_view.h>
# include <__ranges/to.h>
# include <__ranges/zip_transform_view.h>
# include <__ranges/zip_view.h>
More information about the libcxx-commits
mailing list