Il 05/03/21 13:51, Andrei Golubev ha scritto:
That said, QByteArray's ctor accepting char* is not explicit (which kind of makes sense) and we have this ambiguity for f(QByteArray) and f(QByteArrayView) I believe. But guessing that it's not expected that QByteArrayView would be as popular as QStringView.

Sure, but this results in functions overloaded for QByteArray and const char *, not QByteArray and QByteArrayView -- see QByteArray's operators, qCompress, etc.

Thus, QByteArray str = "hello" works fine, so maybe no need to introduce a UDL for that class. OTOH, QString and QByteArray would have API differences (in some sense) yet again (and there's QByteArrayLiteral).

But the UDL you proposed is for the non-allocating path, so

QByteArray b = "hello"_qba;

is different from

QByteArray b = "hello";


Cheers,
--
Giuseppe D'Angelo | giuseppe.dang...@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

Attachment: smime.p7s
Description: Firma crittografica S/MIME

_______________________________________________
Development mailing list
Development@qt-project.org
https://lists.qt-project.org/listinfo/development

Reply via email to