Reply to topic

Forward declaration

arennuit
Registered Member
Posts
12
Karma
0

Forward declaration

Tue Dec 03, 2013 12:17 pm
Hello,

I would like to declare an array based on Eigen::Quaternionf. The more I pull on what I need to forward declare from Eigen in order to do so, the more I have to forward declare and it is becoming heavy to handle. I currently have:

Code: Select all
#pragma once

#include <vector>

namespace Eigen // I use this namespace because I want to add things to Eigen.
{
template<typename _Scalar, int Options = AutoAlign> class Quaternion; // Forward declaration of Quaternion.

typedef Quaternion<float> Quaternionf; // Forward declaration of typedef Quaternionf.

typedef std::vector<Quaternionf> QuaternionfArray;
} // namespace Eigen.


AutoAlign is yet to be forward declared in this code, but it is already becoming unmanageable as is...

Is there a smart way to handle this?

Thanks ;)

Antoine.

PS: I am not even sure the default argument for template parameter 'Options' is 'AutoAlign', does anyone confirm?
User avatar ggael
Moderator
Posts
2193
Karma
15
OS

Re: Forward declaration  Topic is solved

Tue Dec 03, 2013 1:18 pm
Because Eigen is so heavily templated, it will be difficult to forward declare it. Just include Eigen/Geometry in your header. A very long time ago, we tried to define a ForwardDeclare header for Eigen, but the gain in term of compilation speed was negligible, so we gave up. Precompiled-header are much more effective.
User avatar ggael
Moderator
Posts
2193
Karma
15
OS

Re: Forward declaration

Tue Dec 03, 2013 1:20 pm
Well, for Quaternion, the following should do the job though:

template<typename _Scalar, int Options = 0> class Quaternion;

Whenever possible, we make sure that optional parameters default to 0.
arennuit
Registered Member
Posts
12
Karma
0

Re: Forward declaration

Tue Dec 03, 2013 1:50 pm
Very helpful!
arennuit
Registered Member
Posts
12
Karma
0

Re: Forward declaration

Wed Dec 04, 2013 4:30 pm
Hum, and for the multiple definitions, what do you advise me? There is not much else than ignoring the warnings I guess?

Thanks.
User avatar ggael
Moderator
Posts
2193
Karma
15
OS

Re: Forward declaration

Wed Dec 04, 2013 5:18 pm
yep, no trick for that one.
arennuit
Registered Member
Posts
12
Karma
0

Re: Forward declaration

Wed Dec 04, 2013 11:06 pm
Done, thanks for your answer!

 
Reply to topic

Bookmarks



Who is online

Registered users: AGB, airdrik, alake, Alexa [Bot], anditosan, Artmessiah, asevens, Baidu [Spider], belnac, Bing [Bot], colomar, Exabot [Bot], garthecho, Google [Bot], google01103, GreatEmerald, kainz.a, koriun, La Ninje, MiceAreVeryNice, mmistretta, nezumi, parzt, Philippe44, scummos, SeaJey, SurfFalke, Tuukka, wolfi323, Yahoo [Bot]