468,135 Members | 1,455 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,135 developers. It's quick & easy.

Template/inheritance problem with ICC

2
Hi,

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
  1. #include <blitz/array.h>
  2.  
  3. using namespace blitz;
  4.  
  5. template<typename numtype, int rank>
  6. class Tensor : public Array<numtype, rank>
  7. {
  8. public:
  9.     Tensor<numtype, rank>() :
  10.         blitz::Array<numtype, rank>() {}
  11.     Tensor<numtype, rank>(int i1) :
  12.         blitz::Array<numtype, rank>(i1) {}
  13.     Tensor<numtype, rank>(int i1, int i2) :
  14.         blitz::Array<numtype, rank>(i1, i2) {}
  15.  
  16.     // ...and so forth up to rank 9
  17.  
  18.     // some methods...
  19. };
  20.  
  21. int main()
  22. {
  23.     Tensor<double,2> t;
  24.     return 0;
  25. }
The errors I get are:

Expand|Select|Wrap|Line Numbers
  1. question.cpp(9): error: argument of type "int (blitz::Array<double, 2>::*)() const" is incompatible with template parameter of type "int"
  2.         Tensor<numtype, rank>() :
  3.                         ^
  4.           detected during instantiation of class "Tensor<numtype, rank> [with numtype=double, rank=2]" at line 23
  5.  
  6. question.cpp(9): error: type used as constructor name does not match type "Tensor<double, 2>"
  7.         Tensor<numtype, rank>() :
  8.         ^
  9.           detected during instantiation of class "Tensor<numtype, rank> [with numtype=double, rank=2]" at line 23
  10.  
  11. question.cpp(11): error: argument of type "int (blitz::Array<double, 2>::*)() const" is incompatible with template parameter of type "int"
  12.         Tensor<numtype, rank>(int i1) :
  13.                         ^
  14.           detected during instantiation of class "Tensor<numtype, rank> [with numtype=double, rank=2]" at line 23
  15.  
  16. question.cpp(11): error: type used as constructor name does not match type "Tensor<double, 2>"
  17.         Tensor<numtype, rank>(int i1) :
  18.         ^
  19.           detected during instantiation of class "Tensor<numtype, rank> [with numtype=double, rank=2]" at line 23
  20.  
  21. question.cpp(13): error: argument of type "int (blitz::Array<double, 2>::*)() const" is incompatible with template parameter of type "int"
  22.         Tensor<numtype, rank>(int i1, int i2) :
  23.                         ^
  24.           detected during instantiation of class "Tensor<numtype, rank> [with numtype=double, rank=2]" at line 23
  25.  
  26. question.cpp(13): error: type used as constructor name does not match type "Tensor<double, 2>"
  27.         Tensor<numtype, rank>(int i1, int i2) :
  28.         ^
  29.           detected during instantiation of class "Tensor<numtype, rank> [with numtype=double, rank=2]" at line 23
  30.  
  31. question.cpp(10): error: argument of type "int (blitz::Array<double, 2>::*)() const" is incompatible with template parameter of type "int"
  32.                 blitz::Array<numtype, rank>() {}
  33.                                       ^
  34.           detected during instantiation of "Tensor<numtype, rank>::Tensor() [with numtype=double, rank=2]" at line 23
  35.  
  36. question.cpp(10): error: "Array" is not a nonstatic data member or base class of class "Tensor<double, 2>"
  37.                 blitz::Array<numtype, rank>() {}
  38.                 ^
  39.           detected during instantiation of "Tensor<numtype, rank>::Tensor() [with numtype=double, rank=2]" at line 23
  40.  
Thanks for any suggestions!
Bela
Nov 17 '07 #1
2 2167
aitrob
2
Just in case anyone's interested: we've found the solution. ICC apparently defines "rank" as a macro or something - and you cannot use it in your own code. So just replacing rank by something else everywhere in the code makes things work.
Bela
Nov 19 '07 #2
sicarie
4,677 Expert Mod 4TB
Well thanks for posting the solution. Sorry we couldn't help you this time, but feel free to post again!
Nov 19 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by Thomas Matthews | last post: by
2 posts views Thread by Tony Johansson | last post: by
1 post views Thread by Tony Johansson | last post: by
5 posts views Thread by Tony Johansson | last post: by
13 posts views Thread by jois.de.vivre | last post: by
2 posts views Thread by Thomas Kowalski | last post: by
9 posts views Thread by stephen.diverdi | last post: by
32 posts views Thread by Stephen Horne | last post: by
1 post views Thread by gcdp | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.