Git Product home page Git Product logo

Comments (7)

winwinashwin avatar winwinashwin commented on June 10, 2024 1

@roger- Could you please share a minimal example to reproduce the issue?

from dbg-macro.

roger- avatar roger- commented on June 10, 2024

Sure:

Eigen::MatrixXd X(2, 2);
X.setIdentity();

dbg(X);

from dbg-macro.

winwinashwin avatar winwinashwin commented on June 10, 2024

@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?

from dbg-macro.

roger- avatar roger- commented on June 10, 2024

Looks like it fails with Eigen 3.4: https://godbolt.org/z/o8vYzGnWo

from dbg-macro.

sharkdp avatar sharkdp commented on June 10, 2024

Thank you for reporting this. The problem seems to be that we treat the Eigen matrix as a container via this piece of code:

dbg-macro/dbg.h

Lines 382 to 389 in 1aaa880

template <typename T>
struct is_container {
static constexpr bool value =
is_detected<detect_begin_t, T>::value &&
is_detected<detect_end_t, T>::value &&
is_detected<detect_size_t, T>::value &&
!std::is_same<std::string, remove_cvref_t<T>>::value;
};

I guess that would need to be adapted in order to fix the Eigen matrix case.

from dbg-macro.

winwinashwin avatar winwinashwin commented on June 10, 2024

@sharkdp What should be the approach here? From what I understand we have two options,

  1. 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
  2. Add support for Eigen

I would go with (1) if given the option

from dbg-macro.

sharkdp avatar sharkdp commented on June 10, 2024

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.

from dbg-macro.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.