std::println
Defined in header <print>
template< class... Args >
void println( std::format_string<Args...> fmt, Args&&... args );template< class... Args >
void println( std::format_string<Args...> fmt, Args&&... args ); since C++23
template< class... Args >
void println( std::FILE* stream,
std::format_string<Args...> fmt, Args&&... args );template< class... Args >
void println( std::FILE* stream,
std::format_string<Args...> fmt, Args&&... args ); since C++23
void println();void println(); since C++26
void println( std::FILE* stream );void println( std::FILE* stream ); since C++26
Format args according to the format string fmt with appended \n (which means that each output ends with a new-line), and print the result to a stream.
-
Equivalent to
std::println(stdout, fmt, std::forward<Args>(args)...) -
Equivalent to performing the following operations:
-
std::print(stream, "{}\n", std::format(fmt, std::forward<Args>(args)...));(until C++26) -
std::print(stream, std::runtime_format(std::string(fmt.get()) + '\n'), std::forward<Args>(args)...)(since C++26)
-
-
Equivalent to
std::println(stdout). -
Equivalent to
std::print(stream, "\n").
If std::formatter<Ti, char> does not meet the BasicFormatter requirements for any Ti in Args (as required by std::make_format_args), the behavior is undefined.
Parameters
Section titled “Parameters”stream
Section titled “stream”output file stream to write to
- an object that represents the format string. The format string consists of
- ordinary characters (except
{and}), which are copied unchanged to the output, - escape sequences
{{and}}, which are replaced with{and}respectively in the output, and - replacement fields.
Each replacement field has the following format:
|{ arg-id arg-id format-spec } |(2)|
- replacement field without a format specification
- replacement field with a format specification
arg-id- specifies the index of the argument inargswhose value is to be used for formatting; if it is omitted, the arguments are used in order.