CKTIS / C++
std::print — formatted output
std::print from <print> writes formatted data to stdout or a specified FILE* stream. It uses replacement fields such as {} and does not automatically append a newline.
Version: C++23; repository compiler flag, production runtime not attested
Syntax
#include <print>
std::print(fmt, args...);
std::print(stream, fmt, args...);std::print is a C++23 standard-library function provided by <print>. Calling std::print(fmt, args...) writes to stdout; the std::print(stream, fmt, args...) overload accepts a valid FILE* pointer to an output C stream. The function returns void, not the resulting text.
The {} fields in the format are replaced by successive arguments. For a format literal, validity of the format against the argument types is checked at compile time. This is not printf syntax: use brace-delimited fields rather than specifiers such as %d.
std::print does not add a newline: include \n in the format, as in the example. In contrast, std::println appends a newline. A write failure can throw std::system_error; formatting and allocation exceptions are also possible.
Both compiler and standard-library support for <print> are required. A repository C++23 compiler flag alone does not attest operation in the production runtime. The supplied sources are a developing standard draft and may contain additions beyond C++23; this entry stays within the C++23 interface.
Examples
#include <print>
int main() {
const int count = 3;
std::print("Items: {}; total: {}\n", count, count * 7);
}
Result
Items: 3; total: 21
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.