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 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.
Bela
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: 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...
| |