27 Input/output library [input.output]

27.7 Formatting and manipulators [iostream.format]

27.7.3 Output streams [output.streams]

27.7.3.7 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 on330 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 in [ostream.unformatted], paragraph 1). After constructing a sentry object, inserts the character c, if possible.331

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 in [ostream.unformatted], paragraph 1). After constructing a sentry object, obtains characters to insert from successive locations of an array whose first element is designated by s.332 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 in [ostream.formatted.reqmts], paragraph 1). 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.