源码实现:

// 类型提取
template<typename _Type>
    struct __type_identity
    { using type = _Type; };

template<typename _Tp>
    using __type_identity_t = typename __type_identity<_Tp>::type;

提供同等类型的恒等变换, 举例:

#include <iostream>
#include <type_traits>
 
template<class T>
T foo(T a, T b) { return a + b; }
 
template<class T>
T bar(T a, std::type_identity_t<T> b) { return a + b; }
 
int main()
{
    // foo(4.2, 1); // 错误:对 'T' 推导的类型冲突
    std::cout << bar(4.2, 1) << '\\n';  // OK:调用 bar<double>
}