From patchwork Fri Sep 2 16:38:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 936 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:ecc5:0:0:0:0:0 with SMTP id s5csp814871wro; Fri, 2 Sep 2022 09:39:22 -0700 (PDT) X-Google-Smtp-Source: AA6agR7+awTEjQKPiTZuJ0evXZseiFGghXUaKAsNq/FlfEDTCsTTAsWvg0744gfd9Z2a3IfIqLJg X-Received: by 2002:a17:906:730e:b0:741:8fc9:7fbc with SMTP id di14-20020a170906730e00b007418fc97fbcmr17422794ejc.145.1662136762255; Fri, 02 Sep 2022 09:39:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662136762; cv=none; d=google.com; s=arc-20160816; b=L/xDWBSSkd2d6TrIZoxL6OKsINk91Js/qA7ncltTfkMlZco6WvZJ6kUAS/DSBWccc9 3hjVe6Y5lvRz5n/atnT+YsLTvdZ9NG+mf68bkpLvG8hyr/M6+UjfzjQAJ6B7Ok/fb9Te u3ddFkTv1CQUVVvJO0v2m6lRMYjOvyrk2NnEtaEXWOoFGcZ3vxKWYSephrTRmFnoIs+J A8HzEHspiTMbGQ2tR3b//iHgfUiDi5K/MvaULmAua46hcb3CxuW4kTzoWVWO5gbkaTtN BUssn7uhFgGXinQMe4q3/lx+OLwtlyge7Zcg1/KRft+2+Nb14YM9PbGU8IUxI/+Wvy6D r/7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=OMwtGwpCiUYh2aduSnifiTJ44IsN2H/2wffMehfvMNY=; b=CSdHq9uw89z/753r2wc9w37ypBnKx7dp7eBXMVjRz+0/BMSoEn+fWFN/0N/WDojNmn 8ZgW7zSxkU2XhlkN/pp5qCsPyByTttg+QSFDq+q8BhSxA2E6KlxxE6FnECdfJ243Xks3 qlsNqEI+hUTe1OiQfwPSxkloLP/f1MpQWUfpgTry7bLONE3Xr4U/S1PhO9CIq5TykNNc 7h6JiMzvDeG5+6O6702arK1bqESIZ0l7qpez7CZTkzRMGcL19uJc5u5DBpJJNqKiu/WW mXJS556p62ECerSo7ypST5DAzfuEFmz+QMNw63EzMC8E6iqv/d4+hsSk63LOBBvEVTs9 t6Xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="j/lONLq2"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id c12-20020a05640227cc00b0043e81c582d2si2510971ede.232.2022.09.02.09.39.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Sep 2022 09:39:22 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="j/lONLq2"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DEDCF38582A5 for ; Fri, 2 Sep 2022 16:39:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DEDCF38582A5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662136751; bh=OMwtGwpCiUYh2aduSnifiTJ44IsN2H/2wffMehfvMNY=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=j/lONLq21otoJhlWGylOP8NUwMrUCZtF2LrpmQNBOrehpSCkrTO21rA7izt39Bur6 RZv3kEoGf+XwbczaXcppYo5fw3apC3dui9XYvEiKMrxTx0KVTbR4e8k6Tp9p0ticxu a1GBH7j1MbuLJ1zshBlTPCHcRKefwtUGp5f66zYQ= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 05CF23858C53 for ; Fri, 2 Sep 2022 16:38:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 05CF23858C53 Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-408-EwV0sv8aNgOTFU_FuZQhZA-1; Fri, 02 Sep 2022 12:38:26 -0400 X-MC-Unique: EwV0sv8aNgOTFU_FuZQhZA-1 Received: by mail-qv1-f71.google.com with SMTP id og5-20020a056214428500b00496b5246db5so1615688qvb.10 for ; Fri, 02 Sep 2022 09:38:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date; bh=OMwtGwpCiUYh2aduSnifiTJ44IsN2H/2wffMehfvMNY=; b=BonwV+Dib6CvCWp/4tBvNFSgLypXM6kvOSAzT3Mx403N5Dl0aKMPuxpPGrqk3BjB9j p0qqNA9kOudn4R+SoV36FrozyN7nDhmXftrnpXN5Q5gE3fCE6BCc6c249zsAxBNora2V 5uUFTkHlsdNX1Bo4+hUzLrHQfkkBkbcBEAhy7g/pUXV0Ljqd1ggBpYzBRKqo+iG4/8NH 94Uz2YAPbdjCfe4rm8AfebJXdkpvwpYdR4e8/H5KHKuxb63FWd4DCvnXiGOMEkzqmc3f s75kN80tZ9yW8tZHE4UZpmTLBfJsthk9xiL53j8/0m3Vo4rX8oPCqgwHU1zlMBYNNQpn lOfA== X-Gm-Message-State: ACgBeo2NtNNjNItwwWhT5rj0ThKGL11VVigIjo8dgcEdg21INXQYXc0M C9nyETo9urEtuRNOXUsW5xh/dPLzTfoXgBWemwbZ31wjgQtbYuTYCd1tGrqlyhuaXGIm5o78SJs 9gssPC/k12GHM7fKkyeI5Zj3YApt23RjUVO2CmmPS4HtHfi9/0sGHDoNJXEaCZLqctp8= X-Received: by 2002:a37:347:0:b0:6bb:e4e5:de57 with SMTP id 68-20020a370347000000b006bbe4e5de57mr23511878qkd.123.1662136706101; Fri, 02 Sep 2022 09:38:26 -0700 (PDT) X-Received: by 2002:a37:347:0:b0:6bb:e4e5:de57 with SMTP id 68-20020a370347000000b006bbe4e5de57mr23511857qkd.123.1662136705741; Fri, 02 Sep 2022 09:38:25 -0700 (PDT) Received: from localhost.localdomain (ool-457670bb.dyn.optonline.net. [69.118.112.187]) by smtp.gmail.com with ESMTPSA id a15-20020a05622a064f00b003437a694049sm1327584qtb.96.2022.09.02.09.38.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Sep 2022 09:38:24 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [PATCH] libstdc++: Consistently use ::type when deriving from __and/or/not_ Date: Fri, 2 Sep 2022 12:38:16 -0400 Message-Id: <20220902163816.748210-1-ppalka@redhat.com> X-Mailer: git-send-email 2.37.2.490.g6c8e4ee870 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-14.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Patrick Palka via Gcc-patches From: Patrick Palka Reply-To: Patrick Palka Cc: libstdc++@gcc.gnu.org Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1742876717713793417?= X-GMAIL-MSGID: =?utf-8?q?1742876717713793417?= Now that these internal type traits are again class templates, it's better to derive from the trait's ::type (which is either false_type or true_type) instead of from the trait itself, for sake of a shallower inheritance chain. We usually do this but not always; this patch makes us consistently do so. Tested on x86_64-pc-lnux-gnu, does this look OK for trunk? (Compile time for join.cc decreases by about 0.5% with this, avg of 10 runs.) libstdc++-v3/ChangeLog: * include/std/tuple (tuple::_UseOtherCtor): Do ::type when deriving from __and_, __or_ or __not_. * include/std/type_traits (negation): Likewise. (is_unsigned): Likewise. (__is_implicitly_default_constructible): Likewise. (is_trivially_destructible): Likewise. (__is_nt_invocable_impl): Likewise. --- libstdc++-v3/include/std/tuple | 2 +- libstdc++-v3/include/std/type_traits | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libstdc++-v3/include/std/tuple b/libstdc++-v3/include/std/tuple index ddd7c226d80..26e248431ec 100644 --- a/libstdc++-v3/include/std/tuple +++ b/libstdc++-v3/include/std/tuple @@ -826,7 +826,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // then TUPLE should match tuple(UTypes&&...) instead. template struct _UseOtherCtor<_Tuple, tuple<_Tp>, tuple<_Up>> - : __or_, is_constructible<_Tp, _Tuple>> + : __or_, is_constructible<_Tp, _Tuple>>::type { }; // If TUPLE and *this each have a single element of the same type, // then TUPLE should match a copy/move constructor instead. diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index be9f2955539..c0bb1cf64e3 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -235,7 +235,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template struct negation - : __not_<_Pp> + : __not_<_Pp>::type { }; /** @ingroup variable_templates @@ -845,7 +845,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// is_unsigned template struct is_unsigned - : public __and_, __not_>> + : public __and_, __not_>>::type { }; /// @cond undocumented @@ -1222,7 +1222,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template struct __is_implicitly_default_constructible : public __and_<__is_constructible_impl<_Tp>, - __is_implicitly_default_constructible_safe<_Tp>> + __is_implicitly_default_constructible_safe<_Tp>>::type { }; /// is_trivially_copy_constructible @@ -1282,7 +1282,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template struct is_trivially_destructible : public __and_<__is_destructible_safe<_Tp>, - __bool_constant<__has_trivial_destructor(_Tp)>> + __bool_constant<__has_trivial_destructor(_Tp)>>::type { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); @@ -2975,7 +2975,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct __is_nt_invocable_impl<_Result, _Ret, __void_t> : __or_, - __is_nothrow_convertible> + __is_nothrow_convertible>::type { }; /// @endcond