vs2019运行Eigen库报错:error C2280 “Eigen::Block<Derived,-1,-1,false> &Eigen::Block<Derived,-1,-1,false>

问题描述

在调用eigen相关函数中出现如下报错:

error C2280 "Eigen::Block<Derived,-1,-1,false> &Eigen::Block<Derived,-1,-1,false>::operator =(const Eigen::Block<Derived,-1,-1,false> &)": attempting to reference a deleted function

定位的Eigen库头文件位置:

include\Eigen\src\Core\SolveTriangular.h

报错代码段

/** "in-place" version of TriangularView::solve() where the result is written in \a other
  *
  * \warning The parameter is only marked 'const' to make the C++ compiler accept a temporary expression here.
  * This function will const_cast it, so constness isn't honored here.
  *
  * See TriangularView:solve() for the details.
  */
template<typename MatrixType, unsigned int Mode>
template<int Side, typename OtherDerived>
void TriangularView<MatrixType,Mode>::solveInPlace(const MatrixBase<OtherDerived>& _other) const
{
    OtherDerived& other = _other.const_cast_derived();
    eigen_assert( cols() == rows() && ((Side==OnTheLeft && cols() == other.rows()) || (Side==OnTheRight && cols() == other.cols())) );
    eigen_assert((!(Mode & ZeroDiag)) && bool(Mode & (Upper|Lower)));

    enum { copy = internal::traits<OtherDerived>::Flags & RowMajorBit  && OtherDerived::IsVectorAtCompileTime };
    typedef typename internal::conditional<copy,
      typename internal::plain_matrix_type_column_major<OtherDerived>::type, OtherDerived&>::type OtherCopy;
    OtherCopy otherCopy(other);

    internal::triangular_solver_selector<MatrixType, typename internal::remove_reference<OtherCopy>::type,
      Side, Mode>::run(nestedExpression(), otherCopy);

    if (copy)
      other = otherCopy;
}

解决方法

参考:stackoverflow
对Eigen库头文件Macros.h(位置:Eigen/src/Core/util/Macros.h)进行修改

#if defined(_MSC_VER) && (!defined(__INTEL_COMPILER))

在这里插入图片描述

替换成

#if defined(_MSC_VER) && (_MSC_VER < 1900) && (!defined(__INTEL_COMPILER))

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值