Problems with template template parameter
Alexander Helm
helm@fs.tum.de
Sun Dec 15 21:53:00 GMT 2002
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
I'm sorry, I don't know if it's a bug or just my fault. If I compile the
following code with g++-2.95 everything is fine. Version 3.2.1 complaints.
The code:
~ #include <iostream>
~ using namespace std;
~ template<int rows, int cols, template<int rows, int cols> class C>
~ class Matrix_Base {
~ public:
~ Matrix_Base() {
~ cout << __PRETTY_FUNCTION__ << endl;
~ };
~ template<int cols2>
~ C<rows,cols2>* operator*(C<cols,cols2>& lhs) {
~ return 0;
~ }
~ };
~ template<int rows, int cols>
~ class Matrix : public Matrix_Base<rows,cols,Matrix> {
~ public:
~ Matrix() : Matrix_Base<rows,cols,Matrix>() {
~ cout << __PRETTY_FUNCTION__ << endl;
~ };
~ };
~ template<int rows>
~ class Matrix<rows,1> : public Matrix_Base<rows,1,Matrix> {
~ public:
~ Matrix() : Matrix_Base<rows,1,Matrix>() {
~ cout << __PRETTY_FUNCTION__ << endl;
~ };
~ };
~ int main (int argc, char **argv) {
~ Matrix<2,2> A;
~ Matrix<2,1> B;
~ A*A;
~ }
The error message of g++ (3.2.1):
~ test2.cc: In constructor `Matrix<rows, 1>::Matrix()':
~ test2.cc:29: type/value mismatch at argument 3 in template parameter
~ list for `template<int rows, int cols, template<int rows, int cols>
~ class C> class Matrix_Base'
~ test2.cc:29: expected a class template, got `Matrix<rows, 1>'
~ test2.cc:29: class `Matrix<rows, 1>' does not have any field named `
~ <declaration error>'
~ test2.cc: In function `int main(int, char**)':
~ test2.cc:36: warning: unused variable `Matrix<2, 1> B'
Any help will be appreciated.
Thanks in advance
Alexander
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.0 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQE9/NJgdcrm1qkhaakRAh5UAJ0V7cWRSe3B8Uj5KAF0dF4UaFlUUACggHgx
q8qP7BoAq/KXh33rQ5T1ApI=
=5h09
-----END PGP SIGNATURE-----
More information about the Gcc-help
mailing list