January 2019
Intermediate to advanced
384 pages
11h 50m
English
We already discussed the usage of expression templates for the optimization of string construction. Qt provides an internal template class called QStringBuilder, which provides the expression template base optimization for concatenations of QString instances. This class isn't meant to be instantiated directly, but will be automatically invoked when its overloaded % operator is used, instead of the normal + concatenation operator, as in the following example:
QString s1("Hello ");QLatin1String s2("you'all ");QString msg = s1 % s2 % "how are you doing?";
By setting the global option QT_USE_STRING_BUILDER, the + concatenation operator will always be automatically replaced by the QStringBuilder template class's % overload, and ...
Read now
Unlock full access