diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2022-12-04 12:36:50 -0800 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2022-12-06 22:24:14 -0800 |
commit | 497275a8ba12b251869c0112984d8c3cbe00fdfc (patch) | |
tree | 3d7fdc89bf44b97440027f7db7ef71de3fbec263 /src/corelib/text/qstring.h | |
parent | 1501f45c335f0a82843e3133ec2ef54d93546cf9 (diff) |
Q{Latin1,}StringView: invert members so the order is (data,size) in Qt7
Matches Q{Any,Utf8}StringView as well as std::basic_string_view in
Microsoft's STL and LLVM libc++, but not GCC's libstdc++. Interestingly,
it does match the order in libstdc++'s non-small std::basic_string.
Applied for bootstrapped use, so we ensure this works and keeps working.
Change-Id: I51d12ccdc56c4ad2af07fffd172db18254fff083
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Diffstat (limited to 'src/corelib/text/qstring.h')
-rw-r--r-- | src/corelib/text/qstring.h | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/corelib/text/qstring.h b/src/corelib/text/qstring.h index 573fca6481..81a7e492f1 100644 --- a/src/corelib/text/qstring.h +++ b/src/corelib/text/qstring.h @@ -60,15 +60,17 @@ class QLatin1String { public: #ifdef Q_L1S_VIEW_IS_PRIMARY - constexpr inline QLatin1StringView() noexcept : m_size(0), m_data(nullptr) {} + constexpr inline QLatin1StringView() noexcept {} constexpr QLatin1StringView(std::nullptr_t) noexcept : QLatin1StringView() {} constexpr inline explicit QLatin1StringView(const char *s) noexcept - : m_size(s ? qsizetype(QtPrivate::lengthHelperPointer(s)) : 0), m_data(s) {} + : QLatin1StringView(s, s ? qsizetype(QtPrivate::lengthHelperPointer(s)) : 0) {} constexpr QLatin1StringView(const char *f, const char *l) : QLatin1StringView(f, qsizetype(l - f)) {} - constexpr inline QLatin1StringView(const char *s, qsizetype sz) noexcept : m_size(sz), m_data(s) {} - explicit QLatin1StringView(const QByteArray &s) noexcept : m_size(s.size()), m_data(s.constData()) {} - constexpr explicit QLatin1StringView(QByteArrayView s) noexcept : m_size(s.size()), m_data(s.data()) {} + constexpr inline QLatin1StringView(const char *s, qsizetype sz) noexcept : m_data(s), m_size(sz) {} + explicit QLatin1StringView(const QByteArray &s) noexcept + : QLatin1StringView(s.constData(), s.size()) {} + constexpr explicit QLatin1StringView(QByteArrayView s) noexcept + : QLatin1StringView(s.constData(), s.size()) {} #else constexpr inline QLatin1String() noexcept : m_size(0), m_data(nullptr) {} Q_WEAK_OVERLOAD @@ -362,8 +364,13 @@ private: Q_CORE_EXPORT static int compare_helper(const QChar *data1, qsizetype length1, QLatin1StringView s2, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept; +#if QT_VERSION >= QT_VERSION_CHECK(7, 0, 0) || defined(QT_BOOTSTRAPPED) + const char *m_data = nullptr; + qsizetype m_size = 0; +#else qsizetype m_size; const char *m_data; +#endif }; #ifdef Q_L1S_VIEW_IS_PRIMARY Q_DECLARE_TYPEINFO(QLatin1StringView, Q_RELOCATABLE_TYPE); |