C++ Logo

std-proposals

Advanced search

Re: +AFs-std-proposals+AF0 Newlines in F-strings

From: Hadriel Kaplan <hkaplan_at_[hidden]>
Date: Wed, 25 Oct 2023 01:17:26 +0000
Juniper Public
+AD4- From: Std-Proposals +ADw-std-proposals-bounces+AEA-lists.isocpp.org +ADw-mailto:std-proposals-bounces+AEA-lists.isocpp.org+AD4APg- on behalf of Chris Gary via Std-Proposals +ADw-std-proposals+AEA-lists.isocpp.org +ADw-mailto:std-proposals+AEA-lists.isocpp.org+AD4APg-
+AD4- Date: Tuesday, October 24, 2023 at 7:53 PM

+AD4- Also, expanding directly to std::format would limit this to cases where only the appropriate std::string variant can be used. While it may seem inconvenient, being able to do something like this:

I was only showing examples using F+ACIAIg-, and std::format, because I think it's easier to see how they expand/interpolate, since there are parentheses and such.


For purely string-interpolation, one would use X+ACIAIg-, which extracts the expressions into their separate arguments.

So you could use it like this:

std::print(X+ACI-Values of +AHs-gamma+AH0- may give rise to +AHs-condition+AH0AIg-)+ADs-

FormatQString(X+ACI-Values of +AHs-gamma+AH0- may give rise to +AHs-condition+AH0AIg-)+ADs-


Which would become these:

std::print(+ACI-Values of +AHsAfQ- may give rise to +AHsAfQAi-, gamma, condition)+ADs-

FormatQString(+ACI-Values of +AHsAfQ- may give rise to +AHsAfQAi-, gamma, condition)+ADs-


-hadriel

Received on 2023-10-25 01:17:30