Re: [eigen] Inheritence

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


I think even that example is not perfect. Constructors are not inherited, so you will need to re-declare any constructors you want also. You probably want at least the copy constructor from an arbitrary Eigen matrix type. And operator= is more easily defined with a using statement if you do not need additional behavior from it. I wrote up an example at http://www.ros.org/wiki/eigen#Creating_typedefs_for_Eigen_types for a coworker who wanted something like a "templated typedef" over Eigen types. The inheritance approach as you can see is pretty complicated to get right.

Usual caveats about inheriting from STL containers also apply, see for example this thread: http://www.phwinfo.com/forum/comp-lang-cplus/333672-avoid-inheritance-std-map.html

Patrick

On Thu, Feb 4, 2010 at 2:59 AM, Thomas Capricelli <orzel@xxxxxxxxxxxxxxx> wrote:

It is not recommended, but possible, see
http://eigen.tuxfamily.org/dox-devel/CustomizingEigen.html#InheritingFromMatrix

++
--
In data giovedì 04 febbraio 2010 06:29:03, Daniel Stonier ha scritto:
> Just a curioisity...are there any ramifications to inheriting vector
> classes? Is it inadvisable for any particular reason?





Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/