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

Thiago Macieira thiago.macieira at intel.com
Fri Jun 7 15:41:23 CEST 2024


On Friday 7 June 2024 01:53:55 GMT-7 Ivan Solovev via Development wrote:
> Note that currently the standard does not allow to mix char and wide char
> strings, so something like this will not work:
> 
>  std::wstring wstr = ~~~;
>  std::format("{}", wstr); // ERROR!
> 
> That would mean the following:
> * std::formatter<QString(View), wchar_t>, which will simply call
>  QString::toStdWString() and format the resulting std::wstring.

In addition to what Peppe and Eddy said, I recommend we completely ignore 
wchar_t. It's not useful to us because it's only useful in one platform.

It might be that SG16 hasn't tackled formatting onto char16_t and char32_t and 
formatting of std::u16string and std::u32string and similar *because* they 
have yet to come up with functions to do transcoding. But we won't know unless 
we ask.

Or we'll find out that "it's what fmtlib did, so no one has looked into that".

We have and we need it. We also would like to have the ability to allocate 
buffer in the output, write to it, and only then let the output know how much 
we've written. I could not find a way to do that with std::formatter.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Principal Engineer - Intel DCAI Fleet Engineering and Quality
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5152 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/development/attachments/20240607/08351fc4/attachment-0001.bin>


More information about the Development mailing list