std::basic_ostream::sentry

From cppreference.com
Defined in header <ostream>
template< class CharT, class Traits = std::char_traits<CharT> >
class std::basic_istream<charT,traits>::sentry

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.

[edit] Member functions

constructs the sentry object.
All the preparation tasks are done here
(public member function)
finalizes the stream object after formatted output or after exception, if necessary
(public member function)
operator=
the assignment operator is deleted
(public member function)
checks if the preparation of the stream object was successful
(public member function)

[edit] Example


[edit] See also

inserts formatted data
(public member function)