Hmm.. Yes, sounds reasonable. So the 0-array declaration here does not
go under SFINAE?
The failure is an instantiation failure that comes before the
substitution can even be attempted. Once vector<0is instantiable
(say, by providing a specialization) then the substitution does fail
without an error.
I am still not convinced. Let's take another try.. I simplified the
problem:
template <int N>
struct Vector
{
int data_[N];
};
template <int N>
struct Matrix
{
};
template <int N>
int operator *(
const Vector<N>&,
const Matrix<N>&)
{
return 0;
}
template <int N>
int operator *(
const Vector<N - 1>&,
const Matrix<N>&)
{
return 1;
}
int main()
{
Matrix<1transfo rm;
Vector<1transla tion;
int result = translation * transform;
return 0;
}
If I were a compiler I would act like this:
1) If in the first function I take the Matrix<1to conclude N = 1, then
the other parameter is Vector<1and we have a match.
2) If in the first function I take the Vector<1to conclude N = 1, then
the other parameter is Matrix<1and we have a match.
3) If in the second function I take the Matrix<1to conclude N = 1,
then the other parameter is Vector<0and we don't have a match.
4) If in the second function I take the Vector<1to conclude N = 2,
then the other parameter is Matrix<2and we don't have a match.
Thus, without ever needing instantiation of any template, we have
concluded that the first function is the only possible candidate. Why
would the compiler need the instantiation of Vector<0or Matrix<2>?
Btw, I reposted this question to comp.lang.c++.m oderated before you
replied this second time. I thought there will be no more replies
because this newsgroup has such a traffic all the time. The comment I
make there is written before you replied, so it is not to say that you
couldn't deliver the answer.
Anyway, you still haven't convinced me of the reasons which lead to the
instantion of Vector<0>.. Examples showing its necessity and/or relevant
quotes from the standard would help.
--
Kalle Rutanen
http://kaba.hilvi.org