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 <jwakely@redhat.com> Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index 1c03c22..c56fae4 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits
@@ -164,6 +164,26 @@ 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 @@ 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 @@ /// @} #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