[eigen] Multiple Level CRTP Inheritance

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


I've been practicing template programming mainly by trial and error, looking at the Eigen library, etc. where I've been putting together a hierarchy with a single Base class and many different Derived classes.

I've been successful in getting inlined operator chains that collapse to a single loop with the methodology. In the Base class I have an assignment operator as follows:

   template<typename OtherDerived>
   inline Derived& operator = (const Base<OtherDerived> &B)
   {
    for(int i=0;i<this->size();i++){
      this->operator[](i) = B.derived()[i];
    }
    return this->derived();
  }


While the Derived classes assignment operator looks as follows:

  template<typename OtherDerived>
  inline const Derived& operator = (const Base<OtherDerived> &B){
    return Base::operator = (B);
  }


However, I'm running into problems when I tried to add a middle layer to break
the many Derived classes into subcategories. This would allow catching only certain types of Derived in functions arguments.

Is it possible to have Derived inherit from MiddleBase, which inherits from Base, and get the same inlining characteristics? I can't get the assignment operator to pass the call down the hierarchy, no matter what I've tried. I've gotten errors like "derived() cannot be called without object" and "cannot match return types" and am at a loss to see if this is possible.

I appreciate any help you can give me.

Dalon




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