[diff.cpp20.utilities] (original) (raw)
Annex C (informative) Compatibility [diff]
C.2 C++ and ISO C++ 2020 [diff.cpp20]
C.2.10 [utilities]: general utilities library [diff.cpp20.utilities]
Affected subclause: [format]
Change: Signature changes: format, format_to, vformat_to,format_to_n, formatted_size.
Removal of format_args_t.
Rationale: Improve safety via compile-time format string checks, avoid unnecessary template instantiations.
Effect on original feature: Valid C++ 2020 code that contained errors in format strings or relied on previous format string signatures orformat_args_t may become ill-formed.
[Example 1: auto s = std::format("{:d}", "I am not a number"); — _end example_]
Affected subclause: [format]
Change: Signature changes: format, format_to, format_to_n,formatted_size.
Rationale: Enable formatting of views that do not support iteration when const-qualified and that are not copyable.
Effect on original feature: Valid C++ 2020 code that passes bit-fields to formatting functions may become ill-formed.
[Example 2: struct tiny { int bit: 1;};auto t = tiny(); std::format("{}", t.bit); — _end example_]
Affected subclause: [format.string.std]
Change: Restrict types of formatting arguments used as width or precision in a std-format-spec.
Rationale: Disallow types that do not have useful or portable semantics as a formatting width or precision.
Effect on original feature: Valid C++ 2020 code that passes a boolean or character type as_arg-id_ becomes invalid.
[Example 3: std::format("{:*^{}}", "", true); std::format("{:*^{}}", "", '1'); — _end example_]
Affected subclause: [format.formatter.spec]
Change: Removed the formatter specialization:template<size_t N> struct formatter<const charT[N], charT>;
Rationale: The specialization is inconsistent with the design of formatter, which is intended to be instantiated only with cv-unqualified object types.
Effect on original feature: Valid C++ 2020 code that instantiated the removed specialization can become ill-formed.