From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sourceware.org (Postfix) with ESMTPS id 8C86A38582A1; Tue, 21 Mar 2023 11:20:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8C86A38582A1 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=inria.fr Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=inria.fr DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=date:from:reply-to:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=/JJr3HwQrPjbdDqKA8SvEXqazXPxKIlRx+JBuiXg42E=; b=YT5h8b2rZNRhT0KWvdM9+CA6U4tPs/krP53pVYwCSjxPuAsvPHPlKOdU 67/PgDBX8iOSU8PUdRWW6HBBV4TbUOZpYBfVLhaqO6rXyZHe54ud9JCGx vKbhsnTyx4+tppuqaKMVESpxnpgUNOGzP+OX9JrYCRbiJDPJUABr1na05 8=; Authentication-Results: mail3-relais-sop.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=marc.glisse@inria.fr; dmarc=fail (p=none dis=none) d=inria.fr X-IronPort-AV: E=Sophos;i="5.98,278,1673910000"; d="scan'208";a="50798704" Received: from 85-171-189-19.rev.numericable.fr (HELO hippo) ([85.171.189.19]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Mar 2023 12:20:42 +0100 Date: Tue, 21 Mar 2023 12:20:42 +0100 (CET) From: Marc Glisse Reply-To: libstdc++@gcc.gnu.org To: Ken Matsui cc: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org, ppalka@redhat.com Subject: Re: [PATCH 2/2] libstdc++: use new built-in trait __add_const In-Reply-To: <20230321111056.78121-2-kmatsui@cs.washington.edu> Message-ID: <19d13f2f-65e5-2851-26aa-439ebd90813f@inria.fr> References: <20230321111056.78121-1-kmatsui@cs.washington.edu> <20230321111056.78121-2-kmatsui@cs.washington.edu> MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset=US-ASCII X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham 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 Tue, 21 Mar 2023, Ken Matsui via Libstdc++ wrote: > /// add_const > +#if __has_builtin(__add_const) > + template > + struct add_const > + { using type = __add_const(_Tp); }; > +#else > template > struct add_const > { using type = _Tp const; }; > +#endif Is that really better? You asked elsewhere if you should measure for each patch, and I think that at least for such a trivial case, you need to demonstrate that there is a point. The drawbacks are obvious: more code in libstdc++, non-standard, and more builtins in the compiler. Using builtins makes more sense for complicated traits where you can save several instantiations. Now that you have done a couple simple cases to see how it works, I think you should concentrate on the more complicated cases. -- Marc Glisse