Code Monkey home page Code Monkey logo

Comments (6)

sharkdp avatar sharkdp commented on May 25, 2024

Thank you for reporting this. That should be fixed.

If there is a solution without duplicating all declarations, that would be great. But I guess that's actually the right thing to do.

from dbg-macro.

YarikTH avatar YarikTH commented on May 25, 2024

I think that alternative is using one big function pretty_print with constexpr_if branches. I used it in another project. Easy to maintain, easy to understand. But need to bump std to c++17. I think that for this project it's unwanted.

    template<typename Field>
    inline void process_field( const size_t depth, std::ostream& ss, const char* field_name, Field&& field )
    {
        if constexpr( is_element_container_v<Field> || is_key_value_container_v<Field> || is_pair_v<Field> || is_tuple_v<Field> )
        {
            if constexpr( is_element_container_v<Field> )
            {
                constexpr bool is_simple_element = is_simple_type_v<typename remove_cvref_t<Field>::value_type>;
                ...
            }
            else if constexpr( is_key_value_container_v<Field> )
            {
                ...
            }
            else if constexpr( is_pair_v<Field> )
            {
                ...
            }
            else if constexpr( is_tuple_v<Field> )
            {
                process_tuple_fields( depth + 1, ss, field );
            }
            else
            {
                static_assert( !std::is_same_v<Field,Field>, "We shouldn't be here! Something went wrong." );
            }
        }
        else if constexpr( has_dereference_operator_v<remove_cvref_t<Field>> )
        {
            if( !field )
            {
                apply_depth();
                append_field_name();
                ss << "nullptr";
            }
            else
            {
                process_field( depth, ss, field_name, *field );
            }
        }
        else if constexpr( has_ostream_operator_v<Field> )
        {
            ...
        }
        else if constexpr( std::is_enum_v<remove_cvref_t<Field>> )
        {
            ...
        }
        else
        {
            static_assert( !std::is_same_v<Field,Field>, "Given type is not supported. Please overload std::ostream operator or something." );
        }
    }

from dbg-macro.

sharkdp avatar sharkdp commented on May 25, 2024

Yes. I would like to maintain C++11 backwards compatibility.

from dbg-macro.

anstadnik avatar anstadnik commented on May 25, 2024

Hi, are you planning to fix that issue?
I guess it's kinda important to be able to print nested containers.
I can also add that it doesn't work well with tuples of containers:

  tuple<vector<int>>hm{{1}};
  dbg(hm);

outputs a lot of errors.
If not, IMHO it would be great to add a message which says this type is not supported or something. Currently it breaks the compilation.

from dbg-macro.

sharkdp avatar sharkdp commented on May 25, 2024

Hi, are you planning to fix that issue?

Yes, this should be fixed. We can go the easy way for now and duplicate all declarations. Any help would be very much appreciated.

from dbg-macro.

sharkdp avatar sharkdp commented on May 25, 2024

Fixed by @YarikTH in #110

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.