This forum has been archived. All content is frozen. Please use KDE Discuss instead.

[SOLVED] Question on template magic

Tags: None
(comma "," separated)
Seb
Registered Member
Posts
99
Karma
0

[SOLVED] Question on template magic

Mon Apr 27, 2009 6:44 pm
Hi there, again.

I have a little question on template magic.

Namely, I want to subclass Matrix
Code: Select all
class MathArrayBase : public Eigen::Matrix

Within my class I call the method
Code: Select all
typedef double TScalar;
typedef Matrix Base;
MathArrayBase MathArrayBase::operatorBase::cwise() () );
}


I need the call of 'cast' because cwise()
MathArrayBase MathArrayBase::operator( (this->Base::cwise() () );
}
[/code]

The problem: The compiler complains at 'cast()' saying
error: expected primary-expression before ‘(’ token
error: expected primary-expression before ‘>’ token
error: expected primary-expression before ‘)’

I am not that confident with templates to resolve this...

When I remove and write XXX.cast() the template compiles fine, but it complains again at the same line when I write
Code: Select all
template classMathArrayBase;

which is natural.

I think this is not really Eigen2-related, but hopefully someone went into the same problem and might offer some solution? Thanks!
User avatar
bjacob
Registered Member
Posts
658
Karma
3

[SOLVED] Question on template magic

Mon Apr 27, 2009 6:52 pm
this is a really nasty aspect of c++ that we learnt while coding eigen2.

the problem is that you need to add a "template" keyword before the cast call, like this:

Code: Select all
matrix.template cast()


Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list!
Seb
Registered Member
Posts
99
Karma
0

[SOLVED] Question on template magic

Wed Apr 29, 2009 10:05 am
bjacob wrote:this is a really nasty aspect of c++ that we learnt while coding eigen2.

the problem is that you need to add a "template" keyword before the cast call, like this:

Code: Select all
matrix.template cast()



Wow! So obvious. Thanks!


Bookmarks



Who is online

Registered users: Bing [Bot], Evergrowing, Google [Bot], rblackwell