From: Jonathan Wakely Date: Tue, 16 Sep 2025 12:41:20 +0000 (+0100) Subject: libstdc++: Fix missing change to views::pairwise from P2165R4 [PR121956] X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0c762f79a9e7bbd8d8fc5e639d53e43d9e331299;p=thirdparty%2Fgcc.git libstdc++: Fix missing change to views::pairwise from P2165R4 [PR121956] ranges::adjacent_view::_Iterator::value_type should have been changed by r14-8710-g65b4cba9d6a9ff to always produce std::tuple, even for the N == 2 views::pairwise specialization. libstdc++-v3/ChangeLog: PR libstdc++/121956 * include/std/ranges (adjacent_view::_Iterator::value_type): Always define as std::tuple, not std::pair. * testsuite/std/ranges/adaptors/adjacent/1.cc: Check value type of views::pairwise. Reviewed-by: Patrick Palka --- diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges index f493da56203b..1c76dcc85acd 100644 --- a/libstdc++-v3/include/std/ranges +++ b/libstdc++-v3/include/std/ranges @@ -5460,9 +5460,7 @@ namespace views::__adaptor public: using iterator_category = input_iterator_tag; using iterator_concept = decltype(_S_iter_concept()); - using value_type = conditional_t<_Nm == 2, - pair, range_value_t<_Base>>, - __detail::__repeated_tuple, _Nm>>; + using value_type = __detail::__repeated_tuple, _Nm>; using difference_type = range_difference_t<_Base>; _Iterator() = default; diff --git a/libstdc++-v3/testsuite/std/ranges/adaptors/adjacent/1.cc b/libstdc++-v3/testsuite/std/ranges/adaptors/adjacent/1.cc index 085cd4a8c54c..0a5c67f56140 100644 --- a/libstdc++-v3/testsuite/std/ranges/adaptors/adjacent/1.cc +++ b/libstdc++-v3/testsuite/std/ranges/adaptors/adjacent/1.cc @@ -114,6 +114,18 @@ test04() return true; } +constexpr bool +test05() +{ + // PR libstdc++/121956 + int a[2]{}; + __gnu_test::test_random_access_range r(a); + auto v = r | views::pairwise; + static_assert( std::is_same_v, + std::tuple> ); + return true; +} + int main() { @@ -121,4 +133,5 @@ main() static_assert(test02()); static_assert(test03()); static_assert(test04()); + static_assert(test05()); }