aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKen Matsui <kmatsui@gcc.gnu.org>2024-02-14 03:42:33 -0800
committerKen Matsui <kmatsui@gcc.gnu.org>2024-06-13 05:56:08 -0700
commit24da955ab442107909a06f3ef722f4dbf6751236 (patch)
tree3d14d9c93ad2a19cb047932467788967fe53ccc8
parentb38aefbbc90a3334c6c5ba6569816d348a1a0c91 (diff)
downloadgcc-24da955ab442107909a06f3ef722f4dbf6751236.zip
gcc-24da955ab442107909a06f3ef722f4dbf6751236.tar.gz
gcc-24da955ab442107909a06f3ef722f4dbf6751236.tar.bz2
libstdc++: Optimize std::add_pointer compilation performance
This patch optimizes the compilation performance of std::add_pointer by dispatching to the new __add_pointer built-in trait. libstdc++-v3/ChangeLog: * include/std/type_traits (add_pointer): Use __add_pointer built-in trait. Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org> Reviewed-by: Patrick Palka <ppalka@redhat.com> Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
-rw-r--r--libstdc++-v3/include/std/type_traits8
1 files changed, 7 insertions, 1 deletions
diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits
index efbe273d..e179015 100644
--- a/libstdc++-v3/include/std/type_traits
+++ b/libstdc++-v3/include/std/type_traits
@@ -2135,6 +2135,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ };
#endif
+ /// add_pointer
+#if _GLIBCXX_USE_BUILTIN_TRAIT(__add_pointer)
+ template<typename _Tp>
+ struct add_pointer
+ { using type = __add_pointer(_Tp); };
+#else
template<typename _Tp, typename = void>
struct __add_pointer_helper
{ using type = _Tp; };
@@ -2143,7 +2149,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
struct __add_pointer_helper<_Tp, __void_t<_Tp*>>
{ using type = _Tp*; };
- /// add_pointer
template<typename _Tp>
struct add_pointer
: public __add_pointer_helper<_Tp>
@@ -2156,6 +2161,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Tp>
struct add_pointer<_Tp&&>
{ using type = _Tp*; };
+#endif
#if __cplusplus > 201103L
/// Alias template for remove_pointer