diff options
author | Marc Mutz <marc.mutz@qt.io> | 2022-03-03 09:27:59 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2022-03-04 08:39:07 +0100 |
commit | 1931689c7df579375b904a71c6f9e0844492cbe2 (patch) | |
tree | 36ff26aedda171396a7f3a6e59b1f327556123a4 /tests | |
parent | 400867693baaf8c47cff25615ab838be31665427 (diff) |
tst_qstringapisymmetry: check QString/QAnyStringView overloads w/Q_WEAK_OVERLOAD flipped
This overload set may come in handy to cushion some of the concerns
regarding replacing QString functions with QAnyStringView ones.
Overloading with a Q_WEAK_OVERLOAD QAnyStringView function requires
users to jump through hoops in order to avoid the QString overload,
but with the Q_WEAK_OVERLOAD roles reversed, the QAnyStringView
overload becomes the preferred version, relegating the QString
overload to a fall-back to facilitate sharing where it makes sense
(e.g. for QObject::setObjectName()).
Pick-to: 6.3
Change-Id: Ic65ead505beee627976a306e2d430e800540a600
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp b/tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp index 0bc0ef2efa..3eeaf9b6af 100644 --- a/tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp +++ b/tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp @@ -949,6 +949,14 @@ void overload_sr_a(QString &&) {} Q_WEAK_OVERLOAD void overload_sr_a(QAnyStringView) {} +Q_WEAK_OVERLOAD +void overload_a_s(const QString &) {} +void overload_a_s(QAnyStringView) {} + +Q_WEAK_OVERLOAD +void overload_a_sr(QString &&) {} +void overload_a_sr(QAnyStringView) {} + void overload_s_v(const QString &) {} void overload_s_v(QStringView) {} @@ -984,6 +992,20 @@ void tst_QStringApiSymmetry::overload() overload_sr_a(CT()); } + overload_a_s(t); + overload_a_s(ct); + if constexpr (!std::is_array_v<T>) { + overload_a_s(T()); + overload_a_s(CT()); + } + + overload_a_sr(t); + overload_a_sr(ct); + if constexpr (!std::is_array_v<T>) { + overload_a_sr(T()); + overload_a_sr(CT()); + } + if constexpr (std::is_convertible_v<T, QStringView> || std::is_convertible_v<T, QString>) { overload_s_v(t); overload_s_v(ct); |