C++ Logo


Advanced search

Re: [std-proposals] Proposal to add f-strings to C++ as an improvement of string formatting

From: Ville Voutilainen <ville.voutilainen_at_[hidden]>
Date: Sun, 1 Jan 2023 01:42:55 +0200
On Sun, 1 Jan 2023 at 01:14, Jason McKesson via Std-Proposals
<std-proposals_at_[hidden]> wrote:
> It seems to me that the much easier solution is to just give the
> interpolated string an interface that allows the code receiving it to
> process the interpolated string.

I think you hit various nails on the head here.. but..

>We also need to preserve the types of
> the values. So a `tuple`-like interface makes sense.

..I'm not sure this follows..

> The elements of the string that are literals should not be of any type
> a user can directly create.

..and this in particular puzzles me. *Why* shouold that element be of a a type
that the user can create?

In general, "should C++ be able to interpolate expression results into some sort
of a string", my generic answer would be "yeah, that would be
wonderful". I'm not sure
that is provided even by the new-fangled std::format and std::print.

Received on 2022-12-31 23:43:08