I have the following pattern:
template <int a, int b>
class MyClass
{
public:
template <int c>
MyClass<a, c> operator*(MyClass<b, c> const &other) const;
};
// ../..
template <int a, int b> template <int c>
MyClass<a, c> MyClass<a, b>::operator*(MyClass<b, c> const &other) const //< error here
{
MyClass<a, c> result;
// ..do stuff..
return result;
}
It doesn't compile, the error message is
Error C2975. error C2975: 'dom' : invalid argument template for 'MyClass'
If I replace template <int c>
by template <int c, int d>
and use it accordignly, it works fine. But I want d
to be the same value as b
.
My questions:
- Why the example doesn't work?
- How can I enforce
d
to be the same thanb
?
Thanks.