public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely.gcc@gmail.com>
To: Ken Matsui <kmatsui@gcc.gnu.org>
Cc: gcc-patches <gcc-patches@gcc.gnu.org>,
	"libstdc++" <libstdc++@gcc.gnu.org>
Subject: Re: [PATCH 2/2] libstdc++: Optimize is_scoped_enum trait performance
Date: Tue, 12 Sep 2023 07:50:39 +0100	[thread overview]
Message-ID: <CAH6eHdRErPG-cO2ELdeFpbzkWFKi58sSWJ9yQDTLvNERooeCFw@mail.gmail.com> (raw)
In-Reply-To: <20230912001756.87388-3-kmatsui@gcc.gnu.org>

[-- Attachment #1: Type: text/plain, Size: 1931 bytes --]

On Tue, 12 Sept 2023, 01:21 Ken Matsui via Libstdc++, <libstdc++@gcc.gnu.org>
wrote:

> This patch optimizes the performance of the is_scoped_enum trait
> by dispatching to the new __is_scoped_enum built-in trait.
>

OK for trunk (after the built-in is in the front end), thanks.



> libstdc++-v3/ChangeLog:
>
>         * include/std/type_traits (is_scoped_enum): Use
>         __is_scoped_enum built-in trait.
>         (is_scoped_enum_v): Likewise.
>
> Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
> ---
>  libstdc++-v3/include/std/type_traits | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
>
> diff --git a/libstdc++-v3/include/std/type_traits
> b/libstdc++-v3/include/std/type_traits
> index 677cd934b94..26ae491fa69 100644
> --- a/libstdc++-v3/include/std/type_traits
> +++ b/libstdc++-v3/include/std/type_traits
> @@ -3585,6 +3585,12 @@ template<typename _Ret, typename _Fn, typename...
> _Args>
>    /// True if the type is a scoped enumeration type.
>    /// @since C++23
>
> +# if _GLIBCXX_USE_BUILTIN_TRAIT(__is_scoped_enum)
> +  template<typename _Tp>
> +    struct is_scoped_enum
> +    : bool_constant<__is_scoped_enum(_Tp)>
> +    { };
> +# else
>    template<typename _Tp>
>      struct is_scoped_enum
>      : false_type
> @@ -3596,11 +3602,17 @@ template<typename _Ret, typename _Fn, typename...
> _Args>
>      struct is_scoped_enum<_Tp>
>      : bool_constant<!requires(_Tp __t, void(*__f)(int)) { __f(__t); }>
>      { };
> +# endif
>
>    /// @ingroup variable_templates
>    /// @since C++23
> +# if _GLIBCXX_USE_BUILTIN_TRAIT(__is_scoped_enum)
> +  template<typename _Tp>
> +    inline constexpr bool is_scoped_enum_v = __is_scoped_enum(_Tp);
> +# else
>    template<typename _Tp>
>      inline constexpr bool is_scoped_enum_v = is_scoped_enum<_Tp>::value;
> +# endif
>  #endif
>
>  #ifdef __cpp_lib_reference_from_temporary // C++ >= 23 &&
> ref_{converts,constructs}_from_temp
> --
> 2.42.0
>
>

      reply	other threads:[~2023-09-12  6:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-12  0:16 [PATCH 0/2] " Ken Matsui
2023-09-12  0:16 ` [PATCH 1/2] c++: Implement __is_scoped_enum built-in trait Ken Matsui
2023-09-12  0:16 ` [PATCH 2/2] libstdc++: Optimize is_scoped_enum trait performance Ken Matsui
2023-09-12  6:50   ` Jonathan Wakely [this message]

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=CAH6eHdRErPG-cO2ELdeFpbzkWFKi58sSWJ9yQDTLvNERooeCFw@mail.gmail.com \
    --to=jwakely.gcc@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=kmatsui@gcc.gnu.org \
    --cc=libstdc++@gcc.gnu.org \
    /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).