From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7934) id 7F7B6387088E; Sat, 16 Dec 2023 17:00:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7F7B6387088E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1702746019; bh=yOXw1vvasP2D6Cuubdc7D5JACxYHJMPJJQJBl95TEyU=; h=From:To:Subject:Date:From; b=Zwws9ghh2JsjaD8BajG78wE71rO5L61MZuOlnxfKccdsaS5vRw3rxElRliaoE9jsC +j/s5ZTJEnPWxjru5CrpTsmxKe1y2dLnZE79AFd4+TiXC9MsbwYJkgxJgFIilUnrTd nm0yhTZ28moTuvxKxLbg+xy8Nr760IAheA+g8QPM= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Ken Matsui To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r14-6625] libstdc++: Optimize std::is_scoped_enum compilation performance X-Act-Checkin: gcc X-Git-Author: Ken Matsui X-Git-Refname: refs/heads/master X-Git-Oldrev: 8843cff6c98cb0789a1ec6f51be6c5122fc1b5e9 X-Git-Newrev: 4a235f8eb0f19292c007c4374d6b48ab01667a3b Message-Id: <20231216170019.7F7B6387088E@sourceware.org> Date: Sat, 16 Dec 2023 17:00:19 +0000 (GMT) List-Id: https://gcc.gnu.org/g:4a235f8eb0f19292c007c4374d6b48ab01667a3b commit r14-6625-g4a235f8eb0f19292c007c4374d6b48ab01667a3b Author: Ken Matsui Date: Mon Sep 11 17:14:32 2023 -0700 libstdc++: Optimize std::is_scoped_enum compilation performance This patch optimizes the compilation performance of std::is_scoped_enum by dispatching to the new __is_scoped_enum built-in trait. 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 Reviewed-by: Jonathan Wakely Diff: --- 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 2a1a0aa80ff..4a5068791af 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -3602,6 +3602,12 @@ template /// True if the type is a scoped enumeration type. /// @since C++23 +# if _GLIBCXX_USE_BUILTIN_TRAIT(__is_scoped_enum) + template + struct is_scoped_enum + : bool_constant<__is_scoped_enum(_Tp)> + { }; +# else template struct is_scoped_enum : false_type @@ -3613,11 +3619,17 @@ template struct is_scoped_enum<_Tp> : bool_constant { }; +# endif /// @ingroup variable_templates /// @since C++23 +# if _GLIBCXX_USE_BUILTIN_TRAIT(__is_scoped_enum) + template + inline constexpr bool is_scoped_enum_v = __is_scoped_enum(_Tp); +# else template 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