diff options
author | Roland Reichwein <mail@reichwein.it> | 2025-01-03 15:36:22 +0100 |
---|---|---|
committer | Roland Reichwein <mail@reichwein.it> | 2025-01-03 15:36:22 +0100 |
commit | 9de0b7f8937b7f6ce990132609f0b26851b31f2b (patch) | |
tree | a69f73358c9b75e5a11c9ed18d934964461360bf /debug.h | |
parent | 05895c86bddf50aacb3bb5e6a6bcc073965341ef (diff) |
Monitor CPU
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; |