Skip to content

Conversation

H-G-Hristov
Copy link
Contributor

@H-G-Hristov H-G-Hristov requested a review from a team as a code owner August 24, 2025 10:07
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Aug 24, 2025
@llvmbot
Copy link
Member

llvmbot commented Aug 24, 2025

@llvm/pr-subscribers-libcxx

Author: Hristo Hristov (H-G-Hristov)

Changes

Fixes #105351

References:


Full diff: https://github.com/llvm/llvm-project/pull/155156.diff

3 Files Affected:

  • (modified) libcxx/docs/Status/Cxx2cIssues.csv (+1-1)
  • (modified) libcxx/include/__ranges/as_rvalue_view.h (+1-1)
  • (modified) libcxx/test/std/ranges/range.adaptors/range.as.rvalue/adaptor.pass.cpp (+10)
diff --git a/libcxx/docs/Status/Cxx2cIssues.csv b/libcxx/docs/Status/Cxx2cIssues.csv
index 6fcb2f3c78cfc..f843a6fafc6dc 100644
--- a/libcxx/docs/Status/Cxx2cIssues.csv
+++ b/libcxx/docs/Status/Cxx2cIssues.csv
@@ -70,7 +70,7 @@
 "`LWG4076 <https://wg21.link/LWG4076>`__","``concat_view`` should be freestanding","2024-06 (St. Louis)","","",""
 "`LWG4079 <https://wg21.link/LWG4079>`__","Missing Preconditions in ``concat_view::iterator``\`s conversion constructor","2024-06 (St. Louis)","","",""
 "`LWG4082 <https://wg21.link/LWG4082>`__","``views::concat(r)`` is well-formed when ``r`` is an ``output_range``","2024-06 (St. Louis)","","",""
-"`LWG4083 <https://wg21.link/LWG4083>`__","``views::as_rvalue`` should reject non-input ranges","2024-06 (St. Louis)","","",""
+"`LWG4083 <https://wg21.link/LWG4083>`__","``views::as_rvalue`` should reject non-input ranges","2024-06 (St. Louis)","|Complete|","22",""
 "`LWG4096 <https://wg21.link/LWG4096>`__","``views::iota(views::iota(0))`` should be rejected","2024-06 (St. Louis)","","",""
 "`LWG4098 <https://wg21.link/LWG4098>`__","``views::adjacent<0>`` should reject non-forward ranges","2024-06 (St. Louis)","","",""
 "`LWG4105 <https://wg21.link/LWG4105>`__","``ranges::ends_with``\`s Returns misses difference casting","2024-06 (St. Louis)","","",""
diff --git a/libcxx/include/__ranges/as_rvalue_view.h b/libcxx/include/__ranges/as_rvalue_view.h
index 5849a6c368396..08acf3d7736c6 100644
--- a/libcxx/include/__ranges/as_rvalue_view.h
+++ b/libcxx/include/__ranges/as_rvalue_view.h
@@ -117,7 +117,7 @@ struct __fn : __range_adaptor_closure<__fn> {
     return /*---------------------------------*/ as_rvalue_view(std::forward<_Range>(__range));
   }
 
-  template <class _Range>
+  template <input_range _Range>
     requires same_as<range_rvalue_reference_t<_Range>, range_reference_t<_Range>>
   [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto
   operator()(_Range&& __range) noexcept(noexcept(views::all(std::forward<_Range>(__range))))
diff --git a/libcxx/test/std/ranges/range.adaptors/range.as.rvalue/adaptor.pass.cpp b/libcxx/test/std/ranges/range.adaptors/range.as.rvalue/adaptor.pass.cpp
index dbe15238ebc86..88b28b0ec9832 100644
--- a/libcxx/test/std/ranges/range.adaptors/range.as.rvalue/adaptor.pass.cpp
+++ b/libcxx/test/std/ranges/range.adaptors/range.as.rvalue/adaptor.pass.cpp
@@ -48,6 +48,16 @@ struct move_iterator_range {
 static_assert(!std::ranges::view<move_iterator_range>);
 static_assert(std::ranges::range<move_iterator_range>);
 
+// LWG4083: views::as_rvalue should reject non-input ranges
+struct I {
+  int operator*();
+  using difference_type = int;
+  I& operator++();
+  void operator++(int);
+};
+static_assert(
+    !HasPipe<decltype(std::ranges::subrange{I{}, std::unreachable_sentinel}), decltype(std::views::as_rvalue)>);
+
 constexpr bool test() {
   { // view | views::as_rvalue
     DefaultConstructibleView v{{}, 3};

@Zingam Zingam added the ranges Issues related to `<ranges>` label Sep 3, 2025
Copy link
Contributor

@frederick-vs-ja frederick-vs-ja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Looks like that CI will be green soon.

@frederick-vs-ja frederick-vs-ja merged commit 759a2ac into llvm:main Sep 3, 2025
79 checks passed
@Zingam
Copy link
Contributor

Zingam commented Sep 3, 2025

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. ranges Issues related to `<ranges>`
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LWG4083: views::as_rvalue should reject non-input ranges
4 participants