std::type_identity
From Get docs
Cpp/docs/latest/types/type identity
std::type_identity
Defined in header <type_traits>
|
||
---|---|---|
|
(since C++20) |
Provides the member typedef type
that names T
(i.e., the identity transformation).
Member types
Name | Definition |
---|---|
type
|
T
|
Helper types
|
(since C++20) |
Possible implementation
|
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
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
http://en.cppreference.com/w/cpp/types/type_identity