Column access of some IndexedView won't compile
Submitted by Antoine Bussy
Assigned to Nobody
Link to original bugzilla bug (#1736)
Version: 3.4 (development)
Description
Hi,
The following code won't compile on clang-7 (I also tried gcc-9 and clang-8 on https://godbolt.org/):
#include <Eigen/Core>
#include <array>
auto indexed_view_col()
{
auto const m = Eigen::Matrix4d::Random().eval();
auto ok = m(Eigen::all, Eigen::seq(1, Eigen::last)).col(0).eval();
auto ok2 = m(Eigen::all, Eigen::seq(0, 1)).col(0).eval();
auto err = m(Eigen::all, std::arrayEigen::Index,2{0,1}).col(0).eval();
auto err2= m(Eigen::all, Eigen::VectorEigen::Index,2(0, 1)).col(0).eval();
}
The compilers don't seem to find the unary version of coeff(), and indeed, it isn't in IndexedView.h (whereas it is present in Block.h). I implemented it similarly to Block's:
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
CoeffReturnType coeff(Index index) const
{
return coeff((m_xpr.rows() == 1 ? 0 : index),
(m_xpr.rows() == 1 ? index : 0));
}
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
Scalar& coeffRef(Index index)
{
return coeffRef((m_xpr.rows() == 1 ? 0 : index),
(m_xpr.rows() == 1 ? index : 0));
}
and it seems to solve my problem. but I'm not familiar with Eigen's internals at all, so the root cause might be elsewhere?