NullOStream.h 451 B

1234567891011121314151617181920
  1. #pragma once
  2. #include <ostream>
  3. #include <streambuf>
  4. // from https://stackoverflow.com/a/8244052
  5. class NullStreambuf : public std::streambuf {
  6. char dummyBuffer[64];
  7. protected:
  8. virtual int overflow(int c) override final;
  9. };
  10. class NullOStream final : private NullStreambuf, public std::ostream {
  11. public:
  12. NullOStream() : std::ostream(this) {}
  13. NullStreambuf *rdbuf() { return this; }
  14. virtual void avoidOutOfLineVirtualCompilerWarning();
  15. };