I'm having a problem with overloading of a function that gets a template as an input. I made a template vector:
template TempVec<class T, int size>
which has two options: vector of int by size 3, or vector of complex by size 2.
I have a function called InnerProduct that gets two vectors and returns the result of the inner products between the vectors. The problem is that the type of the return value depends on the vector type (int/complex).
So I created these three functions (in the class of TempVec):
template <class T, int size>
friend int InnerProduct(const TempVec<T, 3>& v1, const TempVec<T, 3>& v2);
template <class T, int size>
friend complex InnerProduct(const TempVec<T, 2>& v1, const TempVec<T, 2>& v2);
template <class T, int size>
friend TempVec<T, size> InnerProduct(const TempVec<T, size>& v1, const TempVec<T, size>& v2);
When I call InnerProduct, I always get to the last function (the most general function), even if I pass two vectors of size 3, or two vectors of size 2. I tried to get rid of the last function, but I got the error:
'InnerProduct': none of the 2 overloads could convert all the argument types.
I would be very grateful for some explanation/solution to the problem.