Date: Mon, 16 Oct 2023 03:59:20 +0000
> From: Barry Revzin <barry.revzin_at_[hidden]>
> That's kind of the point - I would really want to use these functions without having to have a resolved string already. If f-strings were broadly usable, then I could use them to implement the formatter for Point like this:
> return format_to(ctx.out(), f"Point{{.x={point.x}, .y={point.y}}}");
Does the new rev-1 draft (https://tinyurl.com/y7av5tbw) resolve your concern, for that issue?
It offers a `X"..."` x-string for extraction and unpacking into separate discrete parts. And then the `F"..."` f-string just become a convenience for `std::format(X"...")`.
So you can do this:
return format_to(ctx.out(), X"Point{{.x={point.x}, .y={point.y}}}");
And it would become:
return format_to(ctx.out(), "Point{{.x={}, .y={}}}", point.x, point.y);
-hadriel
Juniper Public
> That's kind of the point - I would really want to use these functions without having to have a resolved string already. If f-strings were broadly usable, then I could use them to implement the formatter for Point like this:
> return format_to(ctx.out(), f"Point{{.x={point.x}, .y={point.y}}}");
Does the new rev-1 draft (https://tinyurl.com/y7av5tbw) resolve your concern, for that issue?
It offers a `X"..."` x-string for extraction and unpacking into separate discrete parts. And then the `F"..."` f-string just become a convenience for `std::format(X"...")`.
So you can do this:
return format_to(ctx.out(), X"Point{{.x={point.x}, .y={point.y}}}");
And it would become:
return format_to(ctx.out(), "Point{{.x={}, .y={}}}", point.x, point.y);
-hadriel
Juniper Public
Received on 2023-10-16 03:59:28