af8f9a2a6e
The idea is to store a concatenable in a QStringBuilder object by value or by reference, depending on how it was originally passed into the concatenation operator. So if it was passed by r-value, we treat it as a temporary object and hold it by value (and use move-semantic if available), otherwise we hold it by reference (as before). To achieve this we first change concatenation operators '%' and '+' to take their arguments by universal reference. Next we instantiate QStringBuilder object with deduced types of the arguments, which will be a "value type" or a "reference type" according to "universal reference deduction rules". Further we use perfect forwarding to pass arguments to QStringBuilder's constructor. Thus arguments, initially passed by r-value reference and which are move-constructible, will be "moved" to corresponding QStringBuilder member variables. So, to summarize: 1. Arguments passed by l-value reference - stored in QStringBuilder object by reference (as before). 2. Temporary objects passed by r-value reference - stored in QStringBuilder object by value. If a type is move-constructible (QSting, QByteArray, etc), the object will be "moved" accordingly. Special thanks to Giuseppe D'Angelo for the tests. Fixes: QTBUG-99291 Fixes: QTBUG-87603 Fixes: QTBUG-47066 Task-number: QTBUG-74873 Task-number: QTBUG-103090 Task-number: QTBUG-104354 Change-Id: I64f417be0de0815ec5ae7e35a1cc6cef6d887933 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Vladimir Belyavsky <belyavskyv@gmail.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Marc Mutz <marc.mutz@qt.io> |
||
---|---|---|
.. | ||
qanystringview | ||
qbytearray | ||
qbytearray_large | ||
qbytearrayapisymmetry | ||
qbytearraylist | ||
qbytearraymatcher | ||
qbytearrayview | ||
qbytedatabuffer | ||
qchar | ||
qcollator | ||
qlatin1stringmatcher | ||
qlatin1stringview | ||
qlocale | ||
qregularexpression | ||
qstring | ||
qstring_no_cast_from_bytearray | ||
qstringapisymmetry | ||
qstringbuilder | ||
qstringconverter | ||
qstringiterator | ||
qstringlist | ||
qstringmatcher | ||
qstringtokenizer | ||
qstringview | ||
qtextboundaryfinder | ||
qunicodetools | ||
shared | ||
CMakeLists.txt |