G
gretean
I have a problem that's driving me crazy involving Microsoft's ability
to deduce template parameters. I am using Visual Studio .NET (aka
VC7?), and it gives an error compiling the following code.
template <int x, int y> class M {
public:
template <int xRet, int yRet, int xR, int yR>
M<xRet, yRet> operator *(const M<xR, yR> &b) const {
M<xRet,yRet> a;
return a;
}
};
int main() {
M<1,2> a;
M<3,4> b;
M<5,6> c;
c = a * b;
return 0;
}
The error I get is
error C2783: 'M<xRet,yRet> M<x,y>:perator *(const M<xR,yR> &) const'
: could not deduce template argument for 'xRet'
with
[
x=1,
y=2
]
Can somebody please explain to me what is syntactically wrong with
this? I'm not looking for advice or lectures about why ints shouldn't
be used in template parameters, so please don't respond with such. I'm
just wondering what part of this C++ syntax is invalid. To me it seems
like it should be fine. Thanks.
to deduce template parameters. I am using Visual Studio .NET (aka
VC7?), and it gives an error compiling the following code.
template <int x, int y> class M {
public:
template <int xRet, int yRet, int xR, int yR>
M<xRet, yRet> operator *(const M<xR, yR> &b) const {
M<xRet,yRet> a;
return a;
}
};
int main() {
M<1,2> a;
M<3,4> b;
M<5,6> c;
c = a * b;
return 0;
}
The error I get is
error C2783: 'M<xRet,yRet> M<x,y>:perator *(const M<xR,yR> &) const'
: could not deduce template argument for 'xRet'
with
[
x=1,
y=2
]
Can somebody please explain to me what is syntactically wrong with
this? I'm not looking for advice or lectures about why ints shouldn't
be used in template parameters, so please don't respond with such. I'm
just wondering what part of this C++ syntax is invalid. To me it seems
like it should be fine. Thanks.