This is an interview question, which has been done.
Which line has error ?
#include
template void foo(T op1, T op2)
When we use a function template, the compiler infers what template argument(s) to bind to the template parameter(s). Once the compiler determines the actual template argument(s), it instantiates an instance of the function for us. Essentially the compiler figures out what type to use in place of each type parameter. So, if op1
and op2
have the same type the template parameter(s) can be omitted (that's why line #2 causes error).
From C++ primer