[Development] User-defined literals for QString (and QByteArray)

Giuseppe D'Angelo giuseppe.dangelo at kdab.com
Tue Mar 9 13:03:55 CET 2021


Il 09/03/21 07:42, André Pönitz ha scritto:
> What if there weren't overloads of the actual functions on QString and
> QStringView?
> 
> https://wandbox.org/permlink/rdIhbPRdGHuWWxFW

I'm not sure what QStringArg is supposed to be: a view? A container? A 
type-erased view-or-container?

Anyways, this is the situation where you only have the "right" 
signatures available. The problem of the current situation is that we 
have "wrong" signatures around. That is, we have signatures like

   f(QString);

even for those functions that merely read the string data, so they 
_could_ use a view; they've just been written like that before we had 
QStringView, and have not been ported yet. If we didn't care about 
breaking BC (and marginally about breaking SC) in such a case, we could 
just *change* the signature to

   f(QStringView); // or f(QAnyStringView), f(QStringArg), ...

and just achieve the same goal. Instead, we're forced to *add* the 
overload, therefore causing the possible ambiguities. I don't see how 
adding QStringArg to the mix would change things here, unless you're 
aiming at a Qt 7 scenario...?

Thanks,
-- 
Giuseppe D'Angelo | giuseppe.dangelo at kdab.com | Senior Software Engineer
KDAB (France) S.A.S., a KDAB Group company
Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com
KDAB - The Qt, C++ and OpenGL Experts

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4329 bytes
Desc: Firma crittografica S/MIME
URL: <http://lists.qt-project.org/pipermail/development/attachments/20210309/9d24a3d4/attachment.bin>


More information about the Development mailing list