How to overload "cout <<" to print anything?

Revision en1, by royappa, 2020-06-16 20:54:49

I seem to remember, but cannot find, a tutorial posted here on how to use new features in C++ to print things more easily from cout.

It showed how to set it up so you can do "cout << x" on several common data structures (vectors, pairs, maps, etc.) and it would print them, e.g., a vector may print out as "32 12 45\n". Of course you would have to implement some code for each datatype you want.

If someone remembers this tutorial or can show how, I would appreciate greatly. Thanks!

Tags c++, cout

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English royappa 2020-06-16 20:54:49 538 Initial revision (published)