S
in the expression typename std::remove_reference<S>::type
is a non-deduced context (specifically because S
appears in the nested-name-specifier of a type specified using a qualified-id). Non-deduced contexts are, as the name suggests, contexts in which the template argument cannot be deduced.
This case provides an easy example to understand why. Say I had:
int i;
forward(i);
What would S
be? It could be int
, int&
, or int&&
- all of those types would yield the correct argument type for the function. It's simply impossible for the compiler to determine which S
you really mean here - so it doesn't try. It's non-deducible, so you have to explicitly provide which S
you mean:
forward<int&>(i); // oh, got it, you meant S=int&