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 - #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;
-
}
The errors I get are: - 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
-
Thanks for any suggestions!
Bela
2 2559
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
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!
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: 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...
| |
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,...
|
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...
|
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...
|
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,...
|
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...
|
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...
| |
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |