From b40d8e3c8e59d9ab4847a5430fe3188db84b65e1 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Mon, 9 Oct 2023 13:40:55 +0300 Subject: [PATCH] Fixing compatibility with Qt 5.6. --- src/libs/vmisc/compatibility.h | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/libs/vmisc/compatibility.h b/src/libs/vmisc/compatibility.h index 89a597269..c761df6b6 100644 --- a/src/libs/vmisc/compatibility.h +++ b/src/libs/vmisc/compatibility.h @@ -54,6 +54,26 @@ class QPointF; +#if QT_VERSION < QT_VERSION_CHECK(5, 8, 0) +//--------------------------------------------------------------------------------------------------------------------- +inline bool operator==(QChar lhs, const QString &rhs) Q_DECL_NOEXCEPT +{ + return rhs.size() == 1 && lhs == rhs[0]; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline bool operator!=(QChar lhs, const QString &rhs) Q_DECL_NOEXCEPT +{ + return !(lhs == rhs); +} + +//--------------------------------------------------------------------------------------------------------------------- +inline bool operator==(const QString &lhs, QChar rhs) Q_DECL_NOEXCEPT +{ + return rhs == lhs; +} +#endif + #if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) namespace Qt { @@ -63,25 +83,25 @@ inline namespace StringLiterals { //--------------------------------------------------------------------------------------------------------------------- -constexpr inline auto operator"" _L1(char ch) noexcept -> QLatin1Char +Q_DECL_CONSTEXPR inline auto operator"" _L1(char ch) Q_DECL_NOEXCEPT->QLatin1Char { return QLatin1Char(ch); } //--------------------------------------------------------------------------------------------------------------------- -constexpr inline auto operator"" _L1(const char *str, size_t size) noexcept -> QLatin1String +Q_DECL_CONSTEXPR inline auto operator"" _L1(const char *str, size_t size) Q_DECL_NOEXCEPT->QLatin1String { return QLatin1String(str, static_cast(size)); } //--------------------------------------------------------------------------------------------------------------------- -inline auto operator"" _ba(const char *str, size_t size) noexcept -> QByteArray +inline auto operator"" _ba(const char *str, size_t size) Q_DECL_NOEXCEPT->QByteArray { return {str, static_cast(size)}; } //--------------------------------------------------------------------------------------------------------------------- -inline auto operator"" _s(const char16_t *str, size_t size) noexcept -> QString +inline auto operator"" _s(const char16_t *str, size_t size) Q_DECL_NOEXCEPT->QString { return QString::fromUtf16(str, static_cast(size)); }