Files
2025-10-25 03:02:53 +03:00

3.2 KiB

[diff.cpp20.utilities]

Annex C (informative) Compatibility [diff]

C.2 C++ and ISO C++ 2020 [diff.cpp20]

C.2.10 [utilities]: general utilities library [diff.cpp20.utilities]

1

#

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"); // ill-formed,// previously threw format_error — end example]

2

#

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); // ill-formed, previously returned "0" — end example]

3

#

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 asarg-id becomes invalid.

[Example 3: std::format("{:^{}}", "", true); // ill-formed, previously returned "" std::format("{:^{}}", "", '1'); // ill-formed, previously returned an// implementation-defined number of '' characters — end example]

4

#

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.