basic_ostream::sentry

class sentry {
public:
    explicit sentry(basic_ostream<E, T>& os);
    operator bool() const;
    };

The nested class describes an object whose declaration structures the formatted output functions and the unformatted output functions. The constructor effectively calls os.opfx() and stores the return value. operator bool() delivers this return value. The destructor effectively calls os.osfx(), but only if uncaught_exception() returns false.