-
Notifications
You must be signed in to change notification settings - Fork 15k
[libc++][ranges] LWG4083: views::as_rvalue
should reject non-input ranges
#155156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
frederick-vs-ja
merged 4 commits into
llvm:main
from
H-G-Hristov:hgh/libcxx/LWG4083--views--as_rvalue-should-reject-non-input-ranges
Sep 3, 2025
Merged
[libc++][ranges] LWG4083: views::as_rvalue
should reject non-input ranges
#155156
frederick-vs-ja
merged 4 commits into
llvm:main
from
H-G-Hristov:hgh/libcxx/LWG4083--views--as_rvalue-should-reject-non-input-ranges
Sep 3, 2025
+14
−2
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@llvm/pr-subscribers-libcxx Author: Hristo Hristov (H-G-Hristov) ChangesFixes #105351 References:Full diff: https://github.com/llvm/llvm-project/pull/155156.diff 3 Files Affected:
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};
|
…reject-non-input-ranges
…reject-non-input-ranges
frederick-vs-ja
approved these changes
Sep 3, 2025
There was a problem hiding this 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.
Thank you! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #105351
References: