C++ Logo

sg16

Advanced search

Re: [isocpp-sg16] std::format and charN_t

From: Tiago Freire <tmiguelf_at_[hidden]>
Date: Mon, 1 Jul 2024 21:48:59 +0000

> There's a third alternative, which is what we use in Qt: we estimate the maximum possible size and request that. Once we've transcoded, we tell the container how much was actually used, which truncates the output to that size before continuing the formatting operation.

Did you mean "finishing the formatting operation"? Or did you mean proceed to the next parameter?


-----Original Message-----
From: SG16 <sg16-bounces_at_[hidden]> On Behalf Of Thiago Macieira via SG16
Sent: Monday, July 1, 2024 22:52
To: sg16_at_[hidden]
Cc: Thiago Macieira <thiago_at_macieira.org>
Subject: Re: [isocpp-sg16] std::format and charN_t

On Monday 1 July 2024 12:01:49 CEST Tiago Freire via SG16 wrote:
> Not sure that it would be possible to make it to C++26. You can try to
> pre-allocate, but the question is how much? For that it would require
> a 2-pass solution, the first pass figures out the required size, the
> allocation would happen in the middle, the second pass would fulfill
> the conversion keeping the promise of the first pass.

There's a third alternative, which is what we use in Qt: we estimate the maximum possible size and request that. Once we've transcoded, we tell the container how much was actually used, which truncates the output to that size before continuing the formatting operation.

--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Principal Engineer - Intel DCAI Platform & System Engineering



--
SG16 mailing list
SG16_at_[hidden]
https://lists.isocpp.org/mailman/listinfo.cgi/sg16

Received on 2024-07-01 21:49:04