diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-08-12 14:14:02 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-08-14 15:52:58 +0200 |
commit | 6f0df02d002356625f10683ef84da7685d92a2c4 (patch) | |
tree | 46713209af459ebda534c3404f48c5f5c80ba3f8 /src/corelib/text | |
parent | 44cce1a2ea9dadd8b2de93f40de34269dda703c0 (diff) |
Replace Qt CONSTEXPR defines with constexpr
Both normal and relaxed constexpr are required by our new minimum of
C++17.
Change-Id: Ic028b88a2e7a6cb7d5925f3133b9d54859a81744
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Diffstat (limited to 'src/corelib/text')
-rw-r--r-- | src/corelib/text/qbytearraymatcher.h | 8 | ||||
-rw-r--r-- | src/corelib/text/qbytearrayview.h | 2 | ||||
-rw-r--r-- | src/corelib/text/qchar.h | 176 | ||||
-rw-r--r-- | src/corelib/text/qlocale_p.h | 2 | ||||
-rw-r--r-- | src/corelib/text/qstring.cpp | 8 | ||||
-rw-r--r-- | src/corelib/text/qstring.h | 60 | ||||
-rw-r--r-- | src/corelib/text/qstringalgorithms.h | 2 | ||||
-rw-r--r-- | src/corelib/text/qstringbuilder.h | 2 | ||||
-rw-r--r-- | src/corelib/text/qstringview.h | 56 |
9 files changed, 158 insertions, 158 deletions
diff --git a/src/corelib/text/qbytearraymatcher.h b/src/corelib/text/qbytearraymatcher.h index e847d3a6dc..876225230b 100644 --- a/src/corelib/text/qbytearraymatcher.h +++ b/src/corelib/text/qbytearraymatcher.h @@ -90,7 +90,7 @@ class QStaticByteArrayMatcherBase uchar data[256]; } m_skiptable; protected: - explicit Q_DECL_RELAXED_CONSTEXPR QStaticByteArrayMatcherBase(const char *pattern, uint n) noexcept + explicit constexpr QStaticByteArrayMatcherBase(const char *pattern, uint n) noexcept : m_skiptable(generate(pattern, n)) {} // compiler-generated copy/more ctors/assignment operators are ok! // compiler-generated dtor is ok! @@ -98,7 +98,7 @@ protected: Q_CORE_EXPORT int indexOfIn(const char *needle, uint nlen, const char *haystack, int hlen, int from) const noexcept; private: - static Q_DECL_RELAXED_CONSTEXPR Skiptable generate(const char *pattern, uint n) noexcept + static constexpr Skiptable generate(const char *pattern, uint n) noexcept { const auto uchar_max = (std::numeric_limits<uchar>::max)(); uchar max = n > uchar_max ? uchar_max : uchar(n); @@ -140,7 +140,7 @@ class QStaticByteArrayMatcher : QStaticByteArrayMatcherBase char m_pattern[N]; static_assert(N > 2, "QStaticByteArrayMatcher makes no sense for finding a single-char pattern"); public: - explicit Q_DECL_RELAXED_CONSTEXPR QStaticByteArrayMatcher(const char (&patternToMatch)[N]) noexcept + explicit constexpr QStaticByteArrayMatcher(const char (&patternToMatch)[N]) noexcept : QStaticByteArrayMatcherBase(patternToMatch, N - 1), m_pattern() { for (uint i = 0; i < N; ++i) @@ -156,7 +156,7 @@ public: }; template <uint N> -Q_DECL_RELAXED_CONSTEXPR QStaticByteArrayMatcher<N> qMakeStaticByteArrayMatcher(const char (&pattern)[N]) noexcept +constexpr QStaticByteArrayMatcher<N> qMakeStaticByteArrayMatcher(const char (&pattern)[N]) noexcept { return QStaticByteArrayMatcher<N>(pattern); } QT_END_NAMESPACE diff --git a/src/corelib/text/qbytearrayview.h b/src/corelib/text/qbytearrayview.h index 4366c37ed2..81db7029de 100644 --- a/src/corelib/text/qbytearrayview.h +++ b/src/corelib/text/qbytearrayview.h @@ -156,7 +156,7 @@ private: template <typename Byte> static const storage_type *castHelper(const Byte *data) noexcept { return reinterpret_cast<const storage_type*>(data); } - static Q_DECL_CONSTEXPR const storage_type *castHelper(const storage_type *data) noexcept + static constexpr const storage_type *castHelper(const storage_type *data) noexcept { return data; } public: diff --git a/src/corelib/text/qchar.h b/src/corelib/text/qchar.h index 8c6b2685aa..c3fe6d3107 100644 --- a/src/corelib/text/qchar.h +++ b/src/corelib/text/qchar.h @@ -52,27 +52,27 @@ class QString; struct QLatin1Char { public: - Q_DECL_CONSTEXPR inline explicit QLatin1Char(char c) noexcept : ch(c) {} - Q_DECL_CONSTEXPR inline char toLatin1() const noexcept { return ch; } - Q_DECL_CONSTEXPR inline char16_t unicode() const noexcept { return char16_t(uchar(ch)); } + constexpr inline explicit QLatin1Char(char c) noexcept : ch(c) {} + constexpr inline char toLatin1() const noexcept { return ch; } + constexpr inline char16_t unicode() const noexcept { return char16_t(uchar(ch)); } private: char ch; }; -Q_DECL_CONSTEXPR inline bool operator==(char lhs, QLatin1Char rhs) noexcept { return lhs == rhs.toLatin1(); } -Q_DECL_CONSTEXPR inline bool operator!=(char lhs, QLatin1Char rhs) noexcept { return lhs != rhs.toLatin1(); } -Q_DECL_CONSTEXPR inline bool operator<=(char lhs, QLatin1Char rhs) noexcept { return lhs <= rhs.toLatin1(); } -Q_DECL_CONSTEXPR inline bool operator>=(char lhs, QLatin1Char rhs) noexcept { return lhs >= rhs.toLatin1(); } -Q_DECL_CONSTEXPR inline bool operator< (char lhs, QLatin1Char rhs) noexcept { return lhs < rhs.toLatin1(); } -Q_DECL_CONSTEXPR inline bool operator> (char lhs, QLatin1Char rhs) noexcept { return lhs > rhs.toLatin1(); } +constexpr inline bool operator==(char lhs, QLatin1Char rhs) noexcept { return lhs == rhs.toLatin1(); } +constexpr inline bool operator!=(char lhs, QLatin1Char rhs) noexcept { return lhs != rhs.toLatin1(); } +constexpr inline bool operator<=(char lhs, QLatin1Char rhs) noexcept { return lhs <= rhs.toLatin1(); } +constexpr inline bool operator>=(char lhs, QLatin1Char rhs) noexcept { return lhs >= rhs.toLatin1(); } +constexpr inline bool operator< (char lhs, QLatin1Char rhs) noexcept { return lhs < rhs.toLatin1(); } +constexpr inline bool operator> (char lhs, QLatin1Char rhs) noexcept { return lhs > rhs.toLatin1(); } -Q_DECL_CONSTEXPR inline bool operator==(QLatin1Char lhs, char rhs) noexcept { return lhs.toLatin1() == rhs; } -Q_DECL_CONSTEXPR inline bool operator!=(QLatin1Char lhs, char rhs) noexcept { return lhs.toLatin1() != rhs; } -Q_DECL_CONSTEXPR inline bool operator<=(QLatin1Char lhs, char rhs) noexcept { return lhs.toLatin1() <= rhs; } -Q_DECL_CONSTEXPR inline bool operator>=(QLatin1Char lhs, char rhs) noexcept { return lhs.toLatin1() >= rhs; } -Q_DECL_CONSTEXPR inline bool operator< (QLatin1Char lhs, char rhs) noexcept { return lhs.toLatin1() < rhs; } -Q_DECL_CONSTEXPR inline bool operator> (QLatin1Char lhs, char rhs) noexcept { return lhs.toLatin1() > rhs; } +constexpr inline bool operator==(QLatin1Char lhs, char rhs) noexcept { return lhs.toLatin1() == rhs; } +constexpr inline bool operator!=(QLatin1Char lhs, char rhs) noexcept { return lhs.toLatin1() != rhs; } +constexpr inline bool operator<=(QLatin1Char lhs, char rhs) noexcept { return lhs.toLatin1() <= rhs; } +constexpr inline bool operator>=(QLatin1Char lhs, char rhs) noexcept { return lhs.toLatin1() >= rhs; } +constexpr inline bool operator< (QLatin1Char lhs, char rhs) noexcept { return lhs.toLatin1() < rhs; } +constexpr inline bool operator> (QLatin1Char lhs, char rhs) noexcept { return lhs.toLatin1() > rhs; } class Q_CORE_EXPORT QChar { public: @@ -94,30 +94,30 @@ public: LastValidCodePoint = 0x10ffff }; - Q_DECL_CONSTEXPR QChar() noexcept : ucs(0) {} - Q_DECL_CONSTEXPR QChar(ushort rc) noexcept : ucs(rc) {} - Q_DECL_CONSTEXPR QChar(uchar c, uchar r) noexcept : ucs(char16_t((r << 8) | c)) {} - Q_DECL_CONSTEXPR QChar(short rc) noexcept : ucs(char16_t(rc)) {} - Q_DECL_CONSTEXPR QChar(uint rc) noexcept : ucs(char16_t(rc & 0xffff)) {} - Q_DECL_CONSTEXPR QChar(int rc) noexcept : ucs(char16_t(rc & 0xffff)) {} - Q_DECL_CONSTEXPR QChar(SpecialCharacter s) noexcept : ucs(char16_t(s)) {} // implicit - Q_DECL_CONSTEXPR QChar(QLatin1Char ch) noexcept : ucs(ch.unicode()) {} // implicit + constexpr QChar() noexcept : ucs(0) {} + constexpr QChar(ushort rc) noexcept : ucs(rc) {} + constexpr QChar(uchar c, uchar r) noexcept : ucs(char16_t((r << 8) | c)) {} + constexpr QChar(short rc) noexcept : ucs(char16_t(rc)) {} + constexpr QChar(uint rc) noexcept : ucs(char16_t(rc & 0xffff)) {} + constexpr QChar(int rc) noexcept : ucs(char16_t(rc & 0xffff)) {} + constexpr QChar(SpecialCharacter s) noexcept : ucs(char16_t(s)) {} // implicit + constexpr QChar(QLatin1Char ch) noexcept : ucs(ch.unicode()) {} // implicit #if defined(Q_COMPILER_UNICODE_STRINGS) - Q_DECL_CONSTEXPR QChar(char16_t ch) noexcept : ucs(ch) {} // implicit + constexpr QChar(char16_t ch) noexcept : ucs(ch) {} // implicit #endif #if defined(Q_OS_WIN) static_assert(sizeof(wchar_t) == sizeof(char16_t)); #endif #if defined(Q_OS_WIN) || defined(Q_CLANG_QDOC) # if !defined(_WCHAR_T_DEFINED) || defined(_NATIVE_WCHAR_T_DEFINED) - Q_DECL_CONSTEXPR QChar(wchar_t ch) noexcept : ucs(char16_t(ch)) {} // implicit + constexpr QChar(wchar_t ch) noexcept : ucs(char16_t(ch)) {} // implicit # endif #endif #ifndef QT_NO_CAST_FROM_ASCII - QT_ASCII_CAST_WARN Q_DECL_CONSTEXPR QChar(char c) noexcept : ucs(uchar(c)) { } + QT_ASCII_CAST_WARN constexpr QChar(char c) noexcept : ucs(uchar(c)) { } #ifndef QT_RESTRICTED_CAST_FROM_ASCII - QT_ASCII_CAST_WARN Q_DECL_CONSTEXPR QChar(uchar c) noexcept : ucs(c) { } + QT_ASCII_CAST_WARN constexpr QChar(uchar c) noexcept : ucs(c) { } #endif #endif @@ -467,70 +467,70 @@ public: inline UnicodeVersion unicodeVersion() const noexcept { return QChar::unicodeVersion(ucs); } - Q_DECL_CONSTEXPR inline char toLatin1() const noexcept { return ucs > 0xff ? '\0' : char(ucs); } - Q_DECL_CONSTEXPR inline char16_t unicode() const noexcept { return ucs; } - Q_DECL_RELAXED_CONSTEXPR inline char16_t &unicode() noexcept { return ucs; } + constexpr inline char toLatin1() const noexcept { return ucs > 0xff ? '\0' : char(ucs); } + constexpr inline char16_t unicode() const noexcept { return ucs; } + constexpr inline char16_t &unicode() noexcept { return ucs; } - static Q_DECL_CONSTEXPR QChar fromLatin1(char c) noexcept { return QLatin1Char(c); } + static constexpr QChar fromLatin1(char c) noexcept { return QLatin1Char(c); } - Q_DECL_CONSTEXPR inline bool isNull() const noexcept { return ucs == 0; } + constexpr inline bool isNull() const noexcept { return ucs == 0; } inline bool isPrint() const noexcept { return QChar::isPrint(ucs); } - Q_DECL_CONSTEXPR inline bool isSpace() const noexcept { return QChar::isSpace(ucs); } + constexpr inline bool isSpace() const noexcept { return QChar::isSpace(ucs); } inline bool isMark() const noexcept { return QChar::isMark(ucs); } inline bool isPunct() const noexcept { return QChar::isPunct(ucs); } inline bool isSymbol() const noexcept { return QChar::isSymbol(ucs); } - Q_DECL_CONSTEXPR inline bool isLetter() const noexcept { return QChar::isLetter(ucs); } - Q_DECL_CONSTEXPR inline bool isNumber() const noexcept { return QChar::isNumber(ucs); } - Q_DECL_CONSTEXPR inline bool isLetterOrNumber() const noexcept { return QChar::isLetterOrNumber(ucs); } - Q_DECL_CONSTEXPR inline bool isDigit() const noexcept { return QChar::isDigit(ucs); } - Q_DECL_CONSTEXPR inline bool isLower() const noexcept { return QChar::isLower(ucs); } - Q_DECL_CONSTEXPR inline bool isUpper() const noexcept { return QChar::isUpper(ucs); } - Q_DECL_CONSTEXPR inline bool isTitleCase() const noexcept { return QChar::isTitleCase(ucs); } - - Q_DECL_CONSTEXPR inline bool isNonCharacter() const noexcept { return QChar::isNonCharacter(ucs); } - Q_DECL_CONSTEXPR inline bool isHighSurrogate() const noexcept { return QChar::isHighSurrogate(ucs); } - Q_DECL_CONSTEXPR inline bool isLowSurrogate() const noexcept { return QChar::isLowSurrogate(ucs); } - Q_DECL_CONSTEXPR inline bool isSurrogate() const noexcept { return QChar::isSurrogate(ucs); } - - Q_DECL_CONSTEXPR inline uchar cell() const noexcept { return uchar(ucs & 0xff); } - Q_DECL_CONSTEXPR inline uchar row() const noexcept { return uchar((ucs>>8)&0xff); } - Q_DECL_RELAXED_CONSTEXPR inline void setCell(uchar acell) noexcept { ucs = char16_t((ucs & 0xff00) + acell); } - Q_DECL_RELAXED_CONSTEXPR inline void setRow(uchar arow) noexcept { ucs = char16_t((char16_t(arow)<<8) + (ucs&0xff)); } - - static Q_DECL_CONSTEXPR inline bool isNonCharacter(char32_t ucs4) noexcept + constexpr inline bool isLetter() const noexcept { return QChar::isLetter(ucs); } + constexpr inline bool isNumber() const noexcept { return QChar::isNumber(ucs); } + constexpr inline bool isLetterOrNumber() const noexcept { return QChar::isLetterOrNumber(ucs); } + constexpr inline bool isDigit() const noexcept { return QChar::isDigit(ucs); } + constexpr inline bool isLower() const noexcept { return QChar::isLower(ucs); } + constexpr inline bool isUpper() const noexcept { return QChar::isUpper(ucs); } + constexpr inline bool isTitleCase() const noexcept { return QChar::isTitleCase(ucs); } + + constexpr inline bool isNonCharacter() const noexcept { return QChar::isNonCharacter(ucs); } + constexpr inline bool isHighSurrogate() const noexcept { return QChar::isHighSurrogate(ucs); } + constexpr inline bool isLowSurrogate() const noexcept { return QChar::isLowSurrogate(ucs); } + constexpr inline bool isSurrogate() const noexcept { return QChar::isSurrogate(ucs); } + + constexpr inline uchar cell() const noexcept { return uchar(ucs & 0xff); } + constexpr inline uchar row() const noexcept { return uchar((ucs>>8)&0xff); } + constexpr inline void setCell(uchar acell) noexcept { ucs = char16_t((ucs & 0xff00) + acell); } + constexpr inline void setRow(uchar arow) noexcept { ucs = char16_t((char16_t(arow)<<8) + (ucs&0xff)); } + + static constexpr inline bool isNonCharacter(char32_t ucs4) noexcept { return ucs4 >= 0xfdd0 && (ucs4 <= 0xfdef || (ucs4 & 0xfffe) == 0xfffe); } - static Q_DECL_CONSTEXPR inline bool isHighSurrogate(char32_t ucs4) noexcept + static constexpr inline bool isHighSurrogate(char32_t ucs4) noexcept { return ((ucs4 & 0xfffffc00) == 0xd800); } - static Q_DECL_CONSTEXPR inline bool isLowSurrogate(char32_t ucs4) noexcept + static constexpr inline bool isLowSurrogate(char32_t ucs4) noexcept { return ((ucs4 & 0xfffffc00) == 0xdc00); } - static Q_DECL_CONSTEXPR inline bool isSurrogate(char32_t ucs4) noexcept + static constexpr inline bool isSurrogate(char32_t ucs4) noexcept { return (ucs4 - 0xd800u < 2048u); } - static Q_DECL_CONSTEXPR inline bool requiresSurrogates(char32_t ucs4) noexcept + static constexpr inline bool requiresSurrogates(char32_t ucs4) noexcept { return (ucs4 >= 0x10000); } - static Q_DECL_CONSTEXPR inline char32_t surrogateToUcs4(char16_t high, char16_t low) noexcept + static constexpr inline char32_t surrogateToUcs4(char16_t high, char16_t low) noexcept { return (char32_t(high)<<10) + low - 0x35fdc00; } - static Q_DECL_CONSTEXPR inline char32_t surrogateToUcs4(QChar high, QChar low) noexcept + static constexpr inline char32_t surrogateToUcs4(QChar high, QChar low) noexcept { return surrogateToUcs4(high.ucs, low.ucs); } - static Q_DECL_CONSTEXPR inline char16_t highSurrogate(char32_t ucs4) noexcept + static constexpr inline char16_t highSurrogate(char32_t ucs4) noexcept { return char16_t((ucs4>>10) + 0xd7c0); } - static Q_DECL_CONSTEXPR inline char16_t lowSurrogate(char32_t ucs4) noexcept + static constexpr inline char16_t lowSurrogate(char32_t ucs4) noexcept { return char16_t(ucs4%0x400 + 0xdc00); } @@ -559,7 +559,7 @@ public: static UnicodeVersion QT_FASTCALL currentUnicodeVersion() noexcept Q_DECL_CONST_FUNCTION; static bool QT_FASTCALL isPrint(char32_t ucs4) noexcept Q_DECL_CONST_FUNCTION; - static Q_DECL_CONSTEXPR inline bool isSpace(char32_t ucs4) noexcept Q_DECL_CONST_FUNCTION + static constexpr inline bool isSpace(char32_t ucs4) noexcept Q_DECL_CONST_FUNCTION { // note that [0x09..0x0d] + 0x85 are exceptional Cc-s and must be handled explicitly return ucs4 == 0x20 || (ucs4 <= 0x0d && ucs4 >= 0x09) @@ -568,26 +568,26 @@ public: static bool QT_FASTCALL isMark(char32_t ucs4) noexcept Q_DECL_CONST_FUNCTION; static bool QT_FASTCALL isPunct(char32_t ucs4) noexcept Q_DECL_CONST_FUNCTION; static bool QT_FASTCALL isSymbol(char32_t ucs4) noexcept Q_DECL_CONST_FUNCTION; - static Q_DECL_CONSTEXPR inline bool isLetter(char32_t ucs4) noexcept Q_DECL_CONST_FUNCTION + static constexpr inline bool isLetter(char32_t ucs4) noexcept Q_DECL_CONST_FUNCTION { return (ucs4 >= 'A' && ucs4 <= 'z' && (ucs4 >= 'a' || ucs4 <= 'Z')) || (ucs4 > 127 && QChar::isLetter_helper(ucs4)); } - static Q_DECL_CONSTEXPR inline bool isNumber(char32_t ucs4) noexcept Q_DECL_CONST_FUNCTION + static constexpr inline bool isNumber(char32_t ucs4) noexcept Q_DECL_CONST_FUNCTION { return (ucs4 <= '9' && ucs4 >= '0') || (ucs4 > 127 && QChar::isNumber_helper(ucs4)); } - static Q_DECL_CONSTEXPR inline bool isLetterOrNumber(char32_t ucs4) noexcept Q_DECL_CONST_FUNCTION + static constexpr inline bool isLetterOrNumber(char32_t ucs4) noexcept Q_DECL_CONST_FUNCTION { return (ucs4 >= 'A' && ucs4 <= 'z' && (ucs4 >= 'a' || ucs4 <= 'Z')) || (ucs4 >= '0' && ucs4 <= '9') || (ucs4 > 127 && QChar::isLetterOrNumber_helper(ucs4)); } - static Q_DECL_CONSTEXPR inline bool isDigit(char32_t ucs4) noexcept Q_DECL_CONST_FUNCTION + static constexpr inline bool isDigit(char32_t ucs4) noexcept Q_DECL_CONST_FUNCTION { return (ucs4 <= '9' && ucs4 >= '0') || (ucs4 > 127 && QChar::category(ucs4) == Number_DecimalDigit); } - static Q_DECL_CONSTEXPR inline bool isLower(char32_t ucs4) noexcept Q_DECL_CONST_FUNCTION + static constexpr inline bool isLower(char32_t ucs4) noexcept Q_DECL_CONST_FUNCTION { return (ucs4 <= 'z' && ucs4 >= 'a') || (ucs4 > 127 && QChar::category(ucs4) == Letter_Lowercase); } - static Q_DECL_CONSTEXPR inline bool isUpper(char32_t ucs4) noexcept Q_DECL_CONST_FUNCTION + static constexpr inline bool isUpper(char32_t ucs4) noexcept Q_DECL_CONST_FUNCTION { return (ucs4 <= 'Z' && ucs4 >= 'A') || (ucs4 > 127 && QChar::category(ucs4) == Letter_Uppercase); } - static Q_DECL_CONSTEXPR inline bool isTitleCase(char32_t ucs4) noexcept Q_DECL_CONST_FUNCTION + static constexpr inline bool isTitleCase(char32_t ucs4) noexcept Q_DECL_CONST_FUNCTION { return ucs4 > 127 && QChar::category(ucs4) == Letter_Titlecase; } private: @@ -601,36 +601,36 @@ private: QChar(uchar c) noexcept; #endif - friend Q_DECL_CONSTEXPR bool operator==(QChar, QChar) noexcept; - friend Q_DECL_CONSTEXPR bool operator< (QChar, QChar) noexcept; + friend constexpr bool operator==(QChar, QChar) noexcept; + friend constexpr bool operator< (QChar, QChar) noexcept; char16_t ucs; }; Q_DECLARE_TYPEINFO(QChar, Q_MOVABLE_TYPE); -Q_DECL_CONSTEXPR inline bool operator==(QChar c1, QChar c2) noexcept { return c1.ucs == c2.ucs; } -Q_DECL_CONSTEXPR inline bool operator< (QChar c1, QChar c2) noexcept { return c1.ucs < c2.ucs; } +constexpr inline bool operator==(QChar c1, QChar c2) noexcept { return c1.ucs == c2.ucs; } +constexpr inline bool operator< (QChar c1, QChar c2) noexcept { return c1.ucs < c2.ucs; } -Q_DECL_CONSTEXPR inline bool operator!=(QChar c1, QChar c2) noexcept { return !operator==(c1, c2); } -Q_DECL_CONSTEXPR inline bool operator>=(QChar c1, QChar c2) noexcept { return !operator< (c1, c2); } -Q_DECL_CONSTEXPR inline bool operator> (QChar c1, QChar c2) noexcept { return operator< (c2, c1); } -Q_DECL_CONSTEXPR inline bool operator<=(QChar c1, QChar c2) noexcept { return !operator< (c2, c1); } +constexpr inline bool operator!=(QChar c1, QChar c2) noexcept { return !operator==(c1, c2); } +constexpr inline bool operator>=(QChar c1, QChar c2) noexcept { return !operator< (c1, c2); } +constexpr inline bool operator> (QChar c1, QChar c2) noexcept { return operator< (c2, c1); } +constexpr inline bool operator<=(QChar c1, QChar c2) noexcept { return !operator< (c2, c1); } -Q_DECL_CONSTEXPR inline bool operator==(QChar lhs, std::nullptr_t) noexcept { return lhs.isNull(); } -Q_DECL_CONSTEXPR inline bool operator< (QChar, std::nullptr_t) noexcept { return false; } -Q_DECL_CONSTEXPR inline bool operator==(std::nullptr_t, QChar rhs) noexcept { return rhs.isNull(); } -Q_DECL_CONSTEXPR inline bool operator< (std::nullptr_t, QChar rhs) noexcept { return !rhs.isNull(); } +constexpr inline bool operator==(QChar lhs, std::nullptr_t) noexcept { return lhs.isNull(); } +constexpr inline bool operator< (QChar, std::nullptr_t) noexcept { return false; } +constexpr inline bool operator==(std::nullptr_t, QChar rhs) noexcept { return rhs.isNull(); } +constexpr inline bool operator< (std::nullptr_t, QChar rhs) noexcept { return !rhs.isNull(); } -Q_DECL_CONSTEXPR inline bool operator!=(QChar lhs, std::nullptr_t) noexcept { return !operator==(lhs, nullptr); } -Q_DECL_CONSTEXPR inline bool operator>=(QChar lhs, std::nullptr_t) noexcept { return !operator< (lhs, nullptr); } -Q_DECL_CONSTEXPR inline bool operator> (QChar lhs, std::nullptr_t) noexcept { return operator< (nullptr, lhs); } -Q_DECL_CONSTEXPR inline bool operator<=(QChar lhs, std::nullptr_t) noexcept { return !operator< (nullptr, lhs); } +constexpr inline bool operator!=(QChar lhs, std::nullptr_t) noexcept { return !operator==(lhs, nullptr); } +constexpr inline bool operator>=(QChar lhs, std::nullptr_t) noexcept { return !operator< (lhs, nullptr); } +constexpr inline bool operator> (QChar lhs, std::nullptr_t) noexcept { return operator< (nullptr, lhs); } +constexpr inline bool operator<=(QChar lhs, std::nullptr_t) noexcept { return !operator< (nullptr, lhs); } -Q_DECL_CONSTEXPR inline bool operator!=(std::nullptr_t, QChar rhs) noexcept { return !operator==(nullptr, rhs); } -Q_DECL_CONSTEXPR inline bool operator>=(std::nullptr_t, QChar rhs) noexcept { return !operator< (nullptr, rhs); } -Q_DECL_CONSTEXPR inline bool operator> (std::nullptr_t, QChar rhs) noexcept { return operator< (rhs, nullptr); } -Q_DECL_CONSTEXPR inline bool operator<=(std::nullptr_t, QChar rhs) noexcept { return !operator< (rhs, nullptr); } +constexpr inline bool operator!=(std::nullptr_t, QChar rhs) noexcept { return !operator==(nullptr, rhs); } +constexpr inline bool operator>=(std::nullptr_t, QChar rhs) noexcept { return !operator< (nullptr, rhs); } +constexpr inline bool operator> (std::nullptr_t, QChar rhs) noexcept { return operator< (rhs, nullptr); } +constexpr inline bool operator<=(std::nullptr_t, QChar rhs) noexcept { return !operator< (rhs, nullptr); } #ifndef QT_NO_DATASTREAM Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, QChar); diff --git a/src/corelib/text/qlocale_p.h b/src/corelib/text/qlocale_p.h index fa61438041..df6aba30ce 100644 --- a/src/corelib/text/qlocale_p.h +++ b/src/corelib/text/qlocale_p.h @@ -494,7 +494,7 @@ enum { AsciiSpaceMask = (1u << (' ' - 1)) | (1u << ('\v' - 1)) | // 11: VT - vertical tab (1u << ('\f' - 1)) | // 12: FF - form feed (1u << ('\r' - 1)) }; // 13: CR - carriage return -Q_DECL_CONSTEXPR inline bool ascii_isspace(uchar c) +constexpr inline bool ascii_isspace(uchar c) { return c >= 1u && c <= 32u && (AsciiSpaceMask >> uint(c - 1)) & 1u; } diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp index 773688d783..6f8d2c87f5 100644 --- a/src/corelib/text/qstring.cpp +++ b/src/corelib/text/qstring.cpp @@ -588,7 +588,7 @@ bool QtPrivate::isLatin1(QStringView s) noexcept bool QtPrivate::isValidUtf16(QStringView s) noexcept { - Q_CONSTEXPR char32_t InvalidCodePoint = UINT_MAX; + constexpr char32_t InvalidCodePoint = UINT_MAX; QStringIterator i(s); while (i.hasNext()) { @@ -1187,7 +1187,7 @@ static int ucstrncmp(const QChar *a, const uchar *c, size_t l) } template <typename Number> -Q_DECL_CONSTEXPR int lencmp(Number lhs, Number rhs) noexcept +constexpr int lencmp(Number lhs, Number rhs) noexcept { return lhs == rhs ? 0 : lhs > rhs ? 1 : @@ -8245,9 +8245,9 @@ namespace { struct Part { Part() = default; // for QVarLengthArray; do not use - Q_DECL_CONSTEXPR Part(QStringView s, int num = -1) + constexpr Part(QStringView s, int num = -1) : tag{QtPrivate::ArgBase::U16}, number{num}, data{s.utf16()}, size{s.size()} {} - Q_DECL_CONSTEXPR Part(QLatin1String s, int num = -1) + constexpr Part(QLatin1String s, int num = -1) : tag{QtPrivate::ArgBase::L1}, number{num}, data{s.data()}, size{s.size()} {} void reset(QStringView s) noexcept { *this = {s, number}; } diff --git a/src/corelib/text/qstring.h b/src/corelib/text/qstring.h index ba21aba618..6ad24b2b5f 100644 --- a/src/corelib/text/qstring.h +++ b/src/corelib/text/qstring.h @@ -85,37 +85,37 @@ template <bool...B> class BoolList; class QLatin1String { public: - Q_DECL_CONSTEXPR inline QLatin1String() noexcept : m_size(0), m_data(nullptr) {} - Q_DECL_CONSTEXPR inline explicit QLatin1String(const char *s) noexcept : m_size(s ? int(strlen(s)) : 0), m_data(s) {} - Q_DECL_CONSTEXPR explicit QLatin1String(const char *f, const char *l) + constexpr inline QLatin1String() noexcept : m_size(0), m_data(nullptr) {} + constexpr inline explicit QLatin1String(const char *s) noexcept : m_size(s ? int(strlen(s)) : 0), m_data(s) {} + constexpr explicit QLatin1String(const char *f, const char *l) : QLatin1String(f, int(l - f)) {} - Q_DECL_CONSTEXPR inline explicit QLatin1String(const char *s, int sz) noexcept : m_size(sz), m_data(s) {} + constexpr inline explicit QLatin1String(const char *s, int sz) noexcept : m_size(sz), m_data(s) {} inline explicit QLatin1String(const QByteArray &s) noexcept : m_size(int(qstrnlen(s.constData(), s.size()))), m_data(s.constData()) {} inline QString toString() const; - Q_DECL_CONSTEXPR const char *latin1() const noexcept { return m_data; } - Q_DECL_CONSTEXPR int size() const noexcept { return m_size; } - Q_DECL_CONSTEXPR const char *data() const noexcept { return m_data; } + constexpr const char *latin1() const noexcept { return m_data; } + constexpr int size() const noexcept { return m_size; } + constexpr const char *data() const noexcept { return m_data; } - Q_DECL_CONSTEXPR bool isNull() const noexcept { return !data(); } - Q_DECL_CONSTEXPR bool isEmpty() const noexcept { return !size(); } + constexpr bool isNull() const noexcept { return !data(); } + constexpr bool isEmpty() const noexcept { return !size(); } template <typename...Args> Q_REQUIRED_RESULT inline QString arg(Args &&...args) const; - Q_DECL_CONSTEXPR QLatin1Char at(int i) const + constexpr QLatin1Char at(int i) const { return Q_ASSERT(i >= 0), Q_ASSERT(i < size()), QLatin1Char(m_data[i]); } - Q_DECL_CONSTEXPR QLatin1Char operator[](int i) const { return at(i); } + constexpr QLatin1Char operator[](int i) const { return at(i); } - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QLatin1Char front() const { return at(0); } - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QLatin1Char back() const { return at(size() - 1); } + Q_REQUIRED_RESULT constexpr QLatin1Char front() const { return at(0); } + Q_REQUIRED_RESULT constexpr QLatin1Char back() const { return at(size() - 1); } Q_REQUIRED_RESULT int compare(QStringView other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept { return QtPrivate::compareStrings(*this, other, cs); } Q_REQUIRED_RESULT int compare(QLatin1String other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept { return QtPrivate::compareStrings(*this, other, cs); } - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR int compare(QChar c) const noexcept + Q_REQUIRED_RESULT constexpr int compare(QChar c) const noexcept { return isEmpty() || front() == c ? size() - 1 : uchar(m_data[0]) - c.unicode() ; } Q_REQUIRED_RESULT int compare(QChar c, Qt::CaseSensitivity cs) const noexcept { return QtPrivate::compareStrings(*this, QStringView(&c, 1), cs); } @@ -124,7 +124,7 @@ public: { return QtPrivate::startsWith(*this, s, cs); } Q_REQUIRED_RESULT bool startsWith(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept { return QtPrivate::startsWith(*this, s, cs); } - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR bool startsWith(QChar c) const noexcept + Q_REQUIRED_RESULT constexpr bool startsWith(QChar c) const noexcept { return !isEmpty() && front() == c; } Q_REQUIRED_RESULT inline bool startsWith(QChar c, Qt::CaseSensitivity cs) const noexcept { return QtPrivate::startsWith(*this, QStringView(&c, 1), cs); } @@ -133,7 +133,7 @@ public: { return QtPrivate::endsWith(*this, s, cs); } Q_REQUIRED_RESULT bool endsWith(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept { return QtPrivate::endsWith(*this, s, cs); } - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR bool endsWith(QChar c) const noexcept + Q_REQUIRED_RESULT constexpr bool endsWith(QChar c) const noexcept { return !isEmpty() && back() == c; } Q_REQUIRED_RESULT inline bool endsWith(QChar c, Qt::CaseSensitivity cs) const noexcept { return QtPrivate::endsWith(*this, QStringView(&c, 1), cs); } @@ -167,10 +167,10 @@ public: using difference_type = int; // violates Container concept requirements using size_type = int; // violates Container concept requirements - Q_DECL_CONSTEXPR const_iterator begin() const noexcept { return data(); } - Q_DECL_CONSTEXPR const_iterator cbegin() const noexcept { return data(); } - Q_DECL_CONSTEXPR const_iterator end() const noexcept { return data() + size(); } - Q_DECL_CONSTEXPR const_iterator cend() const noexcept { return data() + size(); } + constexpr const_iterator begin() const noexcept { return data(); } + constexpr const_iterator cbegin() const noexcept { return data(); } + constexpr const_iterator end() const noexcept { return data() + size(); } + constexpr const_iterator cend() const noexcept { return data() + size(); } using reverse_iterator = std::reverse_iterator<iterator>; using const_reverse_iterator = reverse_iterator; @@ -200,12 +200,12 @@ public: n = size(); return QLatin1String(m_data + m_size - n, n); } - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QLatin1String chopped(int n) const + Q_REQUIRED_RESULT constexpr QLatin1String chopped(int n) const { return Q_ASSERT(n >= 0), Q_ASSERT(n <= size()), QLatin1String(m_data, m_size - n); } - Q_DECL_RELAXED_CONSTEXPR void chop(int n) + constexpr void chop(int n) { Q_ASSERT(n >= 0); Q_ASSERT(n <= size()); m_size -= n; } - Q_DECL_RELAXED_CONSTEXPR void truncate(int n) + constexpr void truncate(int n) { Q_ASSERT(n >= 0); Q_ASSERT(n <= size()); m_size = n; } Q_REQUIRED_RESULT QLatin1String trimmed() const noexcept { return QtPrivate::trimmed(*this); } @@ -250,7 +250,7 @@ Q_DECLARE_TYPEINFO(QLatin1String, Q_MOVABLE_TYPE); // // QLatin1String inline implementations // -Q_DECL_CONSTEXPR bool QtPrivate::isLatin1(QLatin1String) noexcept +constexpr bool QtPrivate::isLatin1(QLatin1String) noexcept { return true; } // @@ -1796,13 +1796,13 @@ struct ArgBase { struct QStringViewArg : ArgBase { QStringView string; QStringViewArg() = default; - Q_DECL_CONSTEXPR explicit QStringViewArg(QStringView v) noexcept : ArgBase{U16}, string{v} {} + constexpr explicit QStringViewArg(QStringView v) noexcept : ArgBase{U16}, string{v} {} }; struct QLatin1StringArg : ArgBase { QLatin1String string; QLatin1StringArg() = default; - Q_DECL_CONSTEXPR explicit QLatin1StringArg(QLatin1String v) noexcept : ArgBase{L1}, string{v} {} + constexpr explicit QLatin1StringArg(QLatin1String v) noexcept : ArgBase{L1}, string{v} {} }; Q_REQUIRED_RESULT Q_CORE_EXPORT QString argToQString(QStringView pattern, size_t n, const ArgBase **args); @@ -1815,10 +1815,10 @@ Q_REQUIRED_RESULT Q_ALWAYS_INLINE QString argToQStringDispatch(StringView patter return QtPrivate::argToQString(pattern, sizeof...(Args), argBases); } - inline QStringViewArg qStringLikeToArg(const QString &s) noexcept { return QStringViewArg{qToStringViewIgnoringNull(s)}; } -Q_DECL_CONSTEXPR inline QStringViewArg qStringLikeToArg(QStringView s) noexcept { return QStringViewArg{s}; } - inline QStringViewArg qStringLikeToArg(const QChar &c) noexcept { return QStringViewArg{QStringView{&c, 1}}; } -Q_DECL_CONSTEXPR inline QLatin1StringArg qStringLikeToArg(QLatin1String s) noexcept { return QLatin1StringArg{s}; } + inline QStringViewArg qStringLikeToArg(const QString &s) noexcept { return QStringViewArg{qToStringViewIgnoringNull(s)}; } +constexpr inline QStringViewArg qStringLikeToArg(QStringView s) noexcept { return QStringViewArg{s}; } + inline QStringViewArg qStringLikeToArg(const QChar &c) noexcept { return QStringViewArg{QStringView{&c, 1}}; } +constexpr inline QLatin1StringArg qStringLikeToArg(QLatin1String s) noexcept { return QLatin1StringArg{s}; } } // namespace QtPrivate diff --git a/src/corelib/text/qstringalgorithms.h b/src/corelib/text/qstringalgorithms.h index c407c54268..28c0760b61 100644 --- a/src/corelib/text/qstringalgorithms.h +++ b/src/corelib/text/qstringalgorithms.h @@ -100,7 +100,7 @@ Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool isRightToLeft(QStringV Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool isAscii(QLatin1String s) noexcept; Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool isAscii(QStringView s) noexcept; -Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline bool isLatin1(QLatin1String s) noexcept; +Q_REQUIRED_RESULT constexpr inline bool isLatin1(QLatin1String s) noexcept; Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool isLatin1(QStringView s) noexcept; Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool isValidUtf16(QStringView s) noexcept; diff --git a/src/corelib/text/qstringbuilder.h b/src/corelib/text/qstringbuilder.h index 512b7e7bf7..da4277f9a8 100644 --- a/src/corelib/text/qstringbuilder.h +++ b/src/corelib/text/qstringbuilder.h @@ -193,7 +193,7 @@ template <> struct QConcatenable<char16_t> : private QAbstractConcatenable typedef char16_t type; typedef QString ConvertTo; enum { ExactSize = true }; - static Q_DECL_CONSTEXPR int size(char16_t) { return 1; } + static constexpr int size(char16_t) { return 1; } static inline void appendTo(char16_t c, QChar *&out) { *out++ = c; } }; diff --git a/src/corelib/text/qstringview.h b/src/corelib/text/qstringview.h index 24cea33e7f..f2e9f876f9 100644 --- a/src/corelib/text/qstringview.h +++ b/src/corelib/text/qstringview.h @@ -170,13 +170,13 @@ private: } template <typename Container> - static Q_DECL_CONSTEXPR qsizetype lengthHelperContainer(const Container &c) noexcept + static constexpr qsizetype lengthHelperContainer(const Container &c) noexcept { return qsizetype(std::size(c)); } template <typename Char, size_t N> - static Q_DECL_CONSTEXPR qsizetype lengthHelperContainer(const Char (&)[N]) noexcept + static constexpr qsizetype lengthHelperContainer(const Char (&)[N]) noexcept { return qsizetype(N - 1); } @@ -184,34 +184,34 @@ private: template <typename Char> static const storage_type *castHelper(const Char *str) noexcept { return reinterpret_cast<const storage_type*>(str); } - static Q_DECL_CONSTEXPR const storage_type *castHelper(const storage_type *str) noexcept + static constexpr const storage_type *castHelper(const storage_type *str) noexcept { return str; } public: - Q_DECL_CONSTEXPR QStringView() noexcept + constexpr QStringView() noexcept : m_size(0), m_data(nullptr) {} - Q_DECL_CONSTEXPR QStringView(std::nullptr_t) noexcept + constexpr QStringView(std::nullptr_t) noexcept : QStringView() {} template <typename Char, if_compatible_char<Char> = true> - Q_DECL_CONSTEXPR QStringView(const Char *str, qsizetype len) + constexpr QStringView(const Char *str, qsizetype len) : m_size((Q_ASSERT(len >= 0), Q_ASSERT(str || !len), len)), m_data(castHelper(str)) {} template <typename Char, if_compatible_char<Char> = true> - Q_DECL_CONSTEXPR QStringView(const Char *f, const Char *l) + constexpr QStringView(const Char *f, const Char *l) : QStringView(f, l - f) {} #ifdef Q_CLANG_QDOC template <typename Char, size_t N> - Q_DECL_CONSTEXPR QStringView(const Char (&array)[N]) noexcept; + constexpr QStringView(const Char (&array)[N]) noexcept; template <typename Char> - Q_DECL_CONSTEXPR QStringView(const Char *str) noexcept; + constexpr QStringView(const Char *str) noexcept; #else template <typename Pointer, if_compatible_pointer<Pointer> = true> - Q_DECL_CONSTEXPR QStringView(const Pointer &str) noexcept + constexpr QStringView(const Pointer &str) noexcept : QStringView(str, str ? lengthHelperPointer(str) : 0) {} #endif @@ -225,7 +225,7 @@ public: #endif template <typename Container, if_compatible_container<Container> = true> - Q_DECL_CONSTEXPR QStringView(const Container &c) noexcept + constexpr QStringView(const Container &c) noexcept : QStringView(std::data(c), lengthHelperContainer(c)) {} Q_REQUIRED_RESULT inline QString toString() const; // defined in qstring.h @@ -235,12 +235,12 @@ public: Q_REQUIRED_RESULT Q_CORE_EXPORT NSString *toNSString() const Q_DECL_NS_RETURNS_AUTORELEASED; #endif - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR qsizetype size() const noexcept { return m_size; } + Q_REQUIRED_RESULT constexpr qsizetype size() const noexcept { return m_size; } Q_REQUIRED_RESULT const_pointer data() const noexcept { return reinterpret_cast<const_pointer>(m_data); } Q_REQUIRED_RESULT const_pointer constData() const noexcept { return data(); } - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR const storage_type *utf16() const noexcept { return m_data; } + Q_REQUIRED_RESULT constexpr const storage_type *utf16() const noexcept { return m_data; } - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QChar operator[](qsizetype n) const + Q_REQUIRED_RESULT constexpr QChar operator[](qsizetype n) const { return Q_ASSERT(n >= 0), Q_ASSERT(n < size()), QChar(m_data[n]); } // @@ -255,7 +255,7 @@ public: Q_REQUIRED_RESULT QByteArray toLocal8Bit() const { return QtPrivate::convertToLocal8Bit(*this); } Q_REQUIRED_RESULT inline QList<uint> toUcs4() const; // defined in qlist.h - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QChar at(qsizetype n) const { return (*this)[n]; } + Q_REQUIRED_RESULT constexpr QChar at(qsizetype n) const { return (*this)[n]; } Q_REQUIRED_RESULT constexpr QStringView mid(qsizetype pos, qsizetype n = -1) const { @@ -284,12 +284,12 @@ public: { Q_ASSERT(pos >= 0); Q_ASSERT(pos <= size()); return QStringView(m_data + pos, size() - pos); } Q_REQUIRED_RESULT constexpr QStringView sliced(qsizetype pos, qsizetype n) const { Q_ASSERT(pos >= 0); Q_ASSERT(n >= 0); Q_ASSERT(size_t(pos) + size_t(n) <= size_t(size())); return QStringView(m_data + pos, n); } - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QStringView chopped(qsizetype n) const + Q_REQUIRED_RESULT constexpr QStringView chopped(qsizetype n) const { return Q_ASSERT(n >= 0), Q_ASSERT(n <= size()), QStringView(m_data, m_size - n); } - Q_DECL_RELAXED_CONSTEXPR void truncate(qsizetype n) + constexpr void truncate(qsizetype n) { Q_ASSERT(n >= 0); Q_ASSERT(n <= size()); m_size = n; } - Q_DECL_RELAXED_CONSTEXPR void chop(qsizetype n) + constexpr void chop(qsizetype n) { Q_ASSERT(n >= 0); Q_ASSERT(n <= size()); m_size -= n; } Q_REQUIRED_RESULT QStringView trimmed() const noexcept { return QtPrivate::trimmed(*this); } @@ -303,7 +303,7 @@ public: Q_REQUIRED_RESULT int compare(QStringView other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept { return QtPrivate::compareStrings(*this, other, cs); } Q_REQUIRED_RESULT inline int compare(QLatin1String other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept; - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR int compare(QChar c) const noexcept + Q_REQUIRED_RESULT constexpr int compare(QChar c) const noexcept { return size() >= 1 ? compare_single_char_helper(*utf16() - c.unicode()) : -1; } Q_REQUIRED_RESULT int compare(QChar c, Qt::CaseSensitivity cs) const noexcept { return QtPrivate::compareStrings(*this, QStringView(&c, 1), cs); } @@ -392,24 +392,24 @@ public: Q_REQUIRED_RESULT const_reverse_iterator crbegin() const noexcept { return rbegin(); } Q_REQUIRED_RESULT const_reverse_iterator crend() const noexcept { return rend(); } - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR bool empty() const noexcept { return size() == 0; } - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QChar front() const { return Q_ASSERT(!empty()), QChar(m_data[0]); } - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QChar back() const { return Q_ASSERT(!empty()), QChar(m_data[m_size - 1]); } + Q_REQUIRED_RESULT constexpr bool empty() const noexcept { return size() == 0; } + Q_REQUIRED_RESULT constexpr QChar front() const { return Q_ASSERT(!empty()), QChar(m_data[0]); } + Q_REQUIRED_RESULT constexpr QChar back() const { return Q_ASSERT(!empty()), QChar(m_data[m_size - 1]); } // // Qt compatibility API: // - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR bool isNull() const noexcept { return !m_data; } - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR bool isEmpty() const noexcept { return empty(); } - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR int length() const /* not nothrow! */ + Q_REQUIRED_RESULT constexpr bool isNull() const noexcept { return !m_data; } + Q_REQUIRED_RESULT constexpr bool isEmpty() const noexcept { return empty(); } + Q_REQUIRED_RESULT constexpr int length() const /* not nothrow! */ { return Q_ASSERT(int(size()) == size()), int(size()); } - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QChar first() const { return front(); } - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QChar last() const { return back(); } + Q_REQUIRED_RESULT constexpr QChar first() const { return front(); } + Q_REQUIRED_RESULT constexpr QChar last() const { return back(); } private: qsizetype m_size; const storage_type *m_data; - Q_DECL_CONSTEXPR int compare_single_char_helper(int diff) const noexcept + constexpr int compare_single_char_helper(int diff) const noexcept { return diff ? diff : size() > 1 ? 1 : 0; } }; Q_DECLARE_TYPEINFO(QStringView, Q_PRIMITIVE_TYPE); |