[libcxx-commits] [PATCH] D141456: [libc++][ranges] Fix incorrect integer type in `view_interface` tests.
Konstantin Varlamov via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Jan 10 20:37:08 PST 2023
var-const created this revision.
Herald added a project: All.
var-const requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.
`ForwardIter() - ForwardIter()` returns `ptrdiff_t`, and converting it
to an unsigned type isn't guaranteed to produce the same type as
`size_t`.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D141456
Files:
libcxx/test/std/ranges/range.utility/view.interface/view.interface.pass.cpp
Index: libcxx/test/std/ranges/range.utility/view.interface/view.interface.pass.cpp
===================================================================
--- libcxx/test/std/ranges/range.utility/view.interface/view.interface.pass.cpp
+++ libcxx/test/std/ranges/range.utility/view.interface/view.interface.pass.cpp
@@ -233,17 +233,19 @@
static_assert(!SizeInvocable<NotSizedSentinel>);
static_assert( SizeInvocable<ForwardRange>);
- using SignedSize = std::common_type_t<std::ptrdiff_t, std::make_signed_t<std::size_t>>;
+ static_assert(std::same_as<decltype(std::declval<ForwardIter>() - std::declval<ForwardIter>()), std::ptrdiff_t>);
+ using UnsignedSize = std::make_unsigned_t<std::ptrdiff_t>;
+ using SignedSize = std::common_type_t<std::ptrdiff_t, std::make_signed_t<UnsignedSize>>;
ForwardRange forwardRange;
assert(forwardRange.size() == 8);
assert(static_cast<ForwardRange const&>(forwardRange).size() == 8);
assert(std::ranges::size(forwardRange) == 8);
- static_assert(std::same_as<decltype(std::ranges::size(std::declval<ForwardRange>())), std::size_t>);
+ static_assert(std::same_as<decltype(std::ranges::size(std::declval<ForwardRange>())), UnsignedSize>);
static_assert(std::same_as<decltype(std::ranges::ssize(std::declval<ForwardRange>())), SignedSize>);
assert(std::ranges::size(static_cast<ForwardRange const&>(forwardRange)) == 8);
- static_assert(std::same_as<decltype(std::ranges::size(std::declval<ForwardRange const>())), std::size_t>);
+ static_assert(std::same_as<decltype(std::ranges::size(std::declval<ForwardRange const>())), UnsignedSize>);
static_assert(std::same_as<decltype(std::ranges::ssize(std::declval<ForwardRange const>())), SignedSize>);
SizeIsTen sizeTen;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D141456.488070.patch
Type: text/x-patch
Size: 1739 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20230111/6e099bbf/attachment.bin>
More information about the libcxx-commits
mailing list