Recently I posted this question : Ambigous operator overload on clang which got closed for being essentially the same as Is clang wrongfully reporting ambiguity when mixing member and non-member binary operators?
After reading answers to that other question, I think I am still confused about what more specialized means. So based on what I read there, the member operator from my code should resolve to this :
template <class U>
TVector3<T>& TVector3<float>::operator*=(const U ) { return *this; }
during name lookup and for the purpose of overload resolution I would get these two candidates:
template <class U>
TVector3<T>& operator*=(TVector3<float>&, const U ) { return *this; }
template <typename T>
TVector3<T>& operator*=(TVector3<T>& v, const TMatrix3<T>& ) { return v; }
Why are they both equally well specialized ?
Is it because in the first overload the first argument is more specialized, while in the second overload the second argument is more specialized ? So basically a tie between them ?
On the other hand, if I turned the member operator*=
of the Vector class into a free function, the overload resolution set would be:
template <class T, class U>
TVector3<T>& operator*=(TVector3<T>& v, const U ) { return v; }
template <typename T>
TVector3<T>& operator*=(TVector3<T>& v, const TMatrix3<T>& ) { return v; }
in which case the first argument of both overloads is equally specialized, but the second argument of the second overload is more specialized and thus no ambiguity in this case.
Is my understanding correct ?