Why use identity in forward definition for C++0x rvalue reference?
In A Brief Introduction to Rvalue References , forward is defined as follows: template <typename T> struct identity { typedef T type; }; template <typename T> T &&forward(typename identity<T>::type &&a) { return a; } What purpose does the identity class perform? Why not: template <typename T> T &&forward(T &&a) { return a; } The purpose of identity was to make T non-deducible. That is, to force the client to explicitly supply T when calling forward . forward(a); // compile-time error forward<A>(a); // ok The reason this is necessary is because the template parameter is the switch with which