mercredi 19 juillet 2017

C++ class follows with template keyword

I am compiling a C++ library that use a C++ mathematics library Eigen3. However, the following codes introduce some syntax errors when compiling with VC2013:

template <typename Derived>
    inline Eigen::Transform<typename Derived::Scalar, 3, Eigen::Isometry> v2t(const Eigen::MatrixBase<Derived>& x_) {
    Eigen::Transform<typename Derived::Scalar, 3, Eigen::Isometry> X;
    Eigen::Matrix<typename Derived::Scalar, 6, 1> x(x_);
    X.template linear() = quat2mat(x.template block<3,1>(3,0));
    X.template translation() = x.template block<3,1>(0,0);
    return X;
  }

The error messages are as follows:

Error   C2059   syntax error : 'template'    
Error   C2039   'X' : is not a member of 'Eigen::Transform<float,3,1,0>'        
Error   C2059   syntax error : 'template'    
Error   C2039   'X' : is not a member of 'Eigen::Transform<float,3,1,0>'    

I have never saw codes like that X.template so I have no idea how I can do to correct this compilation error. Any ideas?

Aucun commentaire:

Enregistrer un commentaire