On Thu, 14 May 2026 at 12:09, Tomasz Kamiński <[email protected]> wrote:
>
> The components that used __type_identity in C++20 mode (due source
> compatibility with other 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 later is

"the latter" instead of "later"

> available.
>
> libstdc++-v3/ChangeLog:
>
>         * include/std/type_traits (__type_identity, __type_identity_t)
>         [__cpp_lib_type_identity]: Define as alias to type_identity
>         and it's nested type respectively.

"its" without the apostrophe

> ---
> Testing on x86_64-linux. Waiting for full test to finish.
> OK for trunk when all tests passes.
>
>  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 1c03c22e8ee..667725b1b01 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.

I'm not sure why there's an extra '*' here (it was in the original
comment below) but it can be removed.

OK with that change, thanks.

> +   * @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
> --
> 2.54.0
>

Reply via email to