From: Patrick Palka Date: Thu, 3 Jul 2025 14:55:17 +0000 (-0400) Subject: libstdc++: Update LWG 4166 changes to concat_view::end() [PR120934] X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c5a17e92ebf0c6f3887fb5698a1114a3fdf50576;p=thirdparty%2Fgcc.git libstdc++: Update LWG 4166 changes to concat_view::end() [PR120934] In r15-4555-gf191c830154565 we proactively implemented the initial proposed resolution for LWG 4166 which later turned out to be insufficient, since we must also require equality_comparable of the underlying iterators before concat_view could be a common range. This patch implements the updated P/R, requiring all underlying iterators to be forward (which implies equality_comparable) before making concat_view common, which fixes the testcase from this PR. PR libstdc++/120934 libstdc++-v3/ChangeLog: * include/std/ranges (concat_view::end): Refine condition for returning an iterator instead of default_sentinel as per the updated P/R for LWG 4166. * testsuite/std/ranges/concat/1.cc (test05): New test. Reviewed-by: Jonathan Wakely --- diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges index f764aa7512e..3a6710bd0ae 100644 --- a/libstdc++-v3/include/std/ranges +++ b/libstdc++-v3/include/std/ranges @@ -9735,7 +9735,7 @@ namespace ranges end() requires (!(__detail::__simple_view<_Vs> && ...)) { constexpr auto __n = sizeof...(_Vs); - if constexpr ((semiregular> && ...) + if constexpr (__detail::__all_forward && common_range<_Vs...[__n - 1]>) return _Iterator(this, in_place_index<__n - 1>, ranges::end(std::get<__n - 1>(_M_views))); @@ -9747,7 +9747,7 @@ namespace ranges end() const requires (range && ...) && __detail::__concatable { constexpr auto __n = sizeof...(_Vs); - if constexpr ((semiregular> && ...) + if constexpr (__detail::__all_forward && common_range) return _Iterator(this, in_place_index<__n - 1>, ranges::end(std::get<__n - 1>(_M_views))); diff --git a/libstdc++-v3/testsuite/std/ranges/concat/1.cc b/libstdc++-v3/testsuite/std/ranges/concat/1.cc index 16721912a37..f78ed08a610 100644 --- a/libstdc++-v3/testsuite/std/ranges/concat/1.cc +++ b/libstdc++-v3/testsuite/std/ranges/concat/1.cc @@ -99,6 +99,18 @@ test04() using type = decltype(v); } +void +test05() +{ + // PR libstdc++/120934 - views::concat is ill-formed depending on argument order + auto v1 = views::single(1); + std::vector vec = {2, 3}; + auto v2 = views::join(views::transform(vec, views::single)); + + static_assert( ranges::range ); + static_assert( ranges::range ); +} + int main() { @@ -107,4 +119,5 @@ main() test02(); test03(); test04(); + test05(); }