30 Input/output library [input.output]

30.7 Formatting and manipulators [iostream.format]

30.7.5 Output streams [output.streams]

30.7.5.3 Unformatted output functions [ostream.unformatted]

Each unformatted output function begins execution by constructing an object of class sentry. If this object returns true, while converting to a value of type bool, the function endeavors to generate the requested output. If an exception is thrown during output, then ios​::​badbit is turned on323 in *this's error state. If (exceptions() & badbit) != 0 then the exception is rethrown. In any case, the unformatted output function ends by destroying the sentry object, then, if no exception was thrown, returning the value specified for the unformatted output function.

basic_ostream<charT, traits>& put(char_type c);

Effects: Behaves as an unformatted output function (as described above). After constructing a sentry object, inserts the character c, if possible.324

Otherwise, calls setstate(badbit) (which may throw ios_­base​::​failure ([iostate.flags])).

Returns: *this.

basic_ostream& write(const char_type* s, streamsize n);

Effects: Behaves as an unformatted output function (as described above). After constructing a sentry object, obtains characters to insert from successive locations of an array whose first element is designated by s.325 Characters are inserted until either of the following occurs:

  • n characters are inserted;

  • inserting in the output sequence fails (in which case the function calls setstate(badbit), which may throw ios_­base​::​failure ([iostate.flags])).

Returns: *this.

basic_ostream& flush();

Effects: Behaves as an unformatted output function (as described above). If rdbuf() is not a null pointer, constructs a sentry object. If this object returns true when converted to a value of type bool the function calls rdbuf()->pubsync(). If that function returns -1 calls setstate(badbit) (which may throw ios_­base​::​failure ([iostate.flags])). Otherwise, if the sentry object returns false, does nothing.

Returns: *this.

without causing an ios​::​failure to be thrown.

Note that this function is not overloaded on types signed char and unsigned char.

Note that this function is not overloaded on types signed char and unsigned char.