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).
Name | Definition |
---|---|
type | T |
template< class T > using type_identity_t = typename type_identity<T>::type; | (since C++20) |
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>
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
http://en.cppreference.com/w/cpp/types/type_identity