The argument in version B is correct, b!t not the return type which should be Derived::PlainObject
. You also need the template disambiguate keyword to access template member within templated code:
template<typename Derived>
typename Derived::PlainObject bar(const Eigen::MatrixBase<Derived>& v)
{
EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived);
EIGEN_STATIC_ASSERT(Derived::RowsAtCompileTime == 3,
THIS_METHOD_IS_ONLY_FOR_MATRICES_OF_A_SPECIFIC_SIZE);
typename Derived::PlainObject ret;
Vector3d a = v.template leftCols<1>();
return ret;
}