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

Error in returning VectorBlock

Tags: None
(comma "," separated)
coolcat
Registered Member
Posts
20
Karma
0
OS

Error in returning VectorBlock

Tue Jul 24, 2012 9:49 am
What is wrong with the following derived class from Vector6d, the typedeffed name Eigen::Matrix<double,6,1>?

class Twist : public Vector6d
{
public:
...

inline Eigen::VectorBlock<Vector6d, 3> v() { return head<3>(); }
inline Eigen::VectorBlock<Vector6d, 3> w() { return tail<3>(); }
inline const Eigen::VectorBlock<Vector6d, 3> v() const { return head<3>(); } // Error
inline const Eigen::VectorBlock<Vector6d, 3> w() const { return tail<3>(); } // Error

...
}

The errors happen for the last two lines and unver MS VS2010 they are something like:
error C2664: 'Eigen::VectorBlock<VectorType,Size>::VectorBlock(const Eigen::VectorBlock<VectorType,Size> &)' : Cannot change parameter 1 from 'const Eigen::VectorBlock<VectorType,Size>' to 'const Eigen::VectorBlock<VectorType,Size> &'.
coolcat
Registered Member
Posts
20
Karma
0
OS

Re: Error in returning VectorBlock

Tue Jul 24, 2012 10:11 am
I found the solution. Just add 'const' in the template parameter as follows:

inline const Eigen::VectorBlock<const Vector6d, 3> v() const { return head<3>(); }
inline const Eigen::VectorBlock<const Vector6d, 3> w() const { return tail<3>(); }


Bookmarks



Who is online

Registered users: Baidu [Spider], Bing [Bot], Google [Bot]