Skip to content

fmt/ranges.h incompatible with Eigen 3.4 #3839

Closed
@baronep

Description

Eigen 3.4 seems to have a significant change in behavior where begin() exists for all matrices, but returns void for non 1-D matrices where iteration is not well defined.

This currently interferes with the fmt/ranges.h implementation such that the following code compiles with Eigen 3.9, but no longer compiles with 3.4.

#include <Eigen/Core>

#include <fmt/format.h>
#include <fmt/ostream.h>
#include <fmt/ranges.h> // doesn't work if uncomment this

int main() {
  Eigen::Matrix3d m;
  m << 1, 2, 3, 4, 5, 6, 7, 8, 9;
  fmt::print("{}\n", m);

  return 0;
}

Note: This was built using the -DFMT_DEPRECATED_OSTREAM compiler flag

<source>:10:13:   required from here
/opt/compiler-explorer/libs/fmt/9.1.0/include/fmt/ranges.h:264:34: error: void value not ignored as it ought to be
  264 |     decltype(*detail::range_begin(std::declval<Range&>()));

Godbolt Example: https://godbolt.org/z/TzG7TMxWx

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions