a valuable tool for debugging c++

most of the bugs in the code can easily be removed if we can just assert our visualisation with the code that we wrote. In python it is easy to do it by just printing the data structures using the str or repr methods of those data structures. but when it comes to c++ we had to write these pretty printing routines for c++ stdlib containers(often a very small subset).

later I found some fast IO code snippet(from codechef) which automatically handles the type safety.

after that I have added some modification to it, to enable pretty printing for vector, pair, dictionary.

life has been easier ever since. but the source code got ugly as I always have to append that (wrath of C++) code for every small program, and it is UGLY!!!!!!!

so I thought to convert it into an offline header(as just for debugging)… but then I found this amazing header-only-library(cxx-prettyprint) that allows pretty-printing of any container. and it also supports C++11

you can download it from here.



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s