https://gcc.gnu.org/g:1283fc2e30965ea57965bb5ad19f221a645f9c7e

commit r17-512-g1283fc2e30965ea57965bb5ad19f221a645f9c7e
Author: Tomasz Kamiński <[email protected]>
Date:   Thu May 14 12:48:19 2026 +0200

    libstdc++: Merge __type_identity and type_identity for C+20.
    
    The components that used __type_identity in C++20 mode (due source
    compatibility with older standard) lead to instantiation of separate
    class template from std::type_identity for each used type. This
    patch makes __type_identity an alias to type_identity if the latter is
    available.
    
    libstdc++-v3/ChangeLog:
    
            * include/std/type_traits (__type_identity, __type_identity_t)
            [__cpp_lib_type_identity]: Define as alias to type_identity
            and its nested type respectively.
    
    Reviewed-by: Jonathan Wakely <[email protected]>
    Signed-off-by: Tomasz Kamiński <[email protected]>

Diff:
---
 libstdc++-v3/include/std/type_traits | 36 +++++++++++++++++++++++-------------
 1 file changed, 23 insertions(+), 13 deletions(-)

diff --git a/libstdc++-v3/include/std/type_traits 
b/libstdc++-v3/include/std/type_traits
index 1c03c22e8eed..c56fae4a5bf5 100644
--- a/libstdc++-v3/include/std/type_traits
+++ b/libstdc++-v3/include/std/type_traits
@@ -164,6 +164,26 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     using __conditional_t
       = typename __conditional<_Cond>::template type<_If, _Else>;
 
+#ifdef __cpp_lib_type_identity // C++ >= 20
+  /** Identity metafunction.
+   * @since C++20
+   * @{
+   */
+  template<typename _Tp>
+    struct type_identity { using type = _Tp; };
+
+  template<typename _Tp>
+    using type_identity_t = typename type_identity<_Tp>::type;
+  /// @}
+
+  /// @cond undocumented
+  template <typename _Tp>
+    using __type_identity = type_identity<_Tp>;
+
+  template<typename _Tp>
+    using __type_identity_t = typename type_identity<_Tp>::type;
+  /// @endcond
+#else
   /// @cond undocumented
   template <typename _Type>
     struct __type_identity
@@ -171,7 +191,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   template<typename _Tp>
     using __type_identity_t = typename __type_identity<_Tp>::type;
+  /// @endcond
+#endif
 
+  /// @cond undocumented
   namespace __detail
   {
     // A variadic alias template that resolves to its first argument.
@@ -3955,19 +3978,6 @@ template<typename _Ret, typename _Fn, typename... _Args>
   /// @}
 #endif // __cpp_lib_remove_cvref
 
-#ifdef __cpp_lib_type_identity // C++ >= 20
-  /** * Identity metafunction.
-   * @since C++20
-   * @{
-   */
-  template<typename _Tp>
-    struct type_identity { using type = _Tp; };
-
-  template<typename _Tp>
-    using type_identity_t = typename type_identity<_Tp>::type;
-  /// @}
-#endif
-
 #ifdef __cpp_lib_unwrap_ref // C++ >= 20
   /** Unwrap a reference_wrapper
    * @since C++20

Reply via email to