From patchwork Thu Jul 13 02:33:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ken Matsui X-Patchwork-Id: 119485 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp1549118vqm; Wed, 12 Jul 2023 19:43:25 -0700 (PDT) X-Google-Smtp-Source: APBJJlFh+J1de340CVE3pUOlvWSryPsG5FatKfIkdQogrHzigoD0MmBsFQlhhnEpXfdjIGlMBroQ X-Received: by 2002:a17:907:7e8d:b0:98e:4f1:f987 with SMTP id qb13-20020a1709077e8d00b0098e04f1f987mr4828572ejc.3.1689216205353; Wed, 12 Jul 2023 19:43:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689216205; cv=none; d=google.com; s=arc-20160816; b=qab3Ycrp7yPcvcDHA/irDsAoNokE11zncXzJt5gx2zAGDIs7dx1xCm1p44I5w+pqGT ZfMoY9m87M4lWP3qKKpN2UyuCxdQCzW+iDR3VuQ635/EHeAblZElvzOWsRCv7ha5xswA IHWZU2YsWaDWV6JwAPskC5DNrU9ET7nXgbaMGa0fILLAw3IeBSUd1hdCiGBc9YucumGI eMevSpiduUB5XbpzoaLsQZSjn985N4oiOTtDG+FO+2PepGOFGB+u776oIsjXnE8SxliZ //vPB5OoOOBKqoy9d5f6VMSpLElZ+yvqajPKOFqBe5KSWcWHG83yLF1/wukUnBYnD38X szig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=KVQ0wo9zPz94gs1P+vCySNJyvizFXIim3dbIWWJp8rQ=; fh=1CAabwJrK+ugngH18pg8mqZVlwzSJe6ffxxXK5OO7Vs=; b=opKd/xlWYBPM2U2fyEc+inV9D2WQcidtbaliFs7e0uRUNgj2JUq0SmqWbRZynsISp6 FtblpipC23QKGGlInfxWPJgMF4LLhpiWWULXcOSAVB4BR3egew7WZjM4OWJNMCOOFudj 8q7SZJDZKuALPCztwPVAX+3scc2EKkGnk4YIiQyU3gKEumsCBkHc/0oF9xDcpi4N6Ky7 fS7cyoRVVLrqz7cOObj1FfhyGT+UZNf3WXrd6t8U9nm5tajaSlJ41j/WVjFTTKBhiBgJ VxbxXRvrPvp2d5PzgbBXub0QckHcVimB09nec97n1NBCJj/wp2JMiMkYB8dhQa/iHu0P 5XOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=WdnV0494; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id u18-20020aa7d892000000b0051e5cabfebdsi6161815edq.373.2023.07.12.19.43.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jul 2023 19:43:25 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=WdnV0494; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 B3B78385E451 for ; Thu, 13 Jul 2023 02:41:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B3B78385E451 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1689216093; bh=KVQ0wo9zPz94gs1P+vCySNJyvizFXIim3dbIWWJp8rQ=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=WdnV0494vF46ZbnxHLz+ohpcmljB8FgUZryhKTessdyGcj1eSvgFv775vR0fXqePE zrkN0MKQMVPTD4dS3YRzEtW7PFeN7FostRwHsZxX+TQfpX2sC0Aamftm6nDabyCxrh MSaL1LF61dbT0U912xc6kxEUg1i9KZnJSmIvu7oA= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-00641c01.pphosted.com (mx0b-00641c01.pphosted.com [205.220.177.146]) by sourceware.org (Postfix) with ESMTPS id 31F1E3857C66; Thu, 13 Jul 2023 02:40:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 31F1E3857C66 Received: from pps.filterd (m0247477.ppops.net [127.0.0.1]) by mx0a-00641c01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36D2UbS4028963; Thu, 13 Jul 2023 02:40:44 GMT Received: from mxout25.s.uw.edu (mxout25.s.uw.edu [140.142.234.175]) by mx0a-00641c01.pphosted.com (PPS) with ESMTPS id 3rt25eam7s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 13 Jul 2023 02:40:44 +0000 Received: from smtp.washington.edu (smtp.washington.edu [128.208.60.54]) by mxout25.s.uw.edu (8.14.4+UW20.07/8.14.4+UW22.04) with ESMTP id 36D2eF93014177 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 12 Jul 2023 19:40:16 -0700 X-Auth-Received: from localhost.localdomain ([10.154.74.234]) (authenticated authid=kmatsui) by smtp.washington.edu (8.16.1+UW21.10/8.14.4+UW19.10) with ESMTPSA id 36D2bY7H020817 (version=TLSv1.2 cipher=DHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Wed, 12 Jul 2023 19:40:15 -0700 X-UW-Orig-Sender: kmatsui@smtp.washington.edu To: gcc-patches@gcc.gnu.org Cc: libstdc++@gcc.gnu.org, Ken Matsui Subject: [PATCH v10 4/5] libstdc++: Use new built-in trait __is_function for std::is_function Date: Wed, 12 Jul 2023 19:33:38 -0700 Message-ID: <20230713023731.15571-5-kmatsui@gcc.gnu.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230713023731.15571-1-kmatsui@gcc.gnu.org> References: <20230708051137.63707-1-kmatsui@gcc.gnu.org> <20230713023731.15571-1-kmatsui@gcc.gnu.org> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: 46geHwlJ8gGbddtDY21159i5jsMNuyY7 X-Proofpoint-GUID: 46geHwlJ8gGbddtDY21159i5jsMNuyY7 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-12_17,2023-07-11_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 malwarescore=0 mlxlogscore=730 clxscore=1034 phishscore=0 lowpriorityscore=0 priorityscore=1501 impostorscore=0 spamscore=0 bulkscore=0 adultscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2307130021 X-Spam-Status: No, score=-13.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NEUTRAL, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham 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: Ken Matsui via Gcc-patches From: Ken Matsui Reply-To: Ken Matsui Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771271572052372578 X-GMAIL-MSGID: 1771271572052372578 This patch gets std::is_function to dispatch to new built-in trait __is_function. libstdc++-v3/ChangeLog: * include/std/type_traits (is_function): Use __is_function built-in trait. (is_function_v): Likewise. Optimize its implementation. Signed-off-by: Ken Matsui --- libstdc++-v3/include/std/type_traits | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index 2a14df7e5f9..7ef50a2e64f 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -594,6 +594,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { }; /// is_function +#if __has_builtin(__is_function) + template + struct is_function + : public __bool_constant<__is_function(_Tp)> + { }; +#else template struct is_function : public __bool_constant::value> { }; @@ -605,6 +611,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template struct is_function<_Tp&&> : public false_type { }; +#endif #define __cpp_lib_is_null_pointer 201309L @@ -3197,8 +3204,18 @@ template inline constexpr bool is_union_v = __is_union(_Tp); template inline constexpr bool is_class_v = __is_class(_Tp); + +#if __has_builtin(__is_function) template - inline constexpr bool is_function_v = is_function<_Tp>::value; + inline constexpr bool is_function_v = __is_function(_Tp); +#else +template + inline constexpr bool is_function_v = !is_const_v; +template + inline constexpr bool is_function_v<_Tp&> = false; +template + inline constexpr bool is_function_v<_Tp&&> = false; +#endif #if __has_builtin(__is_reference) template