473,473 Members | 1,573 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Template/inheritance problem with ICC

2 New Member
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 2559
aitrob
2 New Member
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 Recognized Expert Moderator Specialist
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

3
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...
13
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 { }; ...
3
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... ...
2
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...
1
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...
5
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...
13
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...
2
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:...
9
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. ...
32
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.