This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Problems with template template parameter


Hi Alexander,

How about a different approach: take out the spurious and superfluous third parameter out of the Matrix_Base template? A forward declaration will hold everything together.

--------------------------------------------------
#include <iostream>
using std::cout;
using std::endl;

template<int rows, int cols> class Matrix;

template<int rows, int cols>
class Matrix_Base {
public:
Matrix_Base() {
cout << __PRETTY_FUNCTION__ << endl;
}

template<int cols2>
Matrix<rows, cols2>* operator * (Matrix<cols, cols2>& lhs) {
return 0;
}
};

template<int rows, int cols>
class Matrix : public Matrix_Base<rows, cols> {
public:
Matrix() : Matrix_Base<rows, cols>() {
cout << __PRETTY_FUNCTION__ << endl;
}

};

template<int rows>
class Matrix<rows, 1>
: public Matrix_Base<rows, 1>
{
public:
Matrix() : Matrix_Base<rows, 1>() {
cout << __PRETTY_FUNCTION__ << endl;
}
};

int main (int argc, char **argv) {
Matrix<2, 2> A;
Matrix<2, 1> B;

A*A;
}
--------------------------------------------------

--Eljay


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]