From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1888) id 8B1A43854821; Wed, 18 Nov 2020 16:11:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8B1A43854821 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Patrick Palka To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r10-9048] libstdc++: Avoid CTAD for std::ranges::join_view [LWG 3474] X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/releases/gcc-10 X-Git-Oldrev: 3feea217fcc1d08e8542ef458ada3b4983ac17ba X-Git-Newrev: 175e6b47f268e871a4c84e006ed981ce048c4184 Message-Id: <20201118161150.8B1A43854821@sourceware.org> Date: Wed, 18 Nov 2020 16:11:50 +0000 (GMT) X-BeenThere: libstdc++-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 16:11:50 -0000 https://gcc.gnu.org/g:175e6b47f268e871a4c84e006ed981ce048c4184 commit r10-9048-g175e6b47f268e871a4c84e006ed981ce048c4184 Author: Jonathan Wakely Date: Tue Oct 6 09:41:16 2020 +0100 libstdc++: Avoid CTAD for std::ranges::join_view [LWG 3474] In commit ef275d1f2083f8a1fa1b59a3cd07fd3e8431023e I implemented the wrong resolution of LWG 3474. This removes the deduction guide and alters the views::join factory to create the right type explicitly. libstdc++-v3/ChangeLog: * include/std/ranges (join_view): Remove deduction guide. (views::join): Add explicit template argument list to prevent deducing the wrong type. * testsuite/std/ranges/adaptors/join.cc: Move test for LWG 3474 here, from ... * testsuite/std/ranges/adaptors/join_lwg3474.cc: Removed. (cherry picked from commit 9065c4adab0b1280f5707d53833d195d0d350fd2) Diff: --- libstdc++-v3/include/std/ranges | 9 ++---- libstdc++-v3/testsuite/std/ranges/adaptors/join.cc | 16 ++++++++++ .../testsuite/std/ranges/adaptors/join_lwg3474.cc | 37 ---------------------- 3 files changed, 19 insertions(+), 43 deletions(-) diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges index 23c54b2ae4e..5625b0ba1a3 100644 --- a/libstdc++-v3/include/std/ranges +++ b/libstdc++-v3/include/std/ranges @@ -2699,17 +2699,14 @@ namespace views template explicit join_view(_Range&&) -> join_view>; - // _GLIBCXX_RESOLVE_LIB_DEFECTS - // 3474. Nesting join_views is broken because of CTAD - template - explicit join_view(join_view<_View>) -> join_view>; - namespace views { inline constexpr __adaptor::_RangeAdaptorClosure join = [] (_Range&& __r) { - return join_view{std::forward<_Range>(__r)}; + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 3474. Nesting join_views is broken because of CTAD + return join_view>{std::forward<_Range>(__r)}; }; } // namespace views diff --git a/libstdc++-v3/testsuite/std/ranges/adaptors/join.cc b/libstdc++-v3/testsuite/std/ranges/adaptors/join.cc index 142c9feddcd..e21e7054b35 100644 --- a/libstdc++-v3/testsuite/std/ranges/adaptors/join.cc +++ b/libstdc++-v3/testsuite/std/ranges/adaptors/join.cc @@ -123,6 +123,21 @@ test06() b = ranges::end(v); } +void +test07() +{ + // LWG 3474. Nesting join_views is broken because of CTAD + std::vector>> nested_vectors = { + {{1, 2, 3}, {4, 5}, {6}}, + {{7}, {8, 9}, {10, 11, 12}}, + {{13}} + }; + auto joined = nested_vectors | std::views::join | std::views::join; + + using V = decltype(joined); + static_assert( std::same_as, int> ); +} + int main() { @@ -132,4 +147,5 @@ main() test04(); test05(); test06(); + test07(); } diff --git a/libstdc++-v3/testsuite/std/ranges/adaptors/join_lwg3474.cc b/libstdc++-v3/testsuite/std/ranges/adaptors/join_lwg3474.cc deleted file mode 100644 index 516aaba7070..00000000000 --- a/libstdc++-v3/testsuite/std/ranges/adaptors/join_lwg3474.cc +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2020 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// { dg-options "-std=gnu++2a" } -// { dg-do compile { target c++2a } } - -#include -#include - -void -test01() -{ - // LWG 3474. Nesting join_views is broken because of CTAD - std::vector>> nested_vectors = { - {{1, 2, 3}, {4, 5}, {6}}, - {{7}, {8, 9}, {10, 11, 12}}, - {{13}} - }; - auto joined = nested_vectors | std::views::join | std::views::join; - - using V = decltype(joined); - static_assert( std::same_as, int> ); -}