Defined in header <ostream> | ||
---|---|---|
template< class... Args > void print( std::ostream& os, std::format_string<Args...> fmt, Args&&... args ); | (since C++23) |
Formats args
according to the format string fmt
, and inserts the result into os
stream.
If ordinary literal encoding of fmt
or any parameter in args...
is UTF-8 (where applicable), equivalent to:
std::vprint_unicode(os, fmt.get(), std::make_format_args(std::forward<Args>(args)...));
Otherwise, equivalent to:
std::vprint_nonunicode(os, fmt.get(), std::make_format_args(std::forward<Args>(args)...));
The behavior is undefined if std::formatter<Ti, char>
does not model std::formattable
for any Ti
in Args
(as required by std::make_format_args
).
os | - | output stream to insert data into | ||||||||||||
fmt | - | an object that represents the format string. The format string consists of
Each replacement field has the following format:
|
||||||||||||
args... | - | arguments to be formatted |
(none).
Feature-test macro | Value | Std |
---|---|---|
__cpp_lib_print | 202207L | (C++23) |
__cpp_lib_format | 202207L | (C++23) |
(C++23) | outputs formatted representation of the arguments with appended '\n' (function template) |
(C++23) | prints to stdout or a file stream using formatted representation of the arguments (function template) |
(C++20) | stores formatted representation of the arguments in a new string (function template) |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/w/cpp/io/basic_ostream/print