[ostream.formatted.print] (original) (raw)

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.5 Print [ostream.formatted.print]

template<class... Args> void print(ostream& os, format_string<Args...> fmt, Args&&... args);

Effects: If the ordinary literal encoding ([lex.charset]) is UTF-8, equivalent to:vprint_unicode(os, fmt.str, make_format_args(args...));

Otherwise, equivalent to:vprint_nonunicode(os, fmt.str, make_format_args(args...));

template<class... Args> void println(ostream& os, format_string<Args...> fmt, Args&&... args);

Effects: Equivalent to:print(os, "{}\n", format(os.getloc(), fmt, std::forward<Args>(args)...));

void println(ostream& os);

Effects: Equivalent to:print(os, "\n");

void vprint_unicode(ostream& os, string_view fmt, format_args args);void vprint_nonunicode(ostream& os, string_view fmt, format_args args);

Effects: Behaves as a formatted output function ([ostream.formatted.reqmts]) of os, except that:

After constructing a sentry object, the function initializes a variable with automatic storage duration viastring out = vformat(os.getloc(), fmt, args);

If writing to the terminal or inserting into os fails, calls os.setstate(ios_base​::​badbit)(which may throw ios_base​::​failure).

Recommended practice: For vprint_unicode, if invoking the native Unicode API requires transcoding, implementations should substitute invalid code units with U+fffd replacement character per the Unicode Standard, Chapter 3.9 U+fffd Substitution in Conversion.