AtMostOnce< T > Class Template Reference

#include <IoManip.h>

Collaboration diagram for AtMostOnce< T >:

Public Member Functions

 AtMostOnce (const T &t)
 caller must ensure t lifetime extends to the last use of this AtMostOnce instance More...
 
void print (std::ostream &os)
 

Private Attributes

const T & toPrint
 
bool printed = false
 

Detailed Description

template<class T>
class AtMostOnce< T >

Helps print T object at most once per AtMostOnce<T> object lifetime. T objects are printed to std::ostream using operator "<<".

auto headerOnce = AtMostOnce("Transaction Details:\n");
if (detailOne)
os << headerOnce << *detailOne;
if (const auto detailTwo = findAnotherDetail())
os << headerOnce << *detailTwo;

Definition at line 259 of file IoManip.h.

Constructor & Destructor Documentation

◆ AtMostOnce()

template<class T >
AtMostOnce< T >::AtMostOnce ( const T &  t)
inlineexplicit

Definition at line 263 of file IoManip.h.

Member Function Documentation

◆ print()

template<class T >
void AtMostOnce< T >::print ( std::ostream &  os)
inline

Definition at line 265 of file IoManip.h.

References AtMostOnce< T >::printed, and AtMostOnce< T >::toPrint.

Referenced by operator<<().

Member Data Documentation

◆ printed

template<class T >
bool AtMostOnce< T >::printed = false
private

Definition at line 274 of file IoManip.h.

Referenced by AtMostOnce< T >::print().

◆ toPrint

template<class T >
const T& AtMostOnce< T >::toPrint
private

Definition at line 273 of file IoManip.h.

Referenced by AtMostOnce< T >::print().


The documentation for this class was generated from the following file:
AtMostOnce(const T &t)
caller must ensure t lifetime extends to the last use of this AtMostOnce instance
Definition: IoManip.h:263

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors