-
Notifications
You must be signed in to change notification settings - Fork 14.7k
[libc++][ranges] LWG4096: views::iota(views::iota(0))
should be rejected
#152855
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
Open
H-G-Hristov
wants to merge
10
commits into
llvm:main
Choose a base branch
from
H-G-Hristov:hgh/libcxx/LWG4096-ranges_iota_zero
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[libc++][ranges] LWG4096: views::iota(views::iota(0))
should be rejected
#152855
H-G-Hristov
wants to merge
10
commits into
llvm:main
from
H-G-Hristov:hgh/libcxx/LWG4096-ranges_iota_zero
+17
−4
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: #105352 Full diff: https://github.com/llvm/llvm-project/pull/152855.diff 3 Files Affected:
diff --git a/libcxx/docs/Status/Cxx2cIssues.csv b/libcxx/docs/Status/Cxx2cIssues.csv
index 6fcb2f3c78cfc..9b61c921c8db4 100644
--- a/libcxx/docs/Status/Cxx2cIssues.csv
+++ b/libcxx/docs/Status/Cxx2cIssues.csv
@@ -71,7 +71,7 @@
"`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)","","",""
-"`LWG4096 <https://wg21.link/LWG4096>`__","``views::iota(views::iota(0))`` should be rejected","2024-06 (St. Louis)","","",""
+"`LWG4096 <https://wg21.link/LWG4096>`__","``views::iota(views::iota(0))`` should be rejected","2024-06 (St. Louis)","|Complete|","22",""
"`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)","","",""
"`LWG4106 <https://wg21.link/LWG4106>`__","``basic_format_args`` should not be default-constructible","2024-06 (St. Louis)","|Complete|","19",""
diff --git a/libcxx/include/__ranges/iota_view.h b/libcxx/include/__ranges/iota_view.h
index 4b84585258b91..79a450a9ce40c 100644
--- a/libcxx/include/__ranges/iota_view.h
+++ b/libcxx/include/__ranges/iota_view.h
@@ -30,6 +30,7 @@
#include <__ranges/movable_box.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/type_identity.h>
@@ -377,7 +378,7 @@ struct __fn {
_LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Start&& __start) const
noexcept(noexcept(ranges::iota_view(std::forward<_Start>(__start))))
-> decltype(ranges::iota_view(std::forward<_Start>(__start))) {
- return ranges::iota_view(std::forward<_Start>(__start));
+ return ranges::iota_view<decay_t<_Start>>(std::forward<_Start>(__start));
}
template <class _Start, class _BoundSentinel>
diff --git a/libcxx/test/std/ranges/range.factories/range.iota.view/views_iota.verify.cpp b/libcxx/test/std/ranges/range.factories/range.iota.view/views_iota.verify.cpp
new file mode 100644
index 0000000000000..9f1879968eebc
--- /dev/null
+++ b/libcxx/test/std/ranges/range.factories/range.iota.view/views_iota.verify.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: std-at-least-c++20
+
+// views::iota
+
+#include <ranges>
+
+#include "types.h"
+
+void test() {
+ // LWG4096
+ {
+ [[maybe_unused]] auto i1 = std::views::iota(0); // OK
+ [[maybe_unused]] auto i2 = std::views::iota(std::views::iota(0));
+ // expected-error-re@*:* {{constraints not satisfied for class template 'iota_view'{{.*}}}}
+ }
+ {
+ [[maybe_unused]] auto i1 = std::views::iota(SomeInt(0)); // OK
+ [[maybe_unused]] auto i2 = std::views::iota(std::views::iota(SomeInt(0)));
+ //expected-error-re@*:* {{constraints not satisfied for class template 'iota_view'{{.*}}}}
+ }
+}
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
philnik777
reviewed
Aug 9, 2025
libcxx/test/std/ranges/range.factories/range.iota.view/views_iota.verify.cpp
Outdated
Show resolved
Hide resolved
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: #105352