472,780 Members | 1,767 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,780 software developers and data experts.

Template/inheritance problem with ICC


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>
  3. using namespace blitz;
  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) {}
  16.     // ...and so forth up to rank 9
  18.     // some methods...
  19. };
  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
  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
  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
  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
  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
  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
  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
  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
Thanks for any suggestions!
Nov 17 '07 #1
2 2493
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.
Nov 19 '07 #2
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

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

Similar topics

by: Gandu | last post by:
Could some C++ guru please help me? I have a very odd problem with respect templates and inheritance. I have templatized List class, from which I am inheriting to create a Stack class. All works...
by: Walt Karas | last post by:
The following gives an error in the declaration of the member function x() of the class template Tpl, compiliing with a recent version of GCC under Solaris: class A { }; class B { }; ...
by: Thomas Matthews | last post by:
Hi, I would like to apply inheritance to a template parameter, but my design fails to compile: cannot initialize one template class with child child parameterized class. I'll explain... ...
by: Tony Johansson | last post by:
Hello Experts To derive a concrete class from a template class in invalid. Why?? So you should not be able have something like this class Derived : public Base<int, 100> It's valid to derive...
by: Tony Johansson | last post by:
Hello Experts! I reading a book called programming with design pattern revealed by Tomasz Muldner and here I read something that I don't understand completely. Im I right if I say the...
by: Tony Johansson | last post by:
Hello experts! I have two class template below with names Array and CheckedArray. The class template CheckedArray is derived from the class template Array which is the base class This program...
by: jois.de.vivre | last post by:
Hi All, I'm trying to write a wrapper class for std::vector to extend some of its functionality. The problem I'm getting into is returning an iterator type from a member function. Here is the...
by: Thomas Kowalski | last post by:
Hi, I would like to write a template class Polygon<VertexTypthere vertex typ can be eigther a pointer or a value typ. It has an attribute: std::vector<VertexTypvertices; And a methode:...
by: stephen.diverdi | last post by:
Can anyone lend a hand on getting this particular template specialization working? I've been trying to compile with g++ 4.1 and VS 2005. ...
by: Stephen Horne | last post by:
I've been using Visual C++ 2003 for some time, and recently started working on making my code compile in GCC and MinGW. I hit on lots of unexpected problems which boil down to the same template...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
by: lllomh | last post by:
How does React native implement an English player?
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.