Fails with Eigen matrices
roger- opened this issue · 7 comments
When trying to print Eigen::MatrixXd objects I get an assertion. Eigen::VectorXd objects work though.
Any ideas?
@roger- Could you please share a minimal example to reproduce the issue?
Sure:
Eigen::MatrixXd X(2, 2);
X.setIdentity();
dbg(X);
@roger- I am unable to reproduce the issue. It might be specific to your arch/compiler/c++ std/eigen version.
Here is my attempt - https://godbolt.org/z/Gc8Y1WhMr
Could you try reproducing your issue in godbolt and share it here?
Looks like it fails with Eigen 3.4: https://godbolt.org/z/o8vYzGnWo
Thank you for reporting this. The problem seems to be that we treat the Eigen matrix as a container via this piece of code:
Lines 382 to 389 in 1aaa880
I guess that would need to be adapted in order to fix the Eigen matrix case.
@sharkdp What should be the approach here? From what I understand we have two options,
- Eigen is not part of the std library. We should fail when trying to
dbg(...)
Eigen objects and expect the user to add overloads in such scenarios - Add support for Eigen
I would go with (1) if given the option
It's kind of Eigen's fault, in my opinion. They provide .begin()
and .end()
for Eigen::MatrixXd
, but you're not allowed to use them (will result in a static assertion failing). This makes it hard to detect with meta programming. We could maybe forward-declare and special-case it somehow, but I'm not sure if that's a scalable approach.