Open roger- opened 1 year ago
@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:
https://github.com/sharkdp/dbg-macro/blob/1aaa8805ca0a4852c009805e49074cc3dedf058e/dbg.h#L382-L389
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,
dbg(...)
Eigen objects and expect the user to add overloads in such scenariosI 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.
When trying to print Eigen::MatrixXd objects I get an assertion. Eigen::VectorXd objects work though.
Any ideas?