The text formatting library offers a safe and extensible alternative to the printf family of functions. It is intended to complement the existing C++ I/O streams library.
[edit] Format specificationsFormat specification specifies how objects are formatted with different kinds of options.
The formatting of objects of basic types and standard string types uses the basic format specification. Other library components may also provide their own format specifications, see here for details.
[edit] Formatting functions stores formatted representation of the arguments in a new stringparse
and format
We intentionally treat the addition of std::basic_format_string
(P2508) as a defect report because all known implementations make these components available in C++20 mode, although it is not so categorized officially.
#include <cassert> #include <format> int main() { std::string message = std::format("The answer is {}.", 42); assert(message == "The answer is 42."); }[edit] Defect reports
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
DR Applied to Behavior as published Correct behavior P2418R2 C++20 objects that are neither const-formattable nor copyablebasic_format_string
is exposed [edit] See also prints to stdout or a file stream using formatted representation of the arguments
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4