Debug streams

So far I’ve been handling console output using std::cout, as such:

This is all well and good, but I want certain things to only appear on the console in debug mode. For example, I may need to see pathfinding data while debugging a map, but the end-user won’t want to see all that. Using the Quake-style cvar system I’ve implemented I had started to add debug output like this:

This works, but it’s a lot of typing I wish I didn’t have to do. Ideally I’d be able to check for debug mode and print output on the same line. Which brings me to my results for the day:

Usage is exactly the same as std::cout:

…with the notable difference that it only runs if debug mode is on.

Anyone who wants to use this code is welcome to it under the license of your choice. I’d love to hear if you find it useful.