HNHacker News
TopNewBestAskShowJobs

philip82148

40 karma · joined September 30, 2023

submissionscomments
philip82148··on Show HN: A C++ dump func. that can print multi-D vectors, maps, tuples, and all
Sorry, plz ignore this comment. I just changed the source. I used std::tuple_size to handle everything that has a valid `std::tuple_size` specialization.
philip82148··on Show HN: A C++ dump func. that can print multi-D vectors, maps, tuples, and all
Oh, I forgot to mention this, but I am already using std::tuple_size. There is no reason not to handle/accept everything that has a valid `std::tuple_size` specialization. (I am not a native speaker, so I might have misunderstood your reply.)
philip82148··on Show HN: A C++ dump func. that can print multi-D vectors, maps, tuples, and all
The macro version is for printing the variable's name. But it also has a function version. Why this library has some other macros is written in my new comment. Also, (though I hadn't mentioned competitive programming before my new comment,) as far as competitive programming is concerned, I prefer `dump()` to operator<<, which has more letters/types(`cout << variable << endl;`).
philip82148··on Show HN: A C++ dump func. that can print multi-D vectors, maps, tuples, and all
I thought it would be odd to use C++ as an analogy for C++ itself. But it might be confusing. I'll reconsider. Thank your for the feedback!
philip82148··on Show HN: A C++ dump func. that can print multi-D vectors, maps, tuples, and all
Yes, this dumps recursively, so it also supports with nested ones. Why I made this is written in my new comment.
philip82148··on Show HN: A C++ dump func. that can print multi-D vectors, maps, tuples, and all
What I want to do with this library is to make a C++ version of JavaScript's console.log(), PHP's var_dump(), or Python's print(objs...). In other words, this library aims to print variables of any types easily for debugging.

BTW, actually I made this for competitive programming. The reason the library has some macros is also the macros are useful for competitive programming. And I thought it might be useful also for debugging productions, so I created this post.

I am learning a lot from everyone's advice. New advice is welcome, too. (I don't want harsh advice, though. :smile:)

philip82148··on Show HN: A C++ dump func. that can print multi-D vectors, maps, tuples, and all
Would you tell me what I should use instead of std::clog and std::endl? (Is it a deleted comment? I'm not used to HN because this is the first time for me.)
philip82148··on Show HN: A C++ dump func. that can print multi-D vectors, maps, tuples, and all
Thank you for your advice! I appreciate it and I'll do so.
philip82148··on Show HN: A C++ dump func. that can print multi-D vectors, maps, tuples, and all
Wow, I didn't know about this. Does this also support formatting nested containers with auto indent? I couldn't figure it out from the README.
philip82148··on Show HN: A C++ dump func. that can print multi-D vectors, maps, tuples, and all
It supports both std::pair and std::tuple. But I used std::get instead of std::tuple_element. I'll change it. Thank you for your advice!