The necessary T
can be deduced from the type of *first
.
Explicitly specifying by programmer is only necessary if the deduction cannot be automatically made by the compiler.
This (seemingly simple but actually quite involved) phenomenon is known as Argument Dependent Name Lookup or Koenig lookup, named after its inventor Andrew Koenig.