3

What i am trying to do is to compile project which was built by CMake. In my code i have next method:

/** "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;
}

When i try to compile i get next error:

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

at line

other = otherCopy;

How can i get rid of it?

UPD

When i hit F12 ("Go to definition") on OtherDerived, cursor jumps to the line #332 in the following file: http://codepad.org/9zN8inib

template<int Side, typename OtherDerived>
void solveInPlace(const MatrixBase<OtherDerived>& other) const;

(top one)

oleg.v
  • 905
  • 3
  • 10
  • 19
  • Are you sure that OtherDerived have a Copy constructer? Rule of 5 http://stackoverflow.com/questions/4782757/rule-of-three-becomes-rule-of-five-with-c11 – Lord_Curdin Apr 18 '17 at 12:44
  • Does `OtherDerived` type have copy constructor? Also, from my experience, VS can generate this type of error if compiler failed to generate default ctor or default copy ctor for any reason (e.g. one of the members does not have default ctor) – Aleksei Petrenko Apr 18 '17 at 12:44
  • I've updated post, please check it out. – oleg.v Apr 18 '17 at 12:55
  • @Sleepwalker Make sure you're not stumbling upon [this bug](http://eigen.tuxfamily.org/bz/show_bug.cgi?id=920) – Marco A. Apr 18 '17 at 12:58
  • 1
    @MarcoA. could you please have a look at code i've posted (updated my question one more time)? – oleg.v Apr 18 '17 at 13:07

2 Answers2

4

I ran into this myself, turned out to be a bug in Eigen. In my case, just replacing the following line in src/Eigen/Eigen/src/Core/util/Macros.h

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

with

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

solved this issue. The assignment operators are then generated.

Ben
  • 1,169
  • 20
  • 33
0

It seems that you try to reinitialize the reference by doing

OtherDerived& other = _other.const_cast_derived();

and then

other = otherCopy;
tkrishtop
  • 501
  • 1
  • 5
  • 16
  • It compiles with no changes, i still get same error. I don't understand why can't you view my code, probably you could advice me better service to share code with? It would be gladly appreciated. – oleg.v Apr 18 '17 at 15:27
  • Your code should all be at StackOverflow for it to be a good question. I mean how would future readers benefit when the remote site removes your code? Please reduce your code to make a minimal example. – drescherjm Apr 18 '17 at 18:04