TRIQS/TRIQS 4.0.0
Researching Interacting Quantum Systems
Loading...
Searching...
No Matches
triqs::utility::debug_stream

#include <triqs/utility/debug_stream.hpp>

Detailed Description

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).

Warning
This is unused. It might be removed in the future.

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_streamoperator<< (StandardEndLine manip)
 Overload of operator<<() that accepts manipulators like std::endl.
template<class T>
debug_streamoperator<< (T const &x)
 Write an object to the underlying ostream if the condition() holds and TRIQS_DEBUG is defined.

Constructor & Destructor Documentation

◆ debug_stream() [1/2]

triqs::utility::debug_stream::debug_stream ( std::ostream * out_,
std::function< bool()> condition )
inline

Construct a debug stream with a condition predicate.

Parameters
out_Pointer to the underlying output stream.
conditionPredicate that determines whether to emit output.

Definition at line 54 of file debug_stream.hpp.

◆ debug_stream() [2/2]

triqs::utility::debug_stream::debug_stream ( std::ostream * out_)
inline

Construct a debug stream without a condition.

Parameters
out_Pointer to the underlying output stream.

Definition at line 60 of file debug_stream.hpp.

Member Function Documentation

◆ operator<<() [1/2]

debug_stream & triqs::utility::debug_stream::operator<< ( StandardEndLine manip)
inline

Overload of operator<<() that accepts manipulators like std::endl.

Parameters
manipManipulator function.
Returns
Reference to *this.

Definition at line 88 of file debug_stream.hpp.

◆ operator<<() [2/2]

template<class T>
debug_stream & triqs::utility::debug_stream::operator<< ( T const & x)
inline

Write an object to the underlying ostream if the condition() holds and TRIQS_DEBUG is defined.

Template Parameters
TType of the object to write.
Parameters
xObject to write.
Returns
Reference to *this.

Definition at line 69 of file debug_stream.hpp.


The documentation for this class was generated from the following file: