◐ Shell
clean mode source ↗

std::type_identity - cppreference.com

提供: cppreference.com

<tbody> </tbody>

template< class T > struct type_identity;

(C++20以上)

T を表すメンバ型 type を提供します (恒等変換)。

メンバ型

ヘルパー型

<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>