diff --git a/stl/inc/ranges b/stl/inc/ranges index 2610a4dbaab..53d630568d2 100644 --- a/stl/inc/ranges +++ b/stl/inc/ranges @@ -1265,7 +1265,7 @@ namespace ranges { // clang-format off _NODISCARD constexpr auto size() const noexcept(noexcept(_Bound - _Value)) /* strengthened */ requires (same_as<_Wi, _Bo> && _Advanceable<_Wi>) - || (integral<_Wi> && integral<_Bo>) + || (_Integer_like<_Wi> && _Integer_like<_Bo>) || sized_sentinel_for<_Bo, _Wi> { // clang-format on if constexpr (_Integer_like<_Wi> && _Integer_like<_Bo>) { diff --git a/tests/std/test.lst b/tests/std/test.lst index 40791d0adfe..a058f7157dc 100644 --- a/tests/std/test.lst +++ b/tests/std/test.lst @@ -196,6 +196,7 @@ tests\LWG3018_shared_ptr_function tests\LWG3146_excessive_unwrapping_ref_cref tests\LWG3422_seed_seq_ctors tests\LWG3480_directory_iterator_range +tests\LWG3610_iota_view_size_and_integer_class tests\P0019R8_atomic_ref tests\P0024R2_parallel_algorithms_adjacent_difference tests\P0024R2_parallel_algorithms_adjacent_find diff --git a/tests/std/tests/LWG3610_iota_view_size_and_integer_class/env.lst b/tests/std/tests/LWG3610_iota_view_size_and_integer_class/env.lst new file mode 100644 index 00000000000..d6d824b5879 --- /dev/null +++ b/tests/std/tests/LWG3610_iota_view_size_and_integer_class/env.lst @@ -0,0 +1,4 @@ +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +RUNALL_INCLUDE ..\concepts_20_matrix.lst diff --git a/tests/std/tests/LWG3610_iota_view_size_and_integer_class/test.compile.pass.cpp b/tests/std/tests/LWG3610_iota_view_size_and_integer_class/test.compile.pass.cpp new file mode 100644 index 00000000000..b97e4628c2e --- /dev/null +++ b/tests/std/tests/LWG3610_iota_view_size_and_integer_class/test.compile.pass.cpp @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include + +using namespace std; + +template +concept CanSize = requires(R& r) { + ranges::size(r); +}; + +// Validate standard signed integer types +static_assert(CanSize>); +static_assert(CanSize>); +static_assert(CanSize>); +static_assert(CanSize>); +static_assert(CanSize>); +static_assert(CanSize>); +static_assert(CanSize>); +static_assert(CanSize>); +static_assert(CanSize>); +static_assert(CanSize>); + +// Validate standard unsigned integer types +static_assert(CanSize>); +static_assert(CanSize>); +static_assert(CanSize>); +static_assert(CanSize>); +static_assert(CanSize>); +static_assert(CanSize>); +static_assert(CanSize>); +static_assert(CanSize>); +static_assert(CanSize>); +static_assert(CanSize>); + +// Validate other integer types (other than bool) +static_assert(CanSize>); +static_assert(CanSize>); +static_assert(CanSize>); +static_assert(CanSize>); +#ifdef __cpp_char8_t +static_assert(CanSize>); +static_assert(CanSize>); +#endif // __cpp_char8_t +static_assert(CanSize>); +static_assert(CanSize>); +static_assert(CanSize>); +static_assert(CanSize>); + +int main() {} // COMPILE-ONLY