diff options
author | Ivan Solovev <ivan.solovev@qt.io> | 2024-03-04 18:45:54 +0100 |
---|---|---|
committer | Ivan Solovev <ivan.solovev@qt.io> | 2024-03-18 17:42:18 +0100 |
commit | fff6562f8c074d75bda8b80f844dc63c6f2e64d5 (patch) | |
tree | 7bef204cdd67302dea17c4f603515f3707cde9dd /tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp | |
parent | 769f68b19bc53a31582c4e3b7ca110661c0c8f4e (diff) |
Rework QByteArrayView comparison helpers
Commit fb50ab700600cbcdf21e5d06321f357eae4303bb replaced relational
operators in QByteArrayView with comparison helper macros.
That commit had to implement the helper methods as static members
instead of hidden friends, because otherwise it broke the
construction of QByteArrayView from QLatin1StringView.
The reason for that is the conditional noexcept on the relational
operators. The noexcept(noexcept(comparesEqual)) check inside the
class declaration expands before the class is complete, and as a
result discards the QByteArrayView constructor, which is restricted
by the QtPrivate::IsContainerCompatibleWithQByteArrayView trait.
Back then I could not find a proper solution, so just decided to
declare the helper functions for QByteArrayView as private static
members.
Such approach has two drawbacks:
- all new helper functions for QBAV vs other type T relational
operators should also be static member functions, because
the compiler always prefers member functions over friend
functions, even if the argument types do not match.
- QBAV helper functions cannot be used in generic code. Also,
qCompareThreeWay() would not work for QBAV.
To fix the issue this patch explicitly adds a
QByteArrayView(QLatin1StringView) constructor which is not
restricted by any trait. To keep the constructor constexpr, we
have to move the actual definition into qlatin1stringview.h
header file.
Integrity compiler also complains about
QByteArrayView(QUtf8StringView) constructors, so the same approach
is used to enable them.
This allows to convert all the private static member helpers in
QByteArrayView to hidden friends.
The extended tests will be added in a follow-up commit, because
they require some more changes.
Amends fb50ab700600cbcdf21e5d06321f357eae4303bb and
a08bafc9205d0b67f71a1896ad84272eeb294374.
This patch removes some exported methods and adds new ones, but
it is not BiC, because the aforementioned patches are only merged
into dev branch at this point.
Task-number: QTBUG-108805
Change-Id: Iee6526a71d859c4fcb2e95bf20fe84ddead6dfb0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp')
0 files changed, 0 insertions, 0 deletions