From 1382514c5e09d8e888fc728e6cbb1fba2a452c98 Mon Sep 17 00:00:00 2001 From: Jakub Mazurkiewicz Date: Thu, 28 Jul 2022 04:13:05 +0200 Subject: [PATCH] Implement LWG-3707: `chunk_view::outer-iterator::value_type::size` should return unsigned type (#2883) --- stl/inc/ranges | 3 ++- tests/std/tests/P2442R1_views_chunk/test.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/stl/inc/ranges b/stl/inc/ranges index 6d20dc78589..a504f4cfe8d 100644 --- a/stl/inc/ranges +++ b/stl/inc/ranges @@ -5380,7 +5380,8 @@ namespace ranges { _NODISCARD constexpr auto size() const noexcept(noexcept(_RANGES end(_Parent->_Range) - *_Parent->_Current)) /* strengthened */ requires sized_sentinel_for, iterator_t<_Vw>> { - return (_STD min)(_Parent->_Remainder, _RANGES end(_Parent->_Range) - *_Parent->_Current); + return _To_unsigned_like( + (_STD min)(_Parent->_Remainder, _RANGES end(_Parent->_Range) - *_Parent->_Current)); } }; diff --git a/tests/std/tests/P2442R1_views_chunk/test.cpp b/tests/std/tests/P2442R1_views_chunk/test.cpp index f2f14cb4ea0..95b9b86d23e 100644 --- a/tests/std/tests/P2442R1_views_chunk/test.cpp +++ b/tests/std/tests/P2442R1_views_chunk/test.cpp @@ -465,7 +465,8 @@ constexpr bool test_input(Rng&& rng, Expected&& expected) { auto val_ty = *outer_iter; if constexpr (sized_sentinel_for, iterator_t>) { - assert(val_ty.size() == 2); + const same_as<_Make_unsigned_like_t>> auto s = val_ty.size(); // test LWG-3707 + assert(s == 2); } auto inner_iter = val_ty.begin();