ALPSCore reference
Public Member Functions | List of all members
alps::alea::internal::format_sentry Class Reference

#include <format.hpp>

Collaboration diagram for alps::alea::internal::format_sentry:
Collaboration graph

Public Member Functions

 format_sentry (std::ostream &str)
 
 ~format_sentry ()
 
std::ios::fmtflags saved_flags () const
 
std::ostream & stream ()
 
const std::ostream & stream () const
 

Detailed Description

Undoes all formatting flag changes on stream when it goes out of scope.

Allows RAII-type use of a stream inside of a function while making sure that no format changes are visible outside of it:

void dump(std::ostream &out) {
    alps::alea::internal::format_sentry sentry(out);
    // flag changes here
    // ...
} // restores flags on exit

Definition at line 32 of file format.hpp.

Constructor & Destructor Documentation

alps::alea::internal::format_sentry::format_sentry ( std::ostream &  str)
inlineexplicit

Definition at line 35 of file format.hpp.

alps::alea::internal::format_sentry::~format_sentry ( )
inline

Definition at line 43 of file format.hpp.

Member Function Documentation

std::ios::fmtflags alps::alea::internal::format_sentry::saved_flags ( ) const
inline

Definition at line 49 of file format.hpp.

std::ostream& alps::alea::internal::format_sentry::stream ( )
inline

Definition at line 51 of file format.hpp.

const std::ostream& alps::alea::internal::format_sentry::stream ( ) const
inline

Definition at line 53 of file format.hpp.


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