|
TRIQS/TRIQS 4.0.0
Researching Interacting Quantum Systems
|
#include <triqs/utility/debug_stream.hpp>
Output stream wrapper that emits only when a condition returns true and only in debug builds.
Behaves like a std::ostream but streaming is guarded both by #ifdef TRIQS_DEBUG and by a user predicate.
Useful for sparse, conditional logging in hot loops (e.g. printing only every 100 Monte Carlo configurations).
Definition at line 43 of file debug_stream.hpp.
Public Types | |
| using | CoutType = std::basic_ostream<char, std::char_traits<char>> |
| Output stream type. | |
| using | StandardEndLine = CoutType &(*)(CoutType &) |
| Type of standard manipulators like std::endl. | |
Public Member Functions | |
| debug_stream (std::ostream *out_) | |
| Construct a debug stream without a condition. | |
| debug_stream (std::ostream *out_, std::function< bool()> condition) | |
| Construct a debug stream with a condition predicate. | |
| debug_stream & | operator<< (StandardEndLine manip) |
| Overload of operator<<() that accepts manipulators like std::endl. | |
| template<class T> | |
| debug_stream & | operator<< (T const &x) |
| Write an object to the underlying ostream if the condition() holds and TRIQS_DEBUG is defined. | |
|
inline |
Construct a debug stream with a condition predicate.
| out_ | Pointer to the underlying output stream. |
| condition | Predicate that determines whether to emit output. |
Definition at line 54 of file debug_stream.hpp.
|
inline |
Construct a debug stream without a condition.
| out_ | Pointer to the underlying output stream. |
Definition at line 60 of file debug_stream.hpp.
|
inline |
Overload of operator<<() that accepts manipulators like std::endl.
| manip | Manipulator function. |
Definition at line 88 of file debug_stream.hpp.
|
inline |
Write an object to the underlying ostream if the condition() holds and TRIQS_DEBUG is defined.
| T | Type of the object to write. |
| x | Object to write. |
Definition at line 69 of file debug_stream.hpp.