Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/125.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 在Eigen上查找失败的静态断言的源_C++_Static_Assert_Eigen - Fatal编程技术网

C++ 在Eigen上查找失败的静态断言的源

C++ 在Eigen上查找失败的静态断言的源,c++,static,assert,eigen,C++,Static,Assert,Eigen,我正试图编译一个相当大的代码库,它与Eigen有一些依赖关系。这样做,我得到了以下错误:错误C2338:\u括号\u运算符\u仅\u用于向量\u使用\u括号\u运算符\u,而不是源自此处的: // Eigen\src\Core\DenseCoeffsBase.h /** \returns a reference to the coefficient at given index. * * This method is allowed only for vector expres

我正试图编译一个相当大的代码库,它与Eigen有一些依赖关系。这样做,我得到了以下错误:
错误C2338:\u括号\u运算符\u仅\u用于向量\u使用\u括号\u运算符\u,而不是源自此处的

//    Eigen\src\Core\DenseCoeffsBase.h


/** \returns a reference to the coefficient at given index.
  *
  * This method is allowed only for vector expressions, and for matrix expressions having the LinearAccessBit.
  *
  * \sa operator[](Index) const, operator()(Index,Index), x(), y(), z(), w()
  */

EIGEN_STRONG_INLINE Scalar&
operator[](Index index)
{
  #ifndef EIGEN2_SUPPORT
  EIGEN_STATIC_ASSERT(Derived::IsVectorAtCompileTime,
                      THE_BRACKET_OPERATOR_IS_ONLY_FOR_VECTORS__USE_THE_PARENTHESIS_OPERATOR_INSTEAD)
  #endif
  eigen_assert(index >= 0 && index < size());
  return derived().coeffRef(index);
}
//Eigen\src\Core\DenseCoeffsBase.h
/**\返回对给定索引处系数的引用。
*
*此方法仅适用于向量表达式和具有LinearAccessBit的矩阵表达式。
*
*\sa运算符[](索引)常量,运算符()(索引,索引),x(),y(),z(),w()
*/
本征强内联标量&
运算符[](索引)
{
#ifndef特征2_支持
特征静态断言(派生::IsVectorAtCompileTime,
_括号_运算符_仅_向量_使用_括号_运算符_)
#恩迪夫
特征断言(索引>=0&&index

由于代码中到处都是特征依赖项,如何找到触发此错误的行?(显然,有一行代码使用
[]
访问特征矩阵,在某个地方,这就是我正在寻找的代码)。

是的,我也遇到了类似的问题。我将矩阵定义为:

Eigen::MatrixXf minor2x2(2,2)
。当矩阵
minor2x2
初始化如下:

minor2x2[0] = 1.0f;
minor2x2[1] = 1.0f;
minor2x2[2] = 1.0f;
minor2x2[3] = 1.0f;

触发了相同的错误。该问题的解决方案是将
minor2x2[i]
替换为
minor2x2(i)
。我认为找到
Eigen::Matrix
可能会有所帮助

请更仔细地查看编译器消息:您应该在问题的根源处看到完整的调用堆栈。@ggael没有其他内容。我看到您正在使用MSVC,就在错误行之后,您应该会看到几行,其中包含
参见函数模板实例化的参考
,显示触发错误的上下文。如果您看不到,那么您可能需要对UI进行一些操作来显示它们。