Problems with template template parameter

Eljay Love-Jensen eljay@adobe.com
Mon Dec 16 08:46:00 GMT 2002


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



More information about the Gcc-help mailing list