std::type_identity - cppreference.com
提供: cppreference.com
<tbody> </tbody>
|
|
(C++20以上) | |
T を表すメンバ型 type を提供します (恒等変換)。
メンバ型
ヘルパー型
<tbody> </tbody>
|
|
(C++20以上) | |
実装例
template< class T > struct type_identity { using type = T; };
ノート
type_identity はテンプレートの実引数推定を防ぐために使用することができます。
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>