public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Marc Glisse <marc.glisse@inria.fr>
To: Ken Matsui <kmatsui@cs.washington.edu>
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
Date: Tue, 21 Mar 2023 12:20:42 +0100 (CET)	[thread overview]
Message-ID: <19d13f2f-65e5-2851-26aa-439ebd90813f@inria.fr> (raw)
In-Reply-To: <20230321111056.78121-2-kmatsui@cs.washington.edu>

On Tue, 21 Mar 2023, Ken Matsui via Libstdc++ wrote:

>   /// add_const
> +#if __has_builtin(__add_const)
> +  template<typename _Tp>
> +    struct add_const
> +    { using type = __add_const(_Tp); };
> +#else
>   template<typename _Tp>
>     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

  reply	other threads:[~2023-03-21 11:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-21 11:10 [PATCH 1/2] c++: implement __add_const built-in trait Ken Matsui
2023-03-21 11:10 ` [PATCH 2/2] libstdc++: use new built-in trait __add_const Ken Matsui
2023-03-21 11:20   ` Marc Glisse [this message]
2023-03-21 11:24     ` Jonathan Wakely
2023-03-21 11:37       ` Ken Matsui
2023-03-21 11:26 ` [PATCH 1/2] c++: implement __add_const built-in trait Jonathan Wakely
2023-03-21 11:29   ` Jonathan Wakely

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=19d13f2f-65e5-2851-26aa-439ebd90813f@inria.fr \
    --to=marc.glisse@inria.fr \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=kmatsui@cs.washington.edu \
    --cc=libstdc++@gcc.gnu.org \
    --cc=ppalka@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).