I have a problem concerning templates/inheritance. I have a code that compiles fine with g++ 4.0.1 (Apple version), but gives a lot of errors with Intel C++ 10.1 (Mac OS X). I'm not sure if I'm doing something wrong and g++ just doesn't notice, or if the people at Intel are doing something weird...
What am I trying to do? I'm trying to implement a template class that inherits from the Blitz++ array library
Expand|Select|Wrap|Line Numbers
- #include <blitz/array.h>
- using namespace blitz;
- template<typename numtype, int rank>
- class Tensor : public Array<numtype, rank>
- {
- public:
- Tensor<numtype, rank>() :
- blitz::Array<numtype, rank>() {}
- Tensor<numtype, rank>(int i1) :
- blitz::Array<numtype, rank>(i1) {}
- Tensor<numtype, rank>(int i1, int i2) :
- blitz::Array<numtype, rank>(i1, i2) {}
- // ...and so forth up to rank 9
- // some methods...
- };
- int main()
- {
- Tensor<double,2> t;
- return 0;
- }
Expand|Select|Wrap|Line Numbers
- question.cpp(9): error: argument of type "int (blitz::Array<double, 2>::*)() const" is incompatible with template parameter of type "int"
- Tensor<numtype, rank>() :
- ^
- detected during instantiation of class "Tensor<numtype, rank> [with numtype=double, rank=2]" at line 23
- question.cpp(9): error: type used as constructor name does not match type "Tensor<double, 2>"
- Tensor<numtype, rank>() :
- ^
- detected during instantiation of class "Tensor<numtype, rank> [with numtype=double, rank=2]" at line 23
- question.cpp(11): error: argument of type "int (blitz::Array<double, 2>::*)() const" is incompatible with template parameter of type "int"
- Tensor<numtype, rank>(int i1) :
- ^
- detected during instantiation of class "Tensor<numtype, rank> [with numtype=double, rank=2]" at line 23
- question.cpp(11): error: type used as constructor name does not match type "Tensor<double, 2>"
- Tensor<numtype, rank>(int i1) :
- ^
- detected during instantiation of class "Tensor<numtype, rank> [with numtype=double, rank=2]" at line 23
- question.cpp(13): error: argument of type "int (blitz::Array<double, 2>::*)() const" is incompatible with template parameter of type "int"
- Tensor<numtype, rank>(int i1, int i2) :
- ^
- detected during instantiation of class "Tensor<numtype, rank> [with numtype=double, rank=2]" at line 23
- question.cpp(13): error: type used as constructor name does not match type "Tensor<double, 2>"
- Tensor<numtype, rank>(int i1, int i2) :
- ^
- detected during instantiation of class "Tensor<numtype, rank> [with numtype=double, rank=2]" at line 23
- question.cpp(10): error: argument of type "int (blitz::Array<double, 2>::*)() const" is incompatible with template parameter of type "int"
- blitz::Array<numtype, rank>() {}
- ^
- detected during instantiation of "Tensor<numtype, rank>::Tensor() [with numtype=double, rank=2]" at line 23
- question.cpp(10): error: "Array" is not a nonstatic data member or base class of class "Tensor<double, 2>"
- blitz::Array<numtype, rank>() {}
- ^
- detected during instantiation of "Tensor<numtype, rank>::Tensor() [with numtype=double, rank=2]" at line 23
Bela