* [PATCH 1/3] libstdc++: Fix zip_view's operator- for integer-class difference type [PR106766]
@ 2022-09-09 17:24 Patrick Palka
2022-09-09 17:24 ` [PATCH 2/3] libstdc++: Fix typo in adjacent_view::_Iterator [PR106798] Patrick Palka
2022-09-09 17:24 ` [PATCH 3/3] libstdc++: Fix return type of empty zip/adjacent_transform [PR106803] Patrick Palka
0 siblings, 2 replies; 3+ messages in thread
From: Patrick Palka @ 2022-09-09 17:24 UTC (permalink / raw)
To: gcc-patches; +Cc: libstdc++, Patrick Palka
make_unsigned_t can't give us the unsigned version of an integer-class
difference type, so use __make_unsigned_like_t / __to_unsigned_like
instead.
PR libstdc++/106766
libstdc++-v3/ChangeLog:
* include/std/ranges (zip_view::_Iterator::operator-): Use
__to_unsigned_like instead of make_unsigned_t.
(zip_view::_Sentinel::operator-): Likewise.
* testsuite/std/ranges/zip/1.cc (test04): New test.
---
libstdc++-v3/include/std/ranges | 8 ++++----
libstdc++-v3/testsuite/std/ranges/zip/1.cc | 14 ++++++++++++++
2 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges
index 2b5cb0531f0..2b8fec3c386 100644
--- a/libstdc++-v3/include/std/ranges
+++ b/libstdc++-v3/include/std/ranges
@@ -4657,8 +4657,8 @@ namespace views::__adaptor
return ranges::min({difference_type(std::get<_Is>(__x._M_current)
- std::get<_Is>(__y._M_current))...},
ranges::less{},
- [](difference_type __i) -> make_unsigned_t<difference_type> {
- return __i < 0 ? -__i : __i;
+ [](difference_type __i) {
+ return __detail::__to_unsigned_like(__i < 0 ? -__i : __i);
});
}(make_index_sequence<sizeof...(_Vs)>{});
}
@@ -4726,8 +4726,8 @@ namespace views::__adaptor
return [&]<size_t... _Is>(index_sequence<_Is...>) {
return ranges::min({_Ret(std::get<_Is>(__x._M_current) - std::get<_Is>(__y._M_end))...},
ranges::less{},
- [](_Ret __i) -> make_unsigned_t<_Ret> {
- return __i < 0 ? -__i : __i;
+ [](_Ret __i) {
+ return __detail::__to_unsigned_like(__i < 0 ? -__i : __i);
});
}(make_index_sequence<sizeof...(_Vs)>{});
}
diff --git a/libstdc++-v3/testsuite/std/ranges/zip/1.cc b/libstdc++-v3/testsuite/std/ranges/zip/1.cc
index 0113efdb537..f868c97cb69 100644
--- a/libstdc++-v3/testsuite/std/ranges/zip/1.cc
+++ b/libstdc++-v3/testsuite/std/ranges/zip/1.cc
@@ -102,10 +102,24 @@ test03()
return true;
}
+constexpr bool
+test04()
+{
+ // PR libstdc++/106766
+ auto r = views::zip(views::iota(__int128(0), __int128(1)));
+ auto i = r.begin();
+ auto s = r.end();
+ VERIFY( s - i == 1 );
+ VERIFY( i + 1 - i == 1 );
+
+ return true;
+}
+
int
main()
{
static_assert(test01());
static_assert(test02());
static_assert(test03());
+ static_assert(test04());
}
--
2.37.3.518.g79f2338b37
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 2/3] libstdc++: Fix typo in adjacent_view::_Iterator [PR106798]
2022-09-09 17:24 [PATCH 1/3] libstdc++: Fix zip_view's operator- for integer-class difference type [PR106766] Patrick Palka
@ 2022-09-09 17:24 ` Patrick Palka
2022-09-09 17:24 ` [PATCH 3/3] libstdc++: Fix return type of empty zip/adjacent_transform [PR106803] Patrick Palka
1 sibling, 0 replies; 3+ messages in thread
From: Patrick Palka @ 2022-09-09 17:24 UTC (permalink / raw)
To: gcc-patches; +Cc: libstdc++, Patrick Palka
PR libstdc++/106798
libstdc++-v3/ChangeLog:
* include/std/ranges (adjacent_view::_Iterator::_Iterator): Fix
typo.
* testsuite/std/ranges/adaptors/adjacent/1.cc (test04): New test.
---
libstdc++-v3/include/std/ranges | 2 +-
.../testsuite/std/ranges/adaptors/adjacent/1.cc | 12 ++++++++++++
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges
index 2b8fec3c386..37ad80ad3de 100644
--- a/libstdc++-v3/include/std/ranges
+++ b/libstdc++-v3/include/std/ranges
@@ -5239,7 +5239,7 @@ namespace views::__adaptor
requires _Const && convertible_to<iterator_t<_Vp>, iterator_t<_Base>>
{
for (size_t __j = 0; __j < _Nm; ++__j)
- _M_current[__j] = std::move(__i[__j]);
+ _M_current[__j] = std::move(__i._M_current[__j]);
}
constexpr auto
diff --git a/libstdc++-v3/testsuite/std/ranges/adaptors/adjacent/1.cc b/libstdc++-v3/testsuite/std/ranges/adaptors/adjacent/1.cc
index 9829f79364f..443c1fbf450 100644
--- a/libstdc++-v3/testsuite/std/ranges/adaptors/adjacent/1.cc
+++ b/libstdc++-v3/testsuite/std/ranges/adaptors/adjacent/1.cc
@@ -101,10 +101,22 @@ test03()
return true;
}
+constexpr bool
+test04()
+{
+ // PR libstdc++/106798
+ auto r = views::single(0) | views::lazy_split(0) | views::pairwise;
+ decltype(ranges::cend(r)) s = r.end();
+ VERIFY( r.begin() == s );
+
+ return true;
+}
+
int
main()
{
static_assert(test01());
static_assert(test02());
static_assert(test03());
+ static_assert(test04());
}
--
2.37.3.518.g79f2338b37
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 3/3] libstdc++: Fix return type of empty zip/adjacent_transform [PR106803]
2022-09-09 17:24 [PATCH 1/3] libstdc++: Fix zip_view's operator- for integer-class difference type [PR106766] Patrick Palka
2022-09-09 17:24 ` [PATCH 2/3] libstdc++: Fix typo in adjacent_view::_Iterator [PR106798] Patrick Palka
@ 2022-09-09 17:24 ` Patrick Palka
1 sibling, 0 replies; 3+ messages in thread
From: Patrick Palka @ 2022-09-09 17:24 UTC (permalink / raw)
To: gcc-patches; +Cc: libstdc++, Patrick Palka
Tested on x86_64-pc-linux-gnu, does this series look OK for trunk?
PR libstdc++/106803
libstdc++-v3/ChangeLog:
* include/std/ranges (views::_ZipTransform::operator()): Fix
return type in the empty case.
(views::_AdjacentTransform::operator()): Likewise.
---
libstdc++-v3/include/std/ranges | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges
index 37ad80ad3de..20eb4e82ac8 100644
--- a/libstdc++-v3/include/std/ranges
+++ b/libstdc++-v3/include/std/ranges
@@ -5071,7 +5071,7 @@ namespace views::__adaptor
operator() [[nodiscard]] (_Fp&& __f, _Ts&&... __ts) const
{
if constexpr (sizeof...(_Ts) == 0)
- return views::empty<decay_t<invoke_result_t<_Fp>>>;
+ return views::empty<decay_t<invoke_result_t<decay_t<_Fp>&>>>;
else
return zip_transform_view(std::forward<_Fp>(__f), std::forward<_Ts>(__ts)...);
}
@@ -5762,7 +5762,7 @@ namespace views::__adaptor
operator() [[nodiscard]] (_Range&& __r, _Fp&& __f) const
{
if constexpr (_Nm == 0)
- return views::empty<tuple<>>;
+ return zip_transform(std::forward<_Fp>(__f));
else
return adjacent_transform_view<all_t<_Range>, decay_t<_Fp>, _Nm>
(std::forward<_Range>(__r), std::forward<_Fp>(__f));
--
2.37.3.518.g79f2338b37
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-09-09 17:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-09 17:24 [PATCH 1/3] libstdc++: Fix zip_view's operator- for integer-class difference type [PR106766] Patrick Palka
2022-09-09 17:24 ` [PATCH 2/3] libstdc++: Fix typo in adjacent_view::_Iterator [PR106798] Patrick Palka
2022-09-09 17:24 ` [PATCH 3/3] libstdc++: Fix return type of empty zip/adjacent_transform [PR106803] Patrick Palka
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).