31 Input/output library [input.output]

31.7 Formatting and manipulators [iostream.format]

31.7.6 Output streams [output.streams]

31.7.6.4 Unformatted output functions [ostream.unformatted]

Each unformatted output function begins execution by constructing an object of class sentry.
If that 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_base​::​badbit is set294 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& 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.295
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.296
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 that object returns true when converted to a value of type bool the function calls rdbuf()->pubsync().
If that function returns calls setstate(badbit) (which may throw ios_base​::​failure ([iostate.flags])).
Otherwise, if the sentry object returns false, does nothing.
Returns: *this.
294)294)
This is done without causing an ios_base​::​failure to be thrown.
295)295)
Note that this function is not overloaded on types signed char and unsigned char.
296)296)
Note that this function is not overloaded on types signed char and unsigned char.