educative.io

Educative

Function template

In function template(generic programming) - example section , the notes say: " The call xchg<double, double>(intA, intB) would be fine, when xchg would take its arguments by value". I tried creating a function called xchgv with arguments as T value instead of T& (reference)
template // 2a

void xchgv(T x, T y){

T t = x;

x = y;

y = t;

}
and I am getting this error when I call
std::cout << "Before: " << doubleA << ", " << doubleB << std::endl;

xchg(doubleA, doubleB); // 2

std::cout << "After: " << doubleA << ", " << doubleB << std::endl;

main.cpp: In function ‘int main()’:
main.cpp:64:35: error: no matching function for call to ‘xchgv<double, double>(int&, int&)’
64 | xchgv<double, double>(intA, intB);
| ^
main.cpp:20:6: note: candidate: ‘template void xchgv(T, T)’
20 | void xchgv(T x, T y){
| ^~~~~
main.cpp:20:6: note: template argument deduction/substitution failed:
main.cpp:64:35: error: wrong number of template arguments (2, should be 1)
64 | xchgv<double, double>(intA, intB);
| ^

Mention the exact lesson name.