# std::type_identity

From cppreference.com
< cpp‎ | types

Defined in header `<type_traits>` |  |
template< class T > struct type_identity; |  | (since C++20)

Provides the member typedef `type` that names `T` (i.e., the identity transformation).

### Member types

Name | Definition
`type` | `T`

### Helper types

template< class T > using type_identity_t = typename type_identity<T>::type; |  | (since C++20)

### Possible implementation

    template< class T >
    struct type_identity {
        using type = T;
    };

### Notes

`type_identity` can be used to block template argument deduction:

    template<class T>
    void f(T, T);

    template<class T>
    void g(T, std::type_identity_t<T>);

    f(4.2, 0); // error, deduced conflicting types for 'T'
    g(4.2, 0); // OK, calls g<double>

### Example

| This section is incomplete Reason: no example

Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/types/type_identity&oldid=105516"