KASSERT  0.0.1
Karlsruhe Assertion Library
kassert::Logger< StreamT > Class Template Reference

Simple wrapper for output streams that is used to stringify values in assertions and exceptions. More...

#include <logger.hpp>

Public Member Functions

 Logger (StreamT &&out)
 Construct the object with an underlying streaming object. More...
 
template<typename ValueT , std::enable_if_t< internal::is_streamable_type< std::ostream, ValueT >, int > = 0>
Logger< StreamT > & operator<< (ValueT &&value)
 Forward all values for which StreamT::operator<< is defined to the underlying streaming object. More...
 
StreamT && stream ()
 Get the underlying streaming object. Flushes all buffered logs to the underlying stream before returning a reference to the stream. More...
 
void flush ()
 Flushes all buffered logs to the underlying stream.
 
 ~Logger ()
 Destructor of the logger stream, which flushes all buffered logs to the underlying stream upon destruction.
 

Detailed Description

template<typename StreamT>
class kassert::Logger< StreamT >

Simple wrapper for output streams that is used to stringify values in assertions and exceptions.

To enable stringification for custom types, overload the << operator of this class. The library overloads this operator for the following STL types:

  • std::vector<T>
  • std::pair<K, V>
Template Parameters
StreamTThe underlying streaming object (e.g., std::ostream or std::ostringstream).

Constructor & Destructor Documentation

◆ Logger()

template<typename StreamT >
kassert::Logger< StreamT >::Logger ( StreamT &&  out)
inlineexplicit

Construct the object with an underlying streaming object.

Parameters
outThe underlying streaming object.

Member Function Documentation

◆ operator<<()

template<typename StreamT >
template<typename ValueT , std::enable_if_t< internal::is_streamable_type< std::ostream, ValueT >, int > = 0>
Logger< StreamT > & kassert::Logger< StreamT >::operator<< ( ValueT &&  value)
inline

Forward all values for which StreamT::operator<< is defined to the underlying streaming object.

Parameters
valueValue to be stringified.
Template Parameters
ValueTType of the value to be stringified.

◆ stream()

template<typename StreamT >
StreamT && kassert::Logger< StreamT >::stream ( )
inline

Get the underlying streaming object. Flushes all buffered logs to the underlying stream before returning a reference to the stream.

Returns
The underlying streaming object.

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