aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKen Matsui <kmatsui@gcc.gnu.org>2023-03-22 16:28:06 -0700
committerKen Matsui <kmatsui@gcc.gnu.org>2024-06-13 05:55:47 -0700
commitbb99672e0c49d8b8822664eaabc10cd51a42aab4 (patch)
treee5cd1f9c9d7a4306c65f0915907a8bb7f8814d9c
parenteea62ce6fbcffb8acc227e5dbed74d2b627ce84d (diff)
downloadgcc-bb99672e0c49d8b8822664eaabc10cd51a42aab4.zip
gcc-bb99672e0c49d8b8822664eaabc10cd51a42aab4.tar.gz
gcc-bb99672e0c49d8b8822664eaabc10cd51a42aab4.tar.bz2
libstdc++: Optimize std::is_volatile compilation performance
This patch optimizes the compilation performance of std::is_volatile by dispatching to the new __is_volatile built-in trait. libstdc++-v3/ChangeLog: * include/std/type_traits (is_volatile): Use __is_volatile built-in trait. (is_volatile_v): Likewise. 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_traits12
1 files changed, 12 insertions, 0 deletions
diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits
index 8df0cf3..748fa18 100644
--- a/libstdc++-v3/include/std/type_traits
+++ b/libstdc++-v3/include/std/type_traits
@@ -851,6 +851,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#endif
/// is_volatile
+#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_volatile)
+ template<typename _Tp>
+ struct is_volatile
+ : public __bool_constant<__is_volatile(_Tp)>
+ { };
+#else
template<typename>
struct is_volatile
: public false_type { };
@@ -858,6 +864,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Tp>
struct is_volatile<_Tp volatile>
: public true_type { };
+#endif
/// is_trivial
template<typename _Tp>
@@ -3360,10 +3367,15 @@ template <typename _Tp>
inline constexpr bool is_function_v<_Tp&&> = false;
#endif
+#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_volatile)
+template <typename _Tp>
+ inline constexpr bool is_volatile_v = __is_volatile(_Tp);
+#else
template <typename _Tp>
inline constexpr bool is_volatile_v = false;
template <typename _Tp>
inline constexpr bool is_volatile_v<volatile _Tp> = true;
+#endif
template <typename _Tp>
inline constexpr bool is_trivial_v = __is_trivial(_Tp);