On 2019-08-22 21:09, Danila Malyutin wrote:
Can't it be alleviated/improved by providing user-defined literal for
QString(Literal)? So that one would only write a["b"_qs] = "c"_qs.
Yes.
++ways_to_construct<QString>;
:)
Fun aside, in C++20, this may actually alleviate some of the problems of
QStringLiteral: if we use UDLs instead of lambdas, at least we make
QStringLiteral data sharable with each other, because instead of a
lambda function (which has a different, new type each time you type it),
you'd instantiate a function template:
"foo"_qs -> operator ""_qs<"foo">();
And the linker would sort out duplicates.
But up to and incl. C++17, the only way to make "foo"_qs work is by
operator ""_qs(const char *, std::size_t), which is not a template, so
all it can do is call QString::fromUtf8(), which would be a step back
from what we have right now (since 5.7 or so, we guarantee that
QStringLiteral doesn't allocate).
@Ville: please correct me if I'm wrong in the above. And: what's the
reason I can't use the template <char...> version for string-literal
UDLs?
Thanks,
Marc
_______________________________________________
Development mailing list
Development@qt-project.org
https://lists.qt-project.org/listinfo/development