On 5 Mar 2021, at 12:08, Tor Arne Vestbø 
<[email protected]<mailto:[email protected]>> wrote:


On 3 Mar 2021, at 16:53, Andrei Golubev 
<[email protected]<mailto:[email protected]>> wrote:

QString hello = u"Hello"; // oops, compilation error

This seems like a bug though? From an API point of view, I’d expect this simple 
assignment to JustWorkTM, without requiring syntactic sugar all over the place. 
Shouldn’t we fix this, so we don’t need (or leave optional) an explicit _qs 
suffix?

The explicit _qs suffix would basically replace QStringLiteral. We can’t have a 
generic QString(char16_t *) constructor that doesn’t copy the data.

I wish we had a good way of adding that overloaded constructor to QString. 
Unfortunately, we have lots of API that is overloaded on both QString and 
QStringView. Adding the constructor to QString will then cause ambiguities 
wherever we have overloaded API taking both a QString and a QStringView.

I wish there was a way to tell the compiler to prefer one conversion over the 
other ("if you have the choice, always use QStringView and not QString”), but 
C++ doesn’t have a way to do that.

Cheers,
Lars

_______________________________________________
Development mailing list
[email protected]
https://lists.qt-project.org/listinfo/development

Reply via email to