Linux-to-Windows:非易失性const整数类型

时间:2017-03-28 11:43:11

标签: c++

我有一些代码,写在Linux上,我试图在Windows中编译,Visual Studio 2015。

在其中一个Header文件中:

    #include <Eigen/Core>
    #include <Eigen/Geometry>
    #include <Eigen/StdVector>
    #include "transformable_vector.h"

    namespace nicp {

      template <int wCoordinate_>
        class HomogeneousVector4f : public Eigen::Vector4f {
      public:
        EIGEN_MAKE_ALIGNED_OPERATOR_NEW;

        static const float wCoordinate = wCoordinate_;

}

行:

 template <int wCoordinate_>
    class HomogeneousVector4f : public Eigen::Vector4f {
  public:
    EIGEN_MAKE_ALIGNED_OPERATOR_NEW;

    static const float wCoordinate = wCoordinate_;

给了我这个错误:

Error   C2864   'nicp::HomogeneousVector4f<0>::wCoordinate': a static data member with an in-class initializer must have non-volatile const integral type

我尝试删除const,并将其替换为constexpr,但结果相同。

我试过了:

const float HomogeneousVector4f<wCoordinate_>::wCoordinate = wCoordinate_;

以及:

 static constexpr float wCoordinate () { return wCoordinate_; }

和:

static float wCoordinate () { return wCoordinate_; }
编辑:我已经尝试了标记为“重复”的问题中的所有答案,但无济于事。我相信这里的区别是这个类是通过传递给它的int创建的。

谢谢。

0 个答案:

没有答案
相关问题