The "universal reference" deduces the parameter to foo&
. The first template also deduces the parameter to foo&
.
C++ has a partial ordering rule for function templates that makes T&
be more specialized than T&&
. Hence the first template must be chosen in your example code.