Add support for C++23 multidimensional subscript operator

I'm not sure where to put tests for this, assuming they're needed. They also wouldn't run in CI anyway since CI only exercises the C++17 codepaths.

See merge request libeigen/eigen!2053
This commit is contained in:
Tyler Veness
2025-11-04 07:03:04 +00:00
committed by Rasmus Munk Larsen
parent b6fcddccfc
commit f95b4698fc
6 changed files with 47 additions and 1 deletions

View File

@@ -117,6 +117,10 @@ class SimpleTensorContractionMapper {
return m_tensor.coeff(computeIndex(row, col));
}
#if __cpp_multidimensional_subscript >= 202110L
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator[](Index row, Index col) const { return operator()(row, col); }
#endif
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index computeIndex(Index row, Index col) const {
const bool left = (side == Lhs);
EIGEN_UNUSED_VARIABLE(left); // annoying bug in g++8.1: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85963