From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1888) id 787273850849; Wed, 7 Sep 2022 14:23:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 787273850849 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662560590; bh=YTODtrg0HeCCw2cc7kpA6e1SXp7oEMSbva3IKUKK7G0=; h=From:To:Subject:Date:From; b=pw0dVN4yK5khzeDJy+cosV1349R/Pe8Nkq7DxbcZFuqzKtqtCVyohoR8Mc1b6s8jm UrVF21qk1r+RYkxqCEDgLMOoCgxf5jQS83NnXE8LZRHB7yogUdvygdWrpZaE5wJL3P dt3KROj/UztfwNhl02R6HArZ3jNQLmkoYB3JDwDU= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Patrick Palka To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r13-2522] libstdc++: Optimize is_void and is_null_pointer X-Act-Checkin: gcc X-Git-Author: Patrick Palka X-Git-Refname: refs/heads/master X-Git-Oldrev: 873d395c2976a8321cec03f21d77e11f746da7c0 X-Git-Newrev: 66af6e991bf0daf1c41e46400a8f19e87c358cf2 Message-Id: <20220907142310.787273850849@sourceware.org> Date: Wed, 7 Sep 2022 14:23:10 +0000 (GMT) List-Id: https://gcc.gnu.org/g:66af6e991bf0daf1c41e46400a8f19e87c358cf2 commit r13-2522-g66af6e991bf0daf1c41e46400a8f19e87c358cf2 Author: Patrick Palka Date: Wed Sep 7 10:21:45 2022 -0400 libstdc++: Optimize is_void and is_null_pointer Instead of defining these in terms of a helper class template and the relatively expensive __remove_cv_t, just declare four explicit specializations of the main template, one for each choice of cv-quals. libstdc++-v3/ChangeLog: * include/std/type_traits (__is_void_helper): Remove. (is_void): Make the primary template derive from false_type, and define four explicit specializations that derive from true_type. (__is_null_pointer_helper, is_null_pointer): Likewise. Diff: --- libstdc++-v3/include/std/type_traits | 48 +++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index e4d167939d9..b83e7257a9f 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -289,23 +289,30 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // __remove_cv_t (std::remove_cv_t for C++11). template using __remove_cv_t = typename remove_cv<_Tp>::type; + /// @endcond // Primary type categories. - template - struct __is_void_helper + /// is_void + template + struct is_void : public false_type { }; template<> - struct __is_void_helper + struct is_void : public true_type { }; - /// @endcond - /// is_void - template - struct is_void - : public __is_void_helper<__remove_cv_t<_Tp>>::type - { }; + template<> + struct is_void + : public true_type { }; + + template<> + struct is_void + : public true_type { }; + + template<> + struct is_void + : public true_type { }; /// @cond undocumented template @@ -571,19 +578,26 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #define __cpp_lib_is_null_pointer 201309L - template - struct __is_null_pointer_helper + /// is_null_pointer (LWG 2247). + template + struct is_null_pointer : public false_type { }; template<> - struct __is_null_pointer_helper + struct is_null_pointer : public true_type { }; - /// is_null_pointer (LWG 2247). - template - struct is_null_pointer - : public __is_null_pointer_helper<__remove_cv_t<_Tp>>::type - { }; + template<> + struct is_null_pointer + : public true_type { }; + + template<> + struct is_null_pointer + : public true_type { }; + + template<> + struct is_null_pointer + : public true_type { }; /// __is_nullptr_t (deprecated extension). /// @deprecated Non-standard. Use `is_null_pointer` instead.