C++ Logo


Advanced search

Re: [std-proposals] New printf/scanf modifiers

From: Bjorn Reese <breese_at_[hidden]>
Date: Thu, 2 Feb 2023 19:13:21 +0100
On 1/31/23 20:26, Jason McKesson via Std-Proposals wrote:

> That's just a library. Anybody can build a library and name their
> functions whatever they want.

That is how many types in the C++ standard library starts.

> If you want to call it "std::printf" (which is what this proposal is
> talking about: changes to the function `std::printf`), then it must
> first become part of C because that's where "std::printf" comes from.

The referenced printx library is a type-safe front-end for printf that
generates the printf formatting string based on the argument types. That
means you no longer have to specify the size modifiers explicity.

> We already have a type-safe replacement for `printf`; I see no reason
> to try to change printf when we could give those capabilities to our
> replacement.

Adding type-safety without having to change formatting syntax (assuming
you are thinking of std::format) requires less work to make existing
code more type-safe.

The printf formatting is not disappearing any day soon, so we might as
well provide a type-safe mechanism.

Received on 2023-02-02 18:13:24