[Development] User-defined literals for QString (and QByteArray)
Edward Welbourne
edward.welbourne at qt.io
Fri Mar 5 13:08:10 CET 2021
On 3 Mar 2021, at 16:53, Andrei Golubev <andrei.golubev at qt.io<mailto:andrei.golubev at qt.io>> wrote:
>> QString hello = u"Hello"; // oops, compilation error
Tor Arne Vestbø (5 March 2021 12:08) replied:
> 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?
Suggest a fix that works ? The problem is that, when a function has
overloads taking both QStringView and QString, calling the function with
u"..." as parameter would then have an ambiguous choice between two
signatures it can coerce that to. We could have purged the QString
version of all of those at Qt 6, to avoid this, but we'd still have the
problem of not being able to add QStringView overloads to other
functions still taking QString during the Qt 6 lifetime.
Eddy.
More information about the Development
mailing list