C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Supporting f-strings in C++

From: Hadriel Kaplan <hkaplan_at_[hidden]>
Date: Sun, 15 Oct 2023 05:22:10 +0000
> From: Std-Proposals <std-proposals-bounces_at_[hidden].org> on behalf of Jason McKesson via Std-Proposals <std-proposals_at_lists.isocpp.org>

> This is a lot of complexity that seems to exist for the sole purpose
> of avoiding typing `std::format`. We already have grammatical
> constructs that must appear in specific places in expressions. We have
> grammatical constructs that "magically" expand into multiple
> expressions.

> Leveraging these mechanisms makes a lot more sense than creating a
> bunch of new types and such.

OK, then how about compromise-B: two prefixes...

Let X"" expand this:

    X"{prefix}_{name}: got {calculate()} for {bits:#06x}"

To this:

    "{}_{}: got {} for {:#06x}", prefix, name, calculate(), bits

And let F"" expand this:

    F"{prefix}_{name}: got {calculate()} for {bits:#06x}"

To this:

    std::format("{}_{}: got {} for {:#06x}", prefix, name, calculate(), bits)

And obviously we could specify F"" as just being `::std::format(X"")` internally.

-hadriel



Juniper Public

Received on 2023-10-15 05:22:16