Git Product home page Git Product logo

Comments (10)

sharkdp avatar sharkdp commented on June 10, 2024

Thank you for reporting this. Can you provide an example that I could reproduce (without dependencies on external libraries)?

from dbg-macro.

Aincvy avatar Aincvy commented on June 10, 2024

Strange, I cann't reproduce this in other project.

The thing that I don't understand is, std::cout << pos; works fine, but dbg(pos); not.

Here is the build error output.

[build] In file included from ../sight_external_widgets.cpp:8:
[build] In file included from ../dependencies/sight-util/sight_defines.h:11:
[build] ../dependencies/dbg-macro/dbg.h:443:3: error: static_assert failed due to requirement 'detail::has_ostream_operator<const ImVec2 &>::value' "Type does not support the << ostream operator"
[build]   static_assert(detail::has_ostream_operator<const T&>::value,
[build]   ^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[build] ../dependencies/dbg-macro/dbg.h:452:3: note: in instantiation of function template specialization 'dbg::pretty_print<ImVec2>' requested here
[build]   pretty_print(stream, value,
[build]   ^
[build] ../dependencies/dbg-macro/dbg.h:773:38: note: in instantiation of function template specialization 'dbg::pretty_print<ImVec2>' requested here
[build]     const bool print_expr_and_type = pretty_print(stream_value, ref);
[build]                                      ^
[build] ../dependencies/dbg-macro/dbg.h:765:12: note: in instantiation of function template specialization 'dbg::DebugOutput::print_impl<ImVec2 &>' requested here
[build]     return print_impl(exprs.begin(), types.begin(), std::forward<T>(values)...);
[build]            ^
[build] ../sight_external_widgets.cpp:196:9: note: in instantiation of function template specialization 'dbg::DebugOutput::print<ImVec2 &>' requested here
[build]         dbg(pos);             //  Type does not support the << ostream operator
[build]         ^
[build] ../dependencies/dbg-macro/dbg.h:893:8: note: expanded from macro 'dbg'
[build]       .print({DBG_MAP(DBG_STRINGIFY, __VA_ARGS__)}, \
[build]        ^
[build] 1 error generated.
[build] ninja: build stopped: subcommand failed.
[build] Build finished with exit code 1

If you are still interested, you can check the code at https://github.com/Aincvy/sight.

from dbg-macro.

sharkdp avatar sharkdp commented on June 10, 2024

Could you try moving the ostream operator definition into the global namespace?

from dbg-macro.

Aincvy avatar Aincvy commented on June 10, 2024

I have tried this: move it into a namespace, and the error reproduces.

Here is the code file
test-code.zip
.

from dbg-macro.

sharkdp avatar sharkdp commented on June 10, 2024

I am not sure, but I don't think this is good practice... shouldn't the ostream operator be defined in the global namespace?

from dbg-macro.

Aincvy avatar Aincvy commented on June 10, 2024

I don't know....

I did not find too may things about that.It seems not a well-known rule.

Would you fix it or not?
If not, could you please add something into readme file?

from dbg-macro.

sharkdp avatar sharkdp commented on June 10, 2024

see for example: https://stackoverflow.com/a/9230853/704831

If there is a clear guideline somewhere that it is OKAY to overload the operator within the user namespace, I'm inclined to fix this in dbg.h. Any help is appreciated.

from dbg-macro.

Aincvy avatar Aincvy commented on June 10, 2024

I move the struct ImVec2 into the namespace sight, then it compiles fine.
Looks like the operator overloading function isn't found.
A bug in the compiler perhaps.

Using decltype fails with an operator using non-ADL lookup
Namespaces and Operator Overloading in C++

from dbg-macro.

sharkdp avatar sharkdp commented on June 10, 2024

Ok, so you say this can be closed? Or has the bug not been fixed?

from dbg-macro.

Aincvy avatar Aincvy commented on June 10, 2024

I think we can do nothing about that, close it.

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.