]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Use new __is_destructible built-in in <type_traits>
authorJonathan Wakely <jwakely@redhat.com>
Thu, 29 May 2025 12:50:08 +0000 (13:50 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Tue, 3 Jun 2025 10:21:02 +0000 (11:21 +0100)
libstdc++-v3/ChangeLog:

* include/std/type_traits (is_destructible, is_destructible_v):
Define using new built-in.
(is_nothrow_destructible, is_nothrow_destructible_v): Likewise.
(is_trivially_destructible, is_trivially_destructible_v):
Likewise.

Reviewed-by: Tomasz KamiƄski <tkaminsk@redhat.com>
libstdc++-v3/include/std/type_traits

index 6bf355d97cc9b119d785a095e678d50dbe06e4fa..c8907fe4d382cf0151e519178c0ec89bd15ec116 100644 (file)
@@ -1039,6 +1039,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   // Destructible and constructible type properties.
 
+#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_destructible)
+  /// is_destructible
+  template<typename _Tp>
+    struct is_destructible
+    : public __bool_constant<__is_destructible(_Tp)>
+    { };
+#else
   // In N3290 is_destructible does not say anything about function
   // types and abstract types, see LWG 2049. This implementation
   // describes function types as non-destructible and all complete
@@ -1090,7 +1097,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
        "template argument must be a complete class or an unbounded array");
     };
+#endif
 
+#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_nothrow_destructible)
+  /// is_nothrow_destructible
+  template<typename _Tp>
+    struct is_nothrow_destructible
+    : public __bool_constant<__is_nothrow_destructible(_Tp)>
+    { };
+#else
   /// @cond undocumented
 
   // is_nothrow_destructible requires that is_destructible is
@@ -1144,6 +1159,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
        "template argument must be a complete class or an unbounded array");
     };
+#endif
 
   /// @cond undocumented
   template<typename _Tp, typename... _Args>
@@ -1451,6 +1467,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        "template argument must be a complete class or an unbounded array");
     };
 
+#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_trivially_destructible)
+  /// is_trivially_destructible
+  template<typename _Tp>
+    struct is_trivially_destructible
+    : public __bool_constant<__is_trivially_destructible(_Tp)>
+    { };
+#else
   /// is_trivially_destructible
   template<typename _Tp>
     struct is_trivially_destructible
@@ -1460,7 +1483,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
        "template argument must be a complete class or an unbounded array");
     };
-
+#endif
 
   /// has_virtual_destructor
   template<typename _Tp>
@@ -3581,8 +3604,13 @@ template <typename _Tp>
   inline constexpr bool is_move_assignable_v
     = __is_assignable(__add_lval_ref_t<_Tp>, __add_rval_ref_t<_Tp>);
 
+#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_destructible)
+template <typename _Tp>
+  inline constexpr bool is_destructible_v = __is_destructible(_Tp);
+#else
 template <typename _Tp>
   inline constexpr bool is_destructible_v = is_destructible<_Tp>::value;
+#endif
 
 template <typename _Tp, typename... _Args>
   inline constexpr bool is_trivially_constructible_v
@@ -3609,7 +3637,11 @@ template <typename _Tp>
     = __is_trivially_assignable(__add_lval_ref_t<_Tp>,
                                __add_rval_ref_t<_Tp>);
 
-#if __cpp_concepts
+#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_trivially_destructible)
+template <typename _Tp>
+  inline constexpr bool is_trivially_destructible_v
+    = __is_trivially_destructible(_Tp);
+#elif __cpp_concepts
 template <typename _Tp>
   inline constexpr bool is_trivially_destructible_v = false;
 
@@ -3654,9 +3686,15 @@ template <typename _Tp>
   inline constexpr bool is_nothrow_move_assignable_v
     = __is_nothrow_assignable(__add_lval_ref_t<_Tp>, __add_rval_ref_t<_Tp>);
 
+#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_nothrow_destructible)
+template <typename _Tp>
+  inline constexpr bool is_nothrow_destructible_v
+    = __is_nothrow_destructible(_Tp);
+#else
 template <typename _Tp>
   inline constexpr bool is_nothrow_destructible_v =
     is_nothrow_destructible<_Tp>::value;
+#endif
 
 template <typename _Tp>
   inline constexpr bool has_virtual_destructor_v