From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 69CB53858C31 for ; Wed, 12 Jul 2023 10:10:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 69CB53858C31 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689156641; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=S+tusaQpwXB7LMCNA1oMYVa8Cq8MnzUtO+QIEuQjW1I=; b=iqv9zWIXP27L6IUJsdDkb97TzD+TZpcZkB35XTIwsx97mJBTbzHEvLNvXz3hhXUB458G13 xIsGNgHrQ2iB+T0M5qIvvD7hP6s7ApRzRDbHYWUmeh2klXIB3WK7p520IE+ib8FiCBOtOv /pNgwXDk9mULB8k7KnmUXpfrew8e2+s= Received: from mail-lj1-f199.google.com (mail-lj1-f199.google.com [209.85.208.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-607-sdPBKe4pNgWYrsvlH0Kmvg-1; Wed, 12 Jul 2023 06:10:40 -0400 X-MC-Unique: sdPBKe4pNgWYrsvlH0Kmvg-1 Received: by mail-lj1-f199.google.com with SMTP id 38308e7fff4ca-2b6f97c9d54so66441431fa.3 for ; Wed, 12 Jul 2023 03:10:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689156638; x=1691748638; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=S+tusaQpwXB7LMCNA1oMYVa8Cq8MnzUtO+QIEuQjW1I=; b=c6yLRMzz15bXGu+uuDt/GBsMpcegf/fIf7Jlf6AqqWaDdr4t6oYuqenfHlxzrcXEkW VvtqU8iBMzO2abdVF0DXr8V9qRxZ9DqgAWBMajeR3laFBleggSl83ehiod9BByETeiVt fEyY/Ec3u8A1MSVklk1LNjsTuBFMmzEcfW9xtPxjjzYrtnWYR+PGFy6t6dx9q2Lk14QR 3VentJ8cgZUtKsG2Y/DX8Zk5tsKqgnG5VGjkWd+sCpf0Bquelj4hqWcOQFSuuVQtMRh8 5pX0Bza6MOOVJSZFF0PAKQjttEF61OSHyKQYcL2ihbGRFhdxpfAyAiZoG8tJK4X/Fzgm gjCw== X-Gm-Message-State: ABy/qLYKz+7piGUg/88tOS8lTZRA1EemdTG8IGHvFFwlscrvNpGsJvMj HB7mQzkpgFRRvM19msdtRNBNSWLzKVa0EE3DDRiPpTYLhr3dS8vluBhOUoD2h+o/CKoazcw5X8E 7ytxxi2dxKtw4ySAOiBi/iZc9FHj6E6A= X-Received: by 2002:a05:651c:91:b0:2b6:a186:52ac with SMTP id 17-20020a05651c009100b002b6a18652acmr14787641ljq.47.1689156638618; Wed, 12 Jul 2023 03:10:38 -0700 (PDT) X-Google-Smtp-Source: APBJJlHlUtjiuXK/3mDKbiIS4KjFm1s+1L8+YyOuqY9bYtS44Il+lz4fP7pndr44MszNiuhN+ZqLgUKMz/V3rwe5rTU= X-Received: by 2002:a05:651c:91:b0:2b6:a186:52ac with SMTP id 17-20020a05651c009100b002b6a18652acmr14787623ljq.47.1689156638352; Wed, 12 Jul 2023 03:10:38 -0700 (PDT) MIME-Version: 1.0 References: <20230708051137.63707-1-kmatsui@gcc.gnu.org> <20230708051137.63707-5-kmatsui@gcc.gnu.org> In-Reply-To: <20230708051137.63707-5-kmatsui@gcc.gnu.org> From: Jonathan Wakely Date: Wed, 12 Jul 2023 11:10:27 +0100 Message-ID: Subject: Re: [PATCH v8 4/6] libstdc++: use new built-in trait __is_function for std::is_function To: Ken Matsui Cc: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-13.4 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,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,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 List-Id: On Sat, 8 Jul 2023 at 06:15, Ken Matsui via Libstdc++ wrote: > > 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. > > Signed-off-by: Ken Matsui > --- > libstdc++-v3/include/std/type_traits | 13 +++++++++++++ > 1 file changed, 13 insertions(+) > > diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits > index 2a14df7e5f9..954b57518de 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,14 @@ 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); > +#else > template > inline constexpr bool is_function_v = is_function<_Tp>::value; This fallback could be: template inline constexpr bool is_function_v = !is_const_v; That would avoid instantiating std::is_function and std::is_const and std::integral_constant, which should be significant.