Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LWG-3610: iota_view::size sometimes rejects integer-class types #2542

Merged
merged 5 commits into from
Feb 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion stl/inc/ranges
Original file line number Diff line number Diff line change
Expand Up @@ -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>) {
Expand Down
1 change: 1 addition & 0 deletions tests/std/test.lst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

RUNALL_INCLUDE ..\concepts_20_matrix.lst
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Copyright (c) Microsoft Corporation.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#include <ranges>

using namespace std;

template <class R>
concept CanSize = requires(R& r) {
ranges::size(r);
};

// Validate standard signed integer types
static_assert(CanSize<ranges::iota_view<signed char, _Signed128>>);
static_assert(CanSize<ranges::iota_view<signed char, _Unsigned128>>);
static_assert(CanSize<ranges::iota_view<short, _Signed128>>);
static_assert(CanSize<ranges::iota_view<short, _Unsigned128>>);
static_assert(CanSize<ranges::iota_view<int, _Signed128>>);
static_assert(CanSize<ranges::iota_view<int, _Unsigned128>>);
static_assert(CanSize<ranges::iota_view<long, _Signed128>>);
static_assert(CanSize<ranges::iota_view<long, _Unsigned128>>);
static_assert(CanSize<ranges::iota_view<long long, _Signed128>>);
static_assert(CanSize<ranges::iota_view<long long, _Unsigned128>>);

// Validate standard unsigned integer types
static_assert(CanSize<ranges::iota_view<unsigned char, _Signed128>>);
static_assert(CanSize<ranges::iota_view<unsigned char, _Unsigned128>>);
static_assert(CanSize<ranges::iota_view<unsigned short, _Signed128>>);
static_assert(CanSize<ranges::iota_view<unsigned short, _Unsigned128>>);
static_assert(CanSize<ranges::iota_view<unsigned int, _Signed128>>);
static_assert(CanSize<ranges::iota_view<unsigned int, _Unsigned128>>);
static_assert(CanSize<ranges::iota_view<unsigned long, _Signed128>>);
static_assert(CanSize<ranges::iota_view<unsigned long, _Unsigned128>>);
static_assert(CanSize<ranges::iota_view<unsigned long long, _Signed128>>);
static_assert(CanSize<ranges::iota_view<unsigned long long, _Unsigned128>>);

// Validate other integer types (other than bool)
static_assert(CanSize<ranges::iota_view<char, _Signed128>>);
static_assert(CanSize<ranges::iota_view<char, _Unsigned128>>);
static_assert(CanSize<ranges::iota_view<wchar_t, _Signed128>>);
static_assert(CanSize<ranges::iota_view<wchar_t, _Unsigned128>>);
#ifdef __cpp_char8_t
static_assert(CanSize<ranges::iota_view<char8_t, _Signed128>>);
static_assert(CanSize<ranges::iota_view<char8_t, _Unsigned128>>);
#endif // __cpp_char8_t
static_assert(CanSize<ranges::iota_view<char16_t, _Signed128>>);
static_assert(CanSize<ranges::iota_view<char16_t, _Unsigned128>>);
static_assert(CanSize<ranges::iota_view<char32_t, _Signed128>>);
static_assert(CanSize<ranges::iota_view<char32_t, _Unsigned128>>);

int main() {} // COMPILE-ONLY