Yes and that's what [...] class definition or something.
A few small source examples should correct your misunderstanding and explain the error you get.
The key differences are [...] the template argument list.
Yes. You have declared two overloads of the method named 'mgso': one with a 'cupper<?,?> &' parameter; the other with a 'cupper<1,?> &' parameter.
So I think this device allows me to include the specialization right inside the class.
You have not specialized anything. You have overloaded a template function with another template function. Now that both declarations exist you can define the functions inline, inside the class definition, or as you would normally.
The key thing to take away from this: you are overloading functions. The rules still apply even though you are using class templates and template methods.
Soma
Code:
// define struct A
struct A
{
void test(int); //declare void A::test(int)
};
//define void A::test(int)
void A::test(int){}
Code:
// define struct A
struct A
{
void test(int); //declare void A::test(int)
};
//define void A::test(float)
void A::test(float){} //error: there is no such function to define
Code:
// define struct A
struct A
{
void test(int); //declare void A::test(int)
};
//define void B::test(int)
void B::test(int){} //error: there is no such class and no such function to define
Code:
// define struct A
struct A
{
void test(int); //declare void A::test(int)
};
//define void B::test(int)
void B::test(float){} //error: again there is no such class and no such function to define
Code:
// here you have defined 'struct A' with the name 'matrix<?, ?, ?>'.
template <int nrows, int ncols, int ld> class cmatrix
{
// here you have declared 'void A::test(int)' with the name 'void msgo(cupper<?,?>&)'
template <int uld> inline void mgso( cupper<ncols,uld> &);
};
// here you have defined 'void A::test(int)' with the name 'void msgo(cupper<?,?>&)'
template <int nrows, int ncols, int ld> template <int uld>
inline void cmatrix<nrows,ncols,ld>::mgso( cupper<ncols,uld> &R){}
Code:
// now consider the problem source (with corrected syntax)
template <int nrows, int ld> template <int uld>
inline void cmatrix<nrows,0,ld>::mgso( cupper<0,uld> &R){}
// the default template for 'cmatrix' doesn't have a declaration for such a function
// the parameter of 'cupper<0,?> &' doesn't match the parameter 'cupper<?,?> &'
// you've attempted to define a function of an enclosing class 'cmatrix<nrows,0,ld>'
// that is an expansion of a partial specialization of a template
// this is basically the same as the forth example above