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

2.5 KiB
Raw Blame History

[ostream.formatted.reqmts]

31 Input/output library [input.output]

31.7 Formatting and manipulators [iostream.format]

31.7.6 Output streams [output.streams]

31.7.6.3 Formatted output functions [ostream.formatted]

31.7.6.3.1 Common requirements [ostream.formatted.reqmts]

1

#

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

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

If the generation fails, then the formatted output function doessetstate(ios_base::failbit), which can throw an exception.

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

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

Whether or not an exception is thrown, thesentry object is destroyed before leaving the formatted output function.

If no exception is thrown, the result of the formatted output function is*this.

2

#

The descriptions of the individual formatted output functions describe how they perform output and do not mention thesentry object.

3

#

If a formatted output function of a stream os determines padding, it does so as follows.

Given a charT character sequence seq wherecharT is the character container type of the stream, if the length of seq is less than os.width(), then enough copies ofos.fill() are added to this sequence as necessary to pad to a width of os.width() characters.

If(os.flags() & ios_base::adjustfield) == ios_base::left istrue, the fill characters are placed after the character sequence; otherwise, they are placed before the character sequence.

285)285)

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