std::basic_ostream<CharT,Traits>::sentry (3) - Linux Man Pages
An object of class basic_ostream::sentry is constructed in local scope at the beginning of each member function of std::basic_ostream that performs output (both formatted and unformatted). Its constructor prepares the output stream: checks if the stream is already in a failed state, flushes the tie()'d output streams, and performs other implementation-defined tasks if necessary. Implementation-defined cleanup, as well as flushing of the output stream if necessary, is performed in the destructor, so that it is guaranteed to happen if exceptions are thrown during output.
constructor (public member function)
destructor (public member function)
operator= (public member function)
operator bool (public member function)
explicit sentry( std::basic_ostream<CharT,Traits>& os );
Prepares the stream for formatted output.
If os.good() is false, returns. Otherwise, if os.tie() is not a null pointer, calls os.tie()->flush() to synchronize the output sequence with external streams. During preparation, the constructor may call setstate(failbit) (which may throw std::ios_base::failure).
If after preparation is completed, is.good() == true, then any subsequent calls to operator bool will return true.
os - output stream to prepare
std::ios_base::failure if the end of file condition occurs.
If (os.flags() & std::ios_base::unitbuf) && !std::uncaught_exception() && os.good()) is true, calls os.rdbuf()->pubsync(). If that function returns -1, sets badbit in os.rdstate() without propagating an exception.
explicit operator bool() const;
Checks whether the preparation of the output stream was successful.
true if the preparation of the output stream was successful, false otherwise.
// Run this code