Skip to content

Commit 3f5b8ff

Browse files
frederick-vs-jaCaseyCarterStephanTLavavej
authored
LWG-3610: iota_view::size sometimes rejects integer-class types (#2542)
Co-authored-by: Casey Carter <[email protected]> Co-authored-by: Stephan T. Lavavej <[email protected]>
1 parent 624b2ae commit 3f5b8ff

File tree

4 files changed

+57
-1
lines changed

4 files changed

+57
-1
lines changed

stl/inc/ranges

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1265,7 +1265,7 @@ namespace ranges {
12651265
// clang-format off
12661266
_NODISCARD constexpr auto size() const noexcept(noexcept(_Bound - _Value)) /* strengthened */
12671267
requires (same_as<_Wi, _Bo> && _Advanceable<_Wi>)
1268-
|| (integral<_Wi> && integral<_Bo>)
1268+
|| (_Integer_like<_Wi> && _Integer_like<_Bo>)
12691269
|| sized_sentinel_for<_Bo, _Wi> {
12701270
// clang-format on
12711271
if constexpr (_Integer_like<_Wi> && _Integer_like<_Bo>) {

tests/std/test.lst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ tests\LWG3018_shared_ptr_function
196196
tests\LWG3146_excessive_unwrapping_ref_cref
197197
tests\LWG3422_seed_seq_ctors
198198
tests\LWG3480_directory_iterator_range
199+
tests\LWG3610_iota_view_size_and_integer_class
199200
tests\P0019R8_atomic_ref
200201
tests\P0024R2_parallel_algorithms_adjacent_difference
201202
tests\P0024R2_parallel_algorithms_adjacent_find
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3+
4+
RUNALL_INCLUDE ..\concepts_20_matrix.lst
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3+
4+
#include <ranges>
5+
6+
using namespace std;
7+
8+
template <class R>
9+
concept CanSize = requires(R& r) {
10+
ranges::size(r);
11+
};
12+
13+
// Validate standard signed integer types
14+
static_assert(CanSize<ranges::iota_view<signed char, _Signed128>>);
15+
static_assert(CanSize<ranges::iota_view<signed char, _Unsigned128>>);
16+
static_assert(CanSize<ranges::iota_view<short, _Signed128>>);
17+
static_assert(CanSize<ranges::iota_view<short, _Unsigned128>>);
18+
static_assert(CanSize<ranges::iota_view<int, _Signed128>>);
19+
static_assert(CanSize<ranges::iota_view<int, _Unsigned128>>);
20+
static_assert(CanSize<ranges::iota_view<long, _Signed128>>);
21+
static_assert(CanSize<ranges::iota_view<long, _Unsigned128>>);
22+
static_assert(CanSize<ranges::iota_view<long long, _Signed128>>);
23+
static_assert(CanSize<ranges::iota_view<long long, _Unsigned128>>);
24+
25+
// Validate standard unsigned integer types
26+
static_assert(CanSize<ranges::iota_view<unsigned char, _Signed128>>);
27+
static_assert(CanSize<ranges::iota_view<unsigned char, _Unsigned128>>);
28+
static_assert(CanSize<ranges::iota_view<unsigned short, _Signed128>>);
29+
static_assert(CanSize<ranges::iota_view<unsigned short, _Unsigned128>>);
30+
static_assert(CanSize<ranges::iota_view<unsigned int, _Signed128>>);
31+
static_assert(CanSize<ranges::iota_view<unsigned int, _Unsigned128>>);
32+
static_assert(CanSize<ranges::iota_view<unsigned long, _Signed128>>);
33+
static_assert(CanSize<ranges::iota_view<unsigned long, _Unsigned128>>);
34+
static_assert(CanSize<ranges::iota_view<unsigned long long, _Signed128>>);
35+
static_assert(CanSize<ranges::iota_view<unsigned long long, _Unsigned128>>);
36+
37+
// Validate other integer types (other than bool)
38+
static_assert(CanSize<ranges::iota_view<char, _Signed128>>);
39+
static_assert(CanSize<ranges::iota_view<char, _Unsigned128>>);
40+
static_assert(CanSize<ranges::iota_view<wchar_t, _Signed128>>);
41+
static_assert(CanSize<ranges::iota_view<wchar_t, _Unsigned128>>);
42+
#ifdef __cpp_char8_t
43+
static_assert(CanSize<ranges::iota_view<char8_t, _Signed128>>);
44+
static_assert(CanSize<ranges::iota_view<char8_t, _Unsigned128>>);
45+
#endif // __cpp_char8_t
46+
static_assert(CanSize<ranges::iota_view<char16_t, _Signed128>>);
47+
static_assert(CanSize<ranges::iota_view<char16_t, _Unsigned128>>);
48+
static_assert(CanSize<ranges::iota_view<char32_t, _Signed128>>);
49+
static_assert(CanSize<ranges::iota_view<char32_t, _Unsigned128>>);
50+
51+
int main() {} // COMPILE-ONLY

0 commit comments

Comments
 (0)