From: Jonathan Wakely <jwakely@redhat.com>
To: Patrick Palka <ppalka@redhat.com>
Cc: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org
Subject: Re: [PATCH 2/2] libstdc++: Optimize is_reference
Date: Wed, 7 Sep 2022 09:00:57 +0100 [thread overview]
Message-ID: <CACb0b4n+i6g33Jc_kbpHMHGCECsyryEWGfw6LUWLtbe3XvkJrg@mail.gmail.com> (raw)
In-Reply-To: <20220907004542.288365-2-ppalka@redhat.com>
On Wed, 7 Sept 2022 at 01:46, Patrick Palka via Libstdc++
<libstdc++@gcc.gnu.org> wrote:
>
> Instead of defining is_reference in terms of is_lvalue_reference
> and is_rvalue_reference, just define it directly.
>
> Tested on x86_64-pc-linux-gnu, does this look OK for trunk?
Yes, thanks (I already did this for the std::is_reference_v variable
template, but for some reason left this equivalent change in the local
branch where I was doing the traits refactoring).
> This reduces memory usage of join.cc by 1%.
Now that many of the variable templates have been optimized to avoid
instantiating class templates, I wonder if the <ranges> code (and
anything else that's only defined for C++17 or later) would benefit
from using foo_v<T> && bar_v<T> instead of __and_<foo<T>, bar<T>>.
With your improvements to __and_ maybe it doesn't make so much
difference.
>
> libstdc++-v3/ChangeLog:
>
> * include/std/type_traits (is_reference): Make the primary
> template derive from false_type. Define two partial
> specializations that derive from true_type.
> ---
> libstdc++-v3/include/std/type_traits | 13 +++++++++++--
> 1 file changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits
> index b83e7257a9f..94e73eafd2f 100644
> --- a/libstdc++-v3/include/std/type_traits
> +++ b/libstdc++-v3/include/std/type_traits
> @@ -611,8 +611,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> /// is_reference
> template<typename _Tp>
> struct is_reference
> - : public __or_<is_lvalue_reference<_Tp>,
> - is_rvalue_reference<_Tp>>::type
> + : public false_type
> + { };
> +
> + template<typename _Tp>
> + struct is_reference<_Tp&>
> + : public true_type
> + { };
> +
> + template<typename _Tp>
> + struct is_reference<_Tp&&>
> + : public true_type
> { };
>
> /// is_arithmetic
> --
> 2.37.3.518.g79f2338b37
>
next prev parent reply other threads:[~2022-09-07 8:01 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-07 0:45 [PATCH 1/2] libstdc++: Optimize is_void and is_null_pointer Patrick Palka
2022-09-07 0:45 ` [PATCH 2/2] libstdc++: Optimize is_reference Patrick Palka
2022-09-07 8:00 ` Jonathan Wakely [this message]
2022-09-07 8:19 ` [PATCH 1/2] libstdc++: Optimize is_void and is_null_pointer 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=CACb0b4n+i6g33Jc_kbpHMHGCECsyryEWGfw6LUWLtbe3XvkJrg@mail.gmail.com \
--to=jwakely@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--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).