Files
cppdraft_translate/cppdraft/ostream/unformatted.md
2025-10-25 03:02:53 +03:00

4.4 KiB
Raw Permalink Blame History

[ostream.unformatted]

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]

1

#

Each unformatted output function begins execution by constructing an object of classsentry.

If that object returnstrue, while converting to a value of typebool, the function endeavors to generate the requested output.

If an exception is thrown during output, thenios_base::badbit is set288 in*this's error state.

If(exceptions() & badbit) != 0 then the exception is rethrown.

In any case, the unformatted output function ends by destroying thesentry object, then, if no exception was thrown, returning the value specified for the unformatted output function.

🔗

basic_ostream& put(char_type c);

2

#

Effects: Behaves as an unformatted output function (as described above).

After constructing a sentry object, inserts the character c, if possible.289

3

#

Otherwise, callssetstate(badbit) (which may throwios_base::failure ([iostate.flags])).

4

#

Returns: *this.

🔗

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

5

#

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 bys.290

Characters are inserted until either of the following occurs:

n characters are inserted;

inserting in the output sequence fails (in which case the function callssetstate(badbit), which may throwios_base::failure ([iostate.flags])).

6

#

Returns: *this.

🔗

basic_ostream& flush();

7

#

Effects: Behaves as an unformatted output function (as described above).

Ifrdbuf() is not a null pointer, constructs a sentry object.

If that object returns true when converted to a value of type bool the function callsrdbuf()->pubsync().

If that function returns −1 callssetstate(badbit) (which may throwios_base::failure ([iostate.flags])).

Otherwise, if the sentry object returns false, does nothing.

8

#

Returns: *this.

288)288)

This is done without causing anios_base::failure to be thrown.

289)289)

Note that this function is not overloaded on typessigned char andunsigned char.

290)290)

Note that this function is not overloaded on typessigned char andunsigned char.