From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2136) id D38D83AA98F6; Wed, 17 Jun 2020 19:01:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D38D83AA98F6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1592420490; bh=JPTToZUHNVYFrDpdCB6lI00/z4NKx/RJC51cCUt+ubE=; h=From:To:Subject:Date:From; b=vG9KFbR3yioy72mGm6YcKFaBVbQwSCOIN94UJI5j82klh2o3mui7jqoDef0kYBs89 6U2pxct4n6BBvSpNLL1fkH2iA7708T1rfr24vrHOxwlZsKjl6OQQJ5p+fUSeeYz8n/ BxwLil6OIklZNiGZPz5jdM18BSKGEmJL1aJ+UAyE= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Aldy Hernandez To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc/devel/ranger] libstdc++: span's deduction-guide for built-in arrays doesn't work (LWG 3369) X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/devel/ranger X-Git-Oldrev: 247f410b83797a1840573840cc2a539ef9d7f96b X-Git-Newrev: 66ae31eb308e5bc90ce6dfd0a67381a0929a6aa0 Message-Id: <20200617190130.D38D83AA98F6@sourceware.org> Date: Wed, 17 Jun 2020 19:01:30 +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, 17 Jun 2020 19:01:30 -0000 https://gcc.gnu.org/g:66ae31eb308e5bc90ce6dfd0a67381a0929a6aa0 commit 66ae31eb308e5bc90ce6dfd0a67381a0929a6aa0 Author: Jonathan Wakely Date: Wed Feb 19 14:41:46 2020 +0000 libstdc++: span's deduction-guide for built-in arrays doesn't work (LWG 3369) The 23_containers/span/deduction.cc test was already passing, but only because I had previously implemented the original proposed resolution of 3255. As pointed out in 3255 that original P/R was incorrect because it broke construction from array xvalues. This reverts the incorrect part of 3255 (and adds tests for the case it broke), and implements the resolution of 3369 instead. * include/std/span (span(T (&)[N])): Use non-deduced context to prevent first parameter from interfering with class template argument deduction (LWG 3369). * testsuite/23_containers/span/deduction.cc: Add missing 'const'. * testsuite/23_containers/span/lwg3255.cc: Check for construction from rvalues. Diff: --- libstdc++-v3/ChangeLog | 7 +++++++ libstdc++-v3/include/std/span | 6 +++--- libstdc++-v3/testsuite/23_containers/span/deduction.cc | 2 +- libstdc++-v3/testsuite/23_containers/span/lwg3255.cc | 4 ++++ 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index f5f8b6fd500..18085f3d9bd 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,12 @@ 2020-02-19 Jonathan Wakely + * include/std/span (span(T (&)[N])): Use non-deduced context to + prevent first parameter from interfering with class template argument + deduction (LWG 3369). + * testsuite/23_containers/span/deduction.cc: Add missing 'const'. + * testsuite/23_containers/span/lwg3255.cc: Check for construction from + rvalues. + * include/std/span (span::const_iterator, span::const_reverse_iterator) (span::cbegin(), span::cend(), span::crbegin(), span::crend()): Remove (LWG 3320). diff --git a/libstdc++-v3/include/std/span b/libstdc++-v3/include/std/span index ccfd7db39fe..16b09a1e50c 100644 --- a/libstdc++-v3/include/std/span +++ b/libstdc++-v3/include/std/span @@ -182,10 +182,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } } - template - requires __is_compatible_array<_Tp, _ArrayExtent>::value + template + requires (_Extent == dynamic_extent || _ArrayExtent == _Extent) constexpr - span(_Tp (&__arr)[_ArrayExtent]) noexcept + span(type_identity_t (&__arr)[_ArrayExtent]) noexcept : span(static_cast(__arr), _ArrayExtent) { } diff --git a/libstdc++-v3/testsuite/23_containers/span/deduction.cc b/libstdc++-v3/testsuite/23_containers/span/deduction.cc index 66e955e961b..2fe1ac477c8 100644 --- a/libstdc++-v3/testsuite/23_containers/span/deduction.cc +++ b/libstdc++-v3/testsuite/23_containers/span/deduction.cc @@ -73,7 +73,7 @@ test01() std::span s9(s2); static_assert( is_static_span(s9) ); - std::span s10(const_cast&>(s2)); + std::span s10(const_cast&>(s2)); static_assert( is_static_span(s10) ); std::span s11(s5); diff --git a/libstdc++-v3/testsuite/23_containers/span/lwg3255.cc b/libstdc++-v3/testsuite/23_containers/span/lwg3255.cc index 91edf6a04fd..03ced2c8710 100644 --- a/libstdc++-v3/testsuite/23_containers/span/lwg3255.cc +++ b/libstdc++-v3/testsuite/23_containers/span/lwg3255.cc @@ -57,10 +57,14 @@ static_assert( !is_constructible_v, const array static_assert( is_constructible_v, int(&)[2]> ); static_assert( is_constructible_v, int(&)[2]> ); static_assert( is_constructible_v, const int(&)[2]> ); +static_assert( is_constructible_v, int[2]> ); +static_assert( is_constructible_v, const int[2]> ); static_assert( is_constructible_v, array&> ); static_assert( is_constructible_v, array&> ); static_assert( is_constructible_v, array&> ); +static_assert( is_constructible_v, array> ); +static_assert( is_constructible_v, array> ); static_assert( is_constructible_v, const array&> ); static_assert( is_constructible_v, const array&> );