diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2017-01-07 21:58:01 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2019-07-24 17:31:25 +0200 |
commit | fd42589b14041d620c51fd7d23877c2749767fb3 (patch) | |
tree | 3e3c5342c73d418687ddd137108ba5f18e2b24d4 /src/corelib/text/qstringview.cpp | |
parent | ca5fc087bdc94fad14f8edce89cfe171858260dc (diff) |
Extend QString::arg(QString, ..., QString) to more than 9 arguments
Now that we have QStringView::arg(), we can use it to implement a
similarly flexible QString::arg(). It's not as straight-forward as in
QStringView, though: QString has existing arg() overloads that all
become worse matches with the introduction of the new,
perfectly-forwarding overload.
So in order to allow calling of the other arg() functions, first
constrain the new arg() function to arguments that are convertible to
QString, QStringView, or QLatin1String, and then delegate to the
QStringView version. To stay compatible with the previous overloads,
which accepted anything that implicitly converts to QString (in
particular, QStringBuilder expressions), add a new overload of
qStringLikeToView, taking const QString &. This benefits the existing
QStringView and QLatin1View versions, too.
[ChangeLog][QtCore][QString] QString::arg(QString, ..., QString) can
now be called with more than nine arguments, as well as with
QStringViews.
Change-Id: I1e717a1bc696346808bcae45dc47762a492c8714
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/corelib/text/qstringview.cpp')
-rw-r--r-- | src/corelib/text/qstringview.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/corelib/text/qstringview.cpp b/src/corelib/text/qstringview.cpp index cc852dd042..8442bcdf1b 100644 --- a/src/corelib/text/qstringview.cpp +++ b/src/corelib/text/qstringview.cpp @@ -532,6 +532,7 @@ QT_BEGIN_NAMESPACE /*! \fn QString QStringView::arg(Args &&...args) const \fn QString QLatin1String::arg(Args &&...args) const + \fn QString QString::arg(Args &&...args) const \since 5.14 Replaces occurrences of \c{%N} in this string with the corresponding @@ -539,8 +540,8 @@ QT_BEGIN_NAMESPACE the \a args replaces the \c{%N} with the lowest \c{N} (all of them), the second of the \a args the \c{%N} with the next-lowest \c{N} etc. - \c Args can consist of anything that implicitly converts to QStringView - or QLatin1String. + \c Args can consist of anything that implicitly converts to QString, + QStringView or QLatin1String. In addition, the following types are also supported: QChar, QLatin1Char. |