summaryrefslogtreecommitdiffhomepage
path: root/debug.h
blob: 335cd6ec8749141adafdc13369dfa68878fe1f18 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#pragma once

#include <iostream>
#include <ostream>

class debug_ostream
{
public:
  debug_ostream();

  void activate();

  void deactivate();

  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>&) );

private:
  bool m_active;
};

extern debug_ostream debug_cout;