From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 124025 invoked by alias); 5 Feb 2020 15:15:06 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 123923 invoked by uid 89); 5 Feb 2020 15:15:05 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-17.9 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_SHORT,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 spammy=__detail X-HELO: us-smtp-delivery-1.mimecast.com Received: from us-smtp-1.mimecast.com (HELO us-smtp-delivery-1.mimecast.com) (205.139.110.61) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 05 Feb 2020 15:15:02 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580915701; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=3BYfsY3pWughzltperkJppZEJoMDB3OvLo2w76bK16A=; b=Y7C3nLhB03/GxAac1zFyK/gKv/jQM5KWnenCkR7JyCCQuwTXAoNpJSo9DkqCnCZxn0TvOb n5XkwjAUSiYUPMs8nxsro2EzCy4k+M6DFU0uWmEzZzjQAYDcb1QRQ7nuBv8MwvnzwedicS 7FodJ6x6oA8ldBqgvVgZU/KLgR873Og= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-326-jJqGq604PLuSPclMqfnUdg-1; Wed, 05 Feb 2020 10:14:56 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 112ED19057A2; Wed, 5 Feb 2020 15:14:55 +0000 (UTC) Received: from localhost (unknown [10.33.36.156]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8AFA460C81; Wed, 5 Feb 2020 15:14:54 +0000 (UTC) Date: Wed, 05 Feb 2020 15:15:00 -0000 From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Remove workarounds for constraints on alias templates Message-ID: <20200205151453.GA854252@redhat.com> MIME-Version: 1.0 X-Clacks-Overhead: GNU Terry Pratchett X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: multipart/mixed; boundary="liOOAslEiF7prFVr" Content-Disposition: inline X-SW-Source: 2020-02/txt/msg00272.txt.bz2 --liOOAslEiF7prFVr Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-length: 517 The G++ bug has been fixed for a couple of months so we can remove these workarounds that define alias templates in terms of constrained class templates. We can just apply constraints directly to alias templates as specified in the C++20 working draft. * include/bits/iterator_concepts.h (iter_reference_t) (iter_rvalue_reference_t, iter_common_reference_t, indirect_result_t): Remove workarounds for PR c++/67704. * testsuite/24_iterators/aliases.cc: New test. Tested powerpc64le-linux, committed to master. --liOOAslEiF7prFVr Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="patch.txt" Content-Transfer-Encoding: quoted-printable Content-length: 7168 commit 269e8130b77065452698ab97e5da77d132d00276 Author: Jonathan Wakely Date: Wed Feb 5 10:35:19 2020 +0000 libstdc++: Remove workarounds for constraints on alias templates =20=20=20=20 The G++ bug has been fixed for a couple of months so we can remove these workarounds that define alias templates in terms of constrained class templates. We can just apply constraints directly to alias templates as specified in the C++20 working draft. =20=20=20=20 * include/bits/iterator_concepts.h (iter_reference_t) (iter_rvalue_reference_t, iter_common_reference_t, indirect_res= ult_t): Remove workarounds for PR c++/67704. * testsuite/24_iterators/aliases.cc: New test. diff --git a/libstdc++-v3/include/bits/iterator_concepts.h b/libstdc++-v3/i= nclude/bits/iterator_concepts.h index bf581597229..d9b8958d0a7 100644 --- a/libstdc++-v3/include/bits/iterator_concepts.h +++ b/libstdc++-v3/include/bits/iterator_concepts.h @@ -70,17 +70,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { { *__t } -> __can_reference; }; - - // FIXME: needed due to PR c++/67704 - template<__detail::__dereferenceable _Tp> - struct __iter_ref - { - using type =3D decltype(*std::declval<_Tp&>()); - }; } // namespace __detail =20 - template - using iter_reference_t =3D typename __detail::__iter_ref<_Tp>::type; + template<__detail::__dereferenceable _Tp> + using iter_reference_t =3D decltype(*std::declval<_Tp&>()); =20 namespace ranges { @@ -127,26 +120,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } // inline namespace __cust } // namespace ranges =20 - namespace __detail - { - // FIXME: needed due to PR c++/67704 - template<__detail::__dereferenceable _Tp> - struct __iter_rvalue_ref - { }; - - template<__detail::__dereferenceable _Tp> - requires requires(_Tp& __t) - { - { ranges::iter_move(__t) } -> __detail::__can_reference; - } - struct __iter_rvalue_ref<_Tp> - { using type =3D decltype(ranges::iter_move(std::declval<_Tp&>())); = }; - - } // namespace __detail - - template + template<__detail::__dereferenceable _Tp> + requires requires(_Tp& __t) + { { ranges::iter_move(__t) } -> __detail::__can_reference; } using iter_rvalue_reference_t - =3D typename __detail::__iter_rvalue_ref<_Tp>::type; + =3D decltype(ranges::iter_move(std::declval<_Tp&>())); =20 template struct incrementable_traits { }; =20 @@ -467,18 +445,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION && common_reference_with&&, const iter_value_t<_In>&>; =20 - namespace __detail - { - // FIXME: needed due to PR c++/67704 - template - struct __iter_common_ref - : common_reference, iter_value_t<_Tp>&> - { }; - } // namespace __detail - - template + template using iter_common_reference_t - =3D typename __detail::__iter_common_ref<_Tp>::type; + =3D common_reference_t, iter_value_t<_Tp>&>; =20 /// Requirements for writing a value into an iterator's referenced objec= t. template @@ -663,24 +632,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION && strict_weak_order<_Fn&, iter_common_reference_t<_I1>, iter_common_reference_t<_I2>>; =20 - namespace __detail - { - // FIXME: needed due to PR c++/67704 - template - struct __indirect_result - { }; - - template - requires (readable<_Is> && ...) - && invocable<_Fn, iter_reference_t<_Is>...> - struct __indirect_result<_Fn, _Is...> - : invoke_result<_Fn, iter_reference_t<_Is>...> - { }; - } // namespace __detail - template - using indirect_result_t =3D typename - __detail::__indirect_result<_Fn, _Is...>::type; + requires (readable<_Is> && ...) + && invocable<_Fn, iter_reference_t<_Is>...> + using indirect_result_t =3D invoke_result_t<_Fn, iter_reference_t<_Is>= ...>; =20 /// [projected], projected template _Proj> diff --git a/libstdc++-v3/testsuite/24_iterators/aliases.cc b/libstdc++-v3/= testsuite/24_iterators/aliases.cc new file mode 100644 index 00000000000..29bb56ec0d3 --- /dev/null +++ b/libstdc++-v3/testsuite/24_iterators/aliases.cc @@ -0,0 +1,61 @@ +// 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=3Dgnu++2a" } +// { dg-do compile { target c++2a } } + +#include + +template +struct Dereferenceable { T operator*(); }; + +template + concept has_iter_reference + =3D requires { typename std::iter_reference_t; }; + +template + concept is_iter_reference_for + =3D has_iter_reference && std::same_as>; + +static_assert(!has_iter_reference>); +static_assert(is_iter_reference_for>); +static_assert(is_iter_reference_for>); +static_assert(is_iter_reference_for>); +static_assert(is_iter_reference_for); +static_assert(is_iter_reference_for); + +template + concept has_iter_rvalue_reference + =3D requires { typename std::iter_rvalue_reference_t; }; + +template + concept is_iter_rvalue_reference_for + =3D has_iter_rvalue_reference + && std::same_as>; + +static_assert(!has_iter_rvalue_reference>); +static_assert(is_iter_rvalue_reference_for>); +static_assert(is_iter_rvalue_reference_for>); +static_assert(is_iter_rvalue_reference_for>); +static_assert(is_iter_rvalue_reference_for); +static_assert(is_iter_rvalue_reference_for); + +// These functions should be found by ADL. std::move is not applied to res= ult. +long iter_move(Dereferenceable); +long& iter_move(Dereferenceable); +static_assert(is_iter_rvalue_reference_for>); +static_assert(is_iter_rvalue_reference_for= >); --liOOAslEiF7prFVr--