Standard format specification (since C++20)

For basic types and string types, the format specification is based on the format specification in Python.

# Notes

In most of the cases the syntax is similar to the old %-formatting, with the addition of the {} and with : used instead of %. For example, “%03.2f” can be translated to “{:03.2f}”.

# Defect reports

DRApplied toBehavior as publishedCorrect behavior
LWG 3721C++20zero is not allowed for the width fieldin standard format specificationzero is permitted if specifiedvia a replacement field
P2909R4C++20char or wchar_t might be formatted asout-of-range unsigned integer valuescode units are converted to the correspondingunsigned type before such formatting