diff options
Diffstat (limited to 'debug.h')
-rw-r--r-- | debug.h | 40 |
1 files changed, 40 insertions, 0 deletions
@@ -0,0 +1,40 @@ +#pragma once + +#include <iostream> +#include <ostream> + +class debug_ostream +{ +public: + debug_ostream(): m_active(false) {} + + void activate() + { + m_active = true; + } + + void deactivate() + { + m_active = false; + } + + template<typename T> + debug_ostream& operator<<(const T& arg) { + if (m_active) + std::cout << arg; + return *this; + } + + debug_ostream& operator<<( + std::basic_ostream<char>& (*func) + (std::basic_ostream<char>&) ) { + if (m_active) + std::cout << *func; + return *this; + } + +private: + bool m_active; +}; + +extern debug_ostream debug_cout; |