31 Input/output library [input.output]

31.7 Formatting and manipulators [iostream.format]

31.7.10 Print functions [print.fun]

template<class... Args> void print(format_string<Args...> fmt, Args&&... args);
Effects: Equivalent to: print(stdout, fmt, std::forward<Args>(args)...);
template<class... Args> void print(FILE* stream, format_string<Args...> fmt, Args&&... args);
Effects: If the ordinary literal encoding ([lex.charset]) is UTF-8, equivalent to: vprint_unicode(stream, fmt.str, make_format_args(std::forward<Args>(args)...));
Otherwise, equivalent to: vprint_nonunicode(stream, fmt.str, make_format_args(std::forward<Args>(args)...));
template<class... Args> void println(format_string<Args...> fmt, Args&&... args);
Effects: Equivalent to: println(stdout, fmt, std::forward<Args>(args)...);
template<class... Args> void println(FILE* stream, format_string<Args...> fmt, Args&&... args);
Effects: Equivalent to: print(stream, "{}\n", format(fmt, std::forward<Args>(args)...));
void vprint_unicode(string_view fmt, format_args args);
Effects: Equivalent to: vprint_unicode(stdout, fmt, args);
void vprint_unicode(FILE* stream, string_view fmt, format_args args);
Preconditions: stream is a valid pointer to an output C stream.
Effects: The function initializes an automatic variable via string out = vformat(fmt, args);
If stream refers to a terminal capable of displaying Unicode, writes out to the terminal using the native Unicode API; if out contains invalid code units, the behavior is undefined and implementations are encouraged to diagnose it.
Otherwise writes out to stream unchanged.
If the native Unicode API is used, the function flushes stream before writing out.
[Note 1: 
On POSIX and Windows, stream referring to a terminal means that, respectively, isatty(fileno(
stream))
and GetConsoleMode(_get_osfhandle(_fileno(stream)), ...) return nonzero.
— end note]
[Note 2: 
On Windows, the native Unicode API is WriteConsoleW.
— end note]
Throws: Any exception thrown by the call to vformat ([format.err.report]).
system_error if writing to the terminal or stream fails.
May throw bad_alloc.
Recommended practice: 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.
void vprint_nonunicode(string_view fmt, format_args args);
Effects: Equivalent to: vprint_nonunicode(stdout, fmt, args);
void vprint_nonunicode(FILE* stream, string_view fmt, format_args args);
Preconditions: stream is a valid pointer to an output C stream.
Effects: Writes the result of vformat(fmt, args) to stream.
Throws: Any exception thrown by the call to vformat ([format.err.report]).
system_error if writing to stream fails.
May throw bad_alloc.