[Development] std::format support for Qt string types

Ivan Solovev ivan.solovev at qt.io
Thu Jun 13 14:05:18 CEST 2024


So, I dropped a message to the SG16 mailing list, and I got a link to a new
paper as an answer: https://wg21.link/P3258

As I read it, the key point for us is that the formatter output should use
the literal encoding of the format string, or fall back to the execution
encoding.

AFAIK, we in Qt already assume that the literal and execution encoding is
UTF-8. That's the case for Linux and macOS, and for MSVC we explicitly pass
the /utf8 flag to enable the same behavior.

As a result, UTF-8 seems to be the right choice for the char formatters.

Best regards,
Ivan

------------------------------

Ivan Solovev
Senior Software Engineer

The Qt Company GmbH
Erich-Thilo-Str. 10
12489 Berlin, Germany
ivan.solovev at qt.io
www.qt.io

Geschäftsführer: Mika Pälsi,
Juha Varelius, Jouni Lintunen
Sitz der Gesellschaft: Berlin,
Registergericht: Amtsgericht
Charlottenburg, HRB 144331 B

________________________________________
From: Development <development-bounces at qt-project.org> on behalf of Thiago Macieira <thiago.macieira at intel.com>
Sent: Friday, June 7, 2024 6:25 PM
To: development at qt-project.org
Subject: Re: [Development] std::format support for Qt string types

On Friday 7 June 2024 08:40:33 GMT-7 Ivan Solovev via Development wrote:
> IIUC, the problem of extra allocations is covered by the transcoding
> iterators and views in the paper that was linked by Giuseppe.

Yes and no.

That appears to transfer the responsibility of transcoding to the formatter,
which may be acceptable for std::format() on std::string or for std::print(),
because for those, performance and code bloat are entirely unimportant.

The question I want to see addressed is performance when we begin using format
to replace QString::arg() and thus tr(). We have highly-specialised conversion
code because this is critical to us and I'd like to see it used. So how do we
ensure that in those contexts we use our code, which is not and cannot be
inline?

How do we format onto a QString?

--
Thiago Macieira - thiago.macieira (AT) intel.com
  Principal Engineer - Intel DCAI Fleet Engineering and Quality


More information about the Development mailing list