[libcxx-commits] [libcxx] [libc++][ranges] LWG3610: `iota_view::size` sometimes rejects integer-class types (PR #155169)
Hristo Hristov via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Aug 25 01:28:42 PDT 2025
https://github.com/H-G-Hristov updated https://github.com/llvm/llvm-project/pull/155169
>From 44284cde6d74a8c0a849f9f30feb23a37a796820 Mon Sep 17 00:00:00 2001
From: Hristo Hristov <hghristov.rmm at gmail.com>
Date: Sun, 24 Aug 2025 13:44:49 +0300
Subject: [PATCH 1/2] [libc++][ranges] LWG3610: iota_view::size sometimes
rejects integer-class types
Fixes #104948
- https://wg21.link/LWG3610
---
libcxx/docs/Status/Cxx23Issues.csv | 2 +-
libcxx/include/__ranges/iota_view.h | 2 +-
.../range.iota.view/size.pass.cpp | 18 ++++++++++++++++++
3 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/libcxx/docs/Status/Cxx23Issues.csv b/libcxx/docs/Status/Cxx23Issues.csv
index 189f8452e0678..38571dabae463 100644
--- a/libcxx/docs/Status/Cxx23Issues.csv
+++ b/libcxx/docs/Status/Cxx23Issues.csv
@@ -143,7 +143,7 @@
"`LWG3598 <https://wg21.link/LWG3598>`__","``system_category().default_error_condition(0)`` is underspecified","2022-02 (Virtual)","","",""
"`LWG3601 <https://wg21.link/LWG3601>`__","common_iterator's postfix-proxy needs ``indirectly_readable`` ","2022-02 (Virtual)","","",""
"`LWG3607 <https://wg21.link/LWG3607>`__","``contiguous_iterator`` should not be allowed to have custom ``iter_move`` and ``iter_swap`` behavior","2022-02 (Virtual)","|Nothing To Do|","",""
-"`LWG3610 <https://wg21.link/LWG3610>`__","``iota_view::size`` sometimes rejects integer-class types","2022-02 (Virtual)","","",""
+"`LWG3610 <https://wg21.link/LWG3610>`__","``iota_view::size`` sometimes rejects integer-class types","2022-02 (Virtual)","|Complete|","22",""
"`LWG3612 <https://wg21.link/LWG3612>`__","Inconsistent pointer alignment in ``std::format`` ","2022-02 (Virtual)","|Complete|","14",""
"`LWG3616 <https://wg21.link/LWG3616>`__","LWG 3498 seems to miss the non-member ``swap`` for ``basic_syncbuf`` ","2022-02 (Virtual)","|Complete|","18",""
"`LWG3618 <https://wg21.link/LWG3618>`__","Unnecessary ``iter_move`` for ``transform_view::iterator`` ","2022-02 (Virtual)","|Complete|","19",""
diff --git a/libcxx/include/__ranges/iota_view.h b/libcxx/include/__ranges/iota_view.h
index 4b84585258b91..cf401a4665fcd 100644
--- a/libcxx/include/__ranges/iota_view.h
+++ b/libcxx/include/__ranges/iota_view.h
@@ -348,7 +348,7 @@ class iota_view : public view_interface<iota_view<_Start, _BoundSentinel>> {
_LIBCPP_HIDE_FROM_ABI constexpr auto size() const
requires(same_as<_Start, _BoundSentinel> && __advanceable<_Start>) ||
- (integral<_Start> && integral<_BoundSentinel>) || sized_sentinel_for<_BoundSentinel, _Start>
+ (__integer_like<_Start> && __integer_like<_BoundSentinel>) || sized_sentinel_for<_BoundSentinel, _Start>
{
if constexpr (__integer_like<_Start> && __integer_like<_BoundSentinel>) {
return (__value_ < 0)
diff --git a/libcxx/test/std/ranges/range.factories/range.iota.view/size.pass.cpp b/libcxx/test/std/ranges/range.factories/range.iota.view/size.pass.cpp
index b894bc542be10..90afec2fba177 100644
--- a/libcxx/test/std/ranges/range.factories/range.iota.view/size.pass.cpp
+++ b/libcxx/test/std/ranges/range.factories/range.iota.view/size.pass.cpp
@@ -16,8 +16,21 @@
#include <ranges>
#include "test_macros.h"
+#define TEST_HAS_NO_INT128
+#include "type_algorithms.h"
#include "types.h"
+template <typename T>
+concept HasSize = requires(const T t) { t.size(); };
+
+struct CheckForSize {
+ template <class T>
+ constexpr void operator()() {
+ static_assert(HasSize<std::ranges::iota_view<T, int>>);
+ static_assert(HasSize<std::ranges::iota_view<T, T>>);
+ }
+};
+
constexpr bool test() {
// Both are integer like and both are less than zero.
{
@@ -99,6 +112,11 @@ constexpr bool test() {
assert(sz == 10);
}
+ // LWG3610: `iota_view::size` sometimes rejects integer-class types
+ {
+ types::for_each(types::integer_types{}, CheckForSize{});
+ }
+
return true;
}
>From bee2ac2a7a4da6b6f234106cbb3070577bf49a96 Mon Sep 17 00:00:00 2001
From: Hristo Hristov <hghristov.rmm at gmail.com>
Date: Mon, 25 Aug 2025 11:28:26 +0300
Subject: [PATCH 2/2] Updated test
---
.../ranges/range.factories/range.iota.view/size.pass.cpp | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/libcxx/test/std/ranges/range.factories/range.iota.view/size.pass.cpp b/libcxx/test/std/ranges/range.factories/range.iota.view/size.pass.cpp
index 90afec2fba177..315e581aed577 100644
--- a/libcxx/test/std/ranges/range.factories/range.iota.view/size.pass.cpp
+++ b/libcxx/test/std/ranges/range.factories/range.iota.view/size.pass.cpp
@@ -24,10 +24,11 @@ template <typename T>
concept HasSize = requires(const T t) { t.size(); };
struct CheckForSize {
- template <class T>
+ template <class IntegerLikeT>
constexpr void operator()() {
- static_assert(HasSize<std::ranges::iota_view<T, int>>);
- static_assert(HasSize<std::ranges::iota_view<T, T>>);
+ types::for_each(types::integer_types{}, []<typename BoundT>() {
+ static_assert(HasSize<std::ranges::iota_view<IntegerLikeT, BoundT>>);
+ });
}
};
More information about the libcxx-commits
mailing list