DEV Community

Gianluca Bianco
Gianluca Bianco

Posted on

ptc print: a modern C++ implementation of the Python print() function with further improvements

Hello everybody,

I want to present you ptc::print a modern C++ library for custom printing to the output stream. It is basically a detailed implementation of the Python print() function, with several additions.

In particular, some of its features are:

  • It is constructed through the Print functor, which is a fully type- and thread-safe class with automatic memory management, implemented through an header-only library, with no external dependencies.
  • It supports also the usage of ANSI escape sequences.
  • It supports the printing of all the standard types and also std ones (std::vector, std::map etc...).
  • It is possible to choose to print using different char types (char, wchar_t...).

And has a very very simple syntax:

#include <ptc/print.hpp>

int main()
 {
  ptc::print("Hello", 123, nullptr, "bye");
 }
Enter fullscreen mode Exit fullscreen mode

It has also many more features like the possibility to choose end and separator characters (like in Python) or to set a pattern among each printed argument.

In the main readme you can find all the information you want, a list of todo stuff and some preliminar benchmarking studies I performed with respect to other similar libraries.

If you like the repo don't forget to leave a star on GitHub! Thanks.

Repository link: https://github.com/JustWhit3/ptc-print

Top comments (0)