aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorPatrick Palka <ppalka@redhat.com>2022-09-07 10:21:45 -0400
committerPatrick Palka <ppalka@redhat.com>2022-09-07 10:21:45 -0400
commit66af6e991bf0daf1c41e46400a8f19e87c358cf2 (patch)
tree93c355e894f77239c489beda6bcdf2f94074e160 /libstdc++-v3
parent873d395c2976a8321cec03f21d77e11f746da7c0 (diff)
downloadgcc-66af6e991bf0daf1c41e46400a8f19e87c358cf2.zip
gcc-66af6e991bf0daf1c41e46400a8f19e87c358cf2.tar.gz
gcc-66af6e991bf0daf1c41e46400a8f19e87c358cf2.tar.bz2
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.
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/include/std/type_traits48
1 files changed, 31 insertions, 17 deletions
diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits
index e4d1679..b83e725 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<typename _Tp>
using __remove_cv_t = typename remove_cv<_Tp>::type;
+ /// @endcond
// Primary type categories.
- template<typename>
- struct __is_void_helper
+ /// is_void
+ template<typename _Tp>
+ struct is_void
: public false_type { };
template<>
- struct __is_void_helper<void>
+ struct is_void<void>
: public true_type { };
- /// @endcond
- /// is_void
- template<typename _Tp>
- struct is_void
- : public __is_void_helper<__remove_cv_t<_Tp>>::type
- { };
+ template<>
+ struct is_void<const void>
+ : public true_type { };
+
+ template<>
+ struct is_void<volatile void>
+ : public true_type { };
+
+ template<>
+ struct is_void<const volatile void>
+ : public true_type { };
/// @cond undocumented
template<typename>
@@ -571,19 +578,26 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#define __cpp_lib_is_null_pointer 201309L
- template<typename>
- struct __is_null_pointer_helper
+ /// is_null_pointer (LWG 2247).
+ template<typename _Tp>
+ struct is_null_pointer
: public false_type { };
template<>
- struct __is_null_pointer_helper<std::nullptr_t>
+ struct is_null_pointer<std::nullptr_t>
: public true_type { };
- /// is_null_pointer (LWG 2247).
- template<typename _Tp>
- struct is_null_pointer
- : public __is_null_pointer_helper<__remove_cv_t<_Tp>>::type
- { };
+ template<>
+ struct is_null_pointer<const std::nullptr_t>
+ : public true_type { };
+
+ template<>
+ struct is_null_pointer<volatile std::nullptr_t>
+ : public true_type { };
+
+ template<>
+ struct is_null_pointer<const volatile std::nullptr_t>
+ : public true_type { };
/// __is_nullptr_t (deprecated extension).
/// @deprecated Non-standard. Use `is_null_pointer` instead.