std::type_identity
提供: cppreference.com
<tbody>
</tbody>
| ヘッダ <type_traits> で定義
|
||
template< class T > struct type_identity; |
(C++20以上) | |
T を表すメンバ型 type を提供します (恒等変換)。
メンバ型
| 名前 | 定義 |
type
|
T
|
ヘルパー型
<tbody> </tbody> template< class T > using type_identity_t = typename type_identity<T>::type; |
(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>
例
| This section is incomplete Reason: no example |