   Templates and Typedefs
  Hi all!I''m just writing on a matrix/vector library and want to handle vectors as 1D-matrices.My matrix class looks like this:   template<unsigned int m, unsigned int n, class T = float>class matrix{public:// Constructormatrix() {}// some methodsprotected:Telement[m*n];};Now I''d like to typedef my special versions:   template<unsigned int m, class T = float>typedef matrix<m,1,T> column_vec;template<unsigned int m, class T = float>typedef matrix<1,m,T> row_vec;But this doesn''t work. Now I tried to derive the classes:   template<unsigned int m, class T = float>class column_vec : public matrix<m,1,T>{};template<unsigned int m, class T = float>class row_vec : public matrix<1,m,T>{};But I''ve to declare here all constructors and I''ve got some problems when casting implicit from matrix to column_vec/row_vec. These problems won''t occur with typedef. So what to do?Thanks a lot!   --------------------------------------------------------There is a theory which states that if ever anybody discovers exactly what the Universe is for and why it is here, it will instantly disappear and be replaced by something even more bizarre and inexplicable.There is another theory which states that this has already happened... 
  It''s a bit of a hack, but how about this: template<unsigned int m, unsigned int n = 0, class T = float>class matrix{public:// Constructormatrix(){}// some methodsprotected:T element[m*n];};template <unsigned int d, class T = float>class matrix<d, 0, T>{public:typedef matrix<d, 1, T> column_vec;typedef matrix<1, d, T> row_vec;private:matrix();};int main(){matrix<3, 3> m1;matrix<3>::column_vec m2;matrix<3>::row_vec m3;}Enigma ;  Well, you can''t have templated typedefs.  How about: template<int n, class T=float>struct RowVector{typedef matrix<1,n,T> Type;};RowVector<5>::Type rowVec;;  Thanks a lot!!It''s really quite dirty programming but it works! Thank you!   --------------------------------------------------------There is a theory which states that if ever anybody discovers exactly what the Universe is for and why it is here, it will instantly disappear and be replaced by something even more bizarre and inexplicable.There is another theory which states that this has already happened... 