OGS
FlushStdoutGuard.h
Go to the documentation of this file.
1
11#pragma once
12
13namespace
14{
19{
20public:
22 explicit FlushStdoutGuard(bool const flush) : _flush(flush)
23 {
24 if (!flush)
25 {
26 return;
27 }
28
29 std::cout << std::flush;
30 }
31
34 {
35 if (!_flush)
36 {
37 return;
38 }
39
40 using namespace pybind11::literals;
41 pybind11::print("end"_a = "", "flush"_a = true);
42 }
43
44private:
46 const bool _flush;
47};
48} // anonymous namespace
~FlushStdoutGuard()
Optionally flushes Python's stdout after running Python code.
FlushStdoutGuard(bool const flush)
Optionally flushes C++ stdout before running Python code.