std::type_identity (3) - Linux Man Pages

std::type_identity: std::type_identity

NAME

std::type_identity - std::type_identity

Synopsis


Defined in header <type_traits>
template< class T > (since C++20)
struct type_identity;


Provides the member typedef type that names T (i.e., the identity transformation).

Member types


Name Definition
type T

Helper types


template< class T > (since C++20)
using type_identity_t = typename type_identity<T>::type;

Possible implementation


  template< class T >
  struct type_identity {
      using type = T;
  };

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


 This section is incomplete
 Reason: no example