[libcxx-commits] [libcxx] b844cc8 - [libc++][ranges] LWG3610: `iota_view::size` sometimes rejects integer-class types (#155169)
via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Apr 12 07:25:41 PDT 2026
Author: Hristo Hristov
Date: 2026-04-12T17:25:36+03:00
New Revision: b844cc8f8de9bfbd003cbe01e1295563c4ca62e6
URL: https://github.com/llvm/llvm-project/commit/b844cc8f8de9bfbd003cbe01e1295563c4ca62e6
DIFF: https://github.com/llvm/llvm-project/commit/b844cc8f8de9bfbd003cbe01e1295563c4ca62e6.diff
LOG: [libc++][ranges] LWG3610: `iota_view::size` sometimes rejects integer-class types (#155169)
Fixes #104948
# References
- https://wg21.link/range.iota.view
- https://wg21.link/range.iota.view#17
- https://wg21.link/LWG3610
---------
Co-authored-by: A. Jiang <de34 at live.cn>
Added:
Modified:
libcxx/docs/Status/Cxx23Issues.csv
libcxx/include/__ranges/iota_view.h
libcxx/test/std/ranges/range.factories/range.iota.view/size.pass.cpp
Removed:
################################################################################
diff --git a/libcxx/docs/Status/Cxx23Issues.csv b/libcxx/docs/Status/Cxx23Issues.csv
index 085fa42d13c64..0a2f0d59484de 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)","","","`#104945 <https://github.com/llvm/llvm-project/issues/104945>`__",""
"`LWG3601 <https://wg21.link/LWG3601>`__","common_iterator's postfix-proxy needs ``indirectly_readable`` ","2022-02 (Virtual)","","","`#104946 <https://github.com/llvm/llvm-project/issues/104946>`__",""
"`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|","","`#104947 <https://github.com/llvm/llvm-project/issues/104947>`__",""
-"`LWG3610 <https://wg21.link/LWG3610>`__","``iota_view::size`` sometimes rejects integer-class types","2022-02 (Virtual)","","","`#104948 <https://github.com/llvm/llvm-project/issues/104948>`__",""
+"`LWG3610 <https://wg21.link/LWG3610>`__","``iota_view::size`` sometimes rejects integer-class types","2022-02 (Virtual)","|Complete|","23","`#104948 <https://github.com/llvm/llvm-project/issues/104948>`__",""
"`LWG3612 <https://wg21.link/LWG3612>`__","Inconsistent pointer alignment in ``std::format`` ","2022-02 (Virtual)","|Complete|","14","`#104949 <https://github.com/llvm/llvm-project/issues/104949>`__",""
"`LWG3616 <https://wg21.link/LWG3616>`__","LWG 3498 seems to miss the non-member ``swap`` for ``basic_syncbuf`` ","2022-02 (Virtual)","|Complete|","18","`#104950 <https://github.com/llvm/llvm-project/issues/104950>`__",""
"`LWG3618 <https://wg21.link/LWG3618>`__","Unnecessary ``iter_move`` for ``transform_view::iterator`` ","2022-02 (Virtual)","|Complete|","19","`#104951 <https://github.com/llvm/llvm-project/issues/104951>`__",""
diff --git a/libcxx/include/__ranges/iota_view.h b/libcxx/include/__ranges/iota_view.h
index 6b2576ec6b23d..29f96545ab34f 100644
--- a/libcxx/include/__ranges/iota_view.h
+++ b/libcxx/include/__ranges/iota_view.h
@@ -357,7 +357,7 @@ class iota_view : public view_interface<iota_view<_Start, _BoundSentinel>> {
[[nodiscard]] _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 8563b85f65dbd..1372824f176fa 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,13 @@
#include <ranges>
#include "test_macros.h"
+#include "type_algorithms.h"
+
#include "types.h"
+template <typename T>
+concept HasSize = requires(const T t) { t.size(); };
+
constexpr bool test() {
// Both are integer like and both are less than zero.
{
@@ -99,6 +104,17 @@ constexpr bool test() {
assert(sz == 10);
}
+ // LWG3610: `iota_view::size` sometimes rejects integer-class types
+ // libc++ does not have integer-class types, so the resolution only impacts uses with `bool`.
+ {
+ types::for_each(types::integer_types{}, []<typename IntegerLikeT>() {
+ types::for_each(types::integer_types{}, []<typename BoundT>() {
+ // libc++ does not have integer-class types
+ static_assert(!HasSize<std::ranges::iota_view<IntegerLikeT, bool>>);
+ });
+ });
+ }
+
return true;
}
More information about the libcxx-commits
mailing list