e540d4a864
QRegularExpression::match (and globalMatch) is currently overloaded for QString and QStringView. This creates a subtle API asymmetry: QRegularExpression re; auto m1 = re.match(getQString()); // OK auto m2 = re.match(getStdU16String()); // Dangling This goes against our decision that every time that there's a possible lifetime issue at play, it should be "evident". Solving the lifetime issue here is possible, but tricky -- since QRegularExpression is out-of-line, one needs a type-erased container for the input string (basically, std::any) to keep it alive and so on. Instead I went for the simpler solution: deprecate match(QStringView) and introduce matchView(QStringView) (same for globalMatch). This makes it clear that the call is matching over a view and therefore users are supposed to keep the source object alive. Drive-by, remove the documentation that says that the QString overloads might not keep the string alive: they do and forever will. [ChangeLog][QtCore][QRegularExpression] Added the matchView() and globalMatchView() functions that operate on string views. The match(QStringView) and globalMatch(QStringView) overloads have been deprecated. Change-Id: I054b8605c2fdea59b556dcfea8920ef4eee78ee9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> |
||
---|---|---|
.. | ||
qanystringview | ||
qbytearray | ||
qbytearrayapisymmetry | ||
qbytearraylist | ||
qbytearraymatcher | ||
qbytearrayview | ||
qbytedatabuffer | ||
qchar | ||
qcollator | ||
qlatin1stringview | ||
qlocale | ||
qregularexpression | ||
qstring | ||
qstring_no_cast_from_bytearray | ||
qstringapisymmetry | ||
qstringbuilder | ||
qstringconverter | ||
qstringiterator | ||
qstringlist | ||
qstringmatcher | ||
qstringtokenizer | ||
qstringview | ||
qtextboundaryfinder | ||
qunicodetools | ||
shared | ||
CMakeLists.txt |