Replace Q_REQUIRED_RESULT with [[nodiscard]]

It was already used many places directly making the code inconsistent.

Change-Id: I3b14bc6c333640fb3ba33c71eba97e78c973e44b
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
Allan Sandfeld Jensen 2020-09-23 10:09:42 +02:00
parent 31a1b3280c
commit c2be9180b7
40 changed files with 452 additions and 465 deletions

View File

@ -123,20 +123,20 @@ Q_CORE_EXPORT void qFloatToFloat16(qfloat16 *, const float *, qsizetype length)
Q_CORE_EXPORT void qFloatFromFloat16(float *, const qfloat16 *, qsizetype length) noexcept;
// Complement qnumeric.h:
Q_REQUIRED_RESULT inline bool qIsInf(qfloat16 f) noexcept { return f.isInf(); }
Q_REQUIRED_RESULT inline bool qIsNaN(qfloat16 f) noexcept { return f.isNaN(); }
Q_REQUIRED_RESULT inline bool qIsFinite(qfloat16 f) noexcept { return f.isFinite(); }
Q_REQUIRED_RESULT inline int qFpClassify(qfloat16 f) noexcept { return f.fpClassify(); }
// Q_REQUIRED_RESULT quint32 qFloatDistance(qfloat16 a, qfloat16 b);
[[nodiscard]] inline bool qIsInf(qfloat16 f) noexcept { return f.isInf(); }
[[nodiscard]] inline bool qIsNaN(qfloat16 f) noexcept { return f.isNaN(); }
[[nodiscard]] inline bool qIsFinite(qfloat16 f) noexcept { return f.isFinite(); }
[[nodiscard]] inline int qFpClassify(qfloat16 f) noexcept { return f.fpClassify(); }
// [[nodiscard]] quint32 qFloatDistance(qfloat16 a, qfloat16 b);
// The remainder of these utility functions complement qglobal.h
Q_REQUIRED_RESULT inline int qRound(qfloat16 d) noexcept
[[nodiscard]] inline int qRound(qfloat16 d) noexcept
{ return qRound(static_cast<float>(d)); }
Q_REQUIRED_RESULT inline qint64 qRound64(qfloat16 d) noexcept
[[nodiscard]] inline qint64 qRound64(qfloat16 d) noexcept
{ return qRound64(static_cast<float>(d)); }
Q_REQUIRED_RESULT inline bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) noexcept
[[nodiscard]] inline bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) noexcept
{
float f1 = static_cast<float>(p1);
float f2 = static_cast<float>(p2);
@ -149,7 +149,7 @@ Q_REQUIRED_RESULT inline bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) noexcept
return (qAbs(f1 - f2) * 102.5f <= qMin(qAbs(f1), qAbs(f2)));
}
Q_REQUIRED_RESULT inline bool qIsNull(qfloat16 f) noexcept
[[nodiscard]] inline bool qIsNull(qfloat16 f) noexcept
{
return (f.b16 & static_cast<quint16>(0x7fff)) == 0;
}
@ -301,7 +301,7 @@ QT_WARNING_POP
/*!
\internal
*/
Q_REQUIRED_RESULT inline bool qFuzzyIsNull(qfloat16 f) noexcept
[[nodiscard]] inline bool qFuzzyIsNull(qfloat16 f) noexcept
{
return qAbs(static_cast<float>(f)) <= 0.001f;
}

View File

@ -864,22 +864,22 @@ typedef void (*QFunctionPointer)();
# define Q_UNIMPLEMENTED() qWarning("Unimplemented code.")
#endif
Q_REQUIRED_RESULT Q_DECL_UNUSED constexpr static inline bool qFuzzyCompare(double p1, double p2)
[[nodiscard]] Q_DECL_UNUSED constexpr static inline bool qFuzzyCompare(double p1, double p2)
{
return (qAbs(p1 - p2) * 1000000000000. <= qMin(qAbs(p1), qAbs(p2)));
}
Q_REQUIRED_RESULT Q_DECL_UNUSED constexpr static inline bool qFuzzyCompare(float p1, float p2)
[[nodiscard]] Q_DECL_UNUSED constexpr static inline bool qFuzzyCompare(float p1, float p2)
{
return (qAbs(p1 - p2) * 100000.f <= qMin(qAbs(p1), qAbs(p2)));
}
Q_REQUIRED_RESULT Q_DECL_UNUSED constexpr static inline bool qFuzzyIsNull(double d)
[[nodiscard]] Q_DECL_UNUSED constexpr static inline bool qFuzzyIsNull(double d)
{
return qAbs(d) <= 0.000000000001;
}
Q_REQUIRED_RESULT Q_DECL_UNUSED constexpr static inline bool qFuzzyIsNull(float f)
[[nodiscard]] Q_DECL_UNUSED constexpr static inline bool qFuzzyIsNull(float f)
{
return qAbs(f) <= 0.00001f;
}
@ -887,12 +887,12 @@ Q_REQUIRED_RESULT Q_DECL_UNUSED constexpr static inline bool qFuzzyIsNull(float
QT_WARNING_PUSH
QT_WARNING_DISABLE_FLOAT_COMPARE
Q_REQUIRED_RESULT Q_DECL_UNUSED constexpr static inline bool qIsNull(double d) noexcept
[[nodiscard]] Q_DECL_UNUSED constexpr static inline bool qIsNull(double d) noexcept
{
return d == 0.0;
}
Q_REQUIRED_RESULT Q_DECL_UNUSED constexpr static inline bool qIsNull(float f) noexcept
[[nodiscard]] Q_DECL_UNUSED constexpr static inline bool qIsNull(float f) noexcept
{
return f == 0.0f;
}

View File

@ -194,7 +194,7 @@ public:
QString url(FormattingOptions options = FormattingOptions(PrettyDecoded)) const;
QString toString(FormattingOptions options = FormattingOptions(PrettyDecoded)) const;
QString toDisplayString(FormattingOptions options = FormattingOptions(PrettyDecoded)) const;
Q_REQUIRED_RESULT QUrl adjusted(FormattingOptions options) const;
[[nodiscard]] QUrl adjusted(FormattingOptions options) const;
QByteArray toEncoded(FormattingOptions options = FullyEncoded) const;
static QUrl fromEncoded(const QByteArray &url, ParsingMode mode = TolerantMode);
@ -248,7 +248,7 @@ public:
QString fragment(ComponentFormattingOptions options = PrettyDecoded) const;
void setFragment(const QString &fragment, ParsingMode mode = TolerantMode);
Q_REQUIRED_RESULT QUrl resolved(const QUrl &relative) const;
[[nodiscard]] QUrl resolved(const QUrl &relative) const;
bool isRelative() const;
bool isParentOf(const QUrl &url) const;

View File

@ -359,7 +359,7 @@ public:
Q_ENUM(CheckIndexOption)
Q_DECLARE_FLAGS(CheckIndexOptions, CheckIndexOption)
Q_REQUIRED_RESULT bool checkIndex(const QModelIndex &index, CheckIndexOptions options = CheckIndexOption::NoOption) const;
[[nodiscard]] bool checkIndex(const QModelIndex &index, CheckIndexOptions options = CheckIndexOption::NoOption) const;
virtual void multiData(const QModelIndex &index, QModelRoleDataSpan roleDataSpan) const;

View File

@ -51,7 +51,7 @@ namespace QTest {
Q_CORE_EXPORT void qSleep(int ms);
template <typename Functor>
Q_REQUIRED_RESULT static bool qWaitFor(Functor predicate, int timeout = 5000)
[[nodiscard]] static bool qWaitFor(Functor predicate, int timeout = 5000)
{
// We should not spin the event loop in case the predicate is already true,
// otherwise we might send new events that invalidate the predicate.

View File

@ -66,17 +66,17 @@ public:
QString language() const;
QString filePath() const;
Q_REQUIRED_RESULT bool load(const QString & filename,
const QString & directory = QString(),
const QString & search_delimiters = QString(),
const QString & suffix = QString());
Q_REQUIRED_RESULT bool load(const QLocale & locale,
const QString & filename,
const QString & prefix = QString(),
const QString & directory = QString(),
const QString & suffix = QString());
Q_REQUIRED_RESULT bool load(const uchar *data, int len,
const QString &directory = QString());
[[nodiscard]] bool load(const QString & filename,
const QString & directory = QString(),
const QString & search_delimiters = QString(),
const QString & suffix = QString());
[[nodiscard]] bool load(const QLocale & locale,
const QString & filename,
const QString & prefix = QString(),
const QString & directory = QString(),
const QString & suffix = QString());
[[nodiscard]] bool load(const uchar *data, int len,
const QString &directory = QString());
private:
Q_DISABLE_COPY(QTranslator)

View File

@ -199,11 +199,11 @@ public:
inline char at(qsizetype i) const;
inline char operator[](qsizetype i) const;
Q_REQUIRED_RESULT inline char &operator[](qsizetype i);
Q_REQUIRED_RESULT char front() const { return at(0); }
Q_REQUIRED_RESULT inline char &front();
Q_REQUIRED_RESULT char back() const { return at(size() - 1); }
Q_REQUIRED_RESULT inline char &back();
[[nodiscard]] inline char &operator[](qsizetype i);
[[nodiscard]] char front() const { return at(0); }
[[nodiscard]] inline char &front();
[[nodiscard]] char back() const { return at(size() - 1); }
[[nodiscard]] inline char &back();
qsizetype indexOf(char c, qsizetype from = 0) const;
qsizetype indexOf(QByteArrayView bv, qsizetype from = 0) const
@ -221,19 +221,19 @@ public:
inline int compare(QByteArrayView a, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept;
Q_REQUIRED_RESULT QByteArray left(qsizetype len) const;
Q_REQUIRED_RESULT QByteArray right(qsizetype len) const;
Q_REQUIRED_RESULT QByteArray mid(qsizetype index, qsizetype len = -1) const;
[[nodiscard]] QByteArray left(qsizetype len) const;
[[nodiscard]] QByteArray right(qsizetype len) const;
[[nodiscard]] QByteArray mid(qsizetype index, qsizetype len = -1) const;
Q_REQUIRED_RESULT QByteArray first(qsizetype n) const
[[nodiscard]] QByteArray first(qsizetype n) const
{ Q_ASSERT(n >= 0); Q_ASSERT(n <= size()); return QByteArray(data(), n); }
Q_REQUIRED_RESULT QByteArray last(qsizetype n) const
[[nodiscard]] QByteArray last(qsizetype n) const
{ Q_ASSERT(n >= 0); Q_ASSERT(n <= size()); return QByteArray(data() + size() - n, n); }
Q_REQUIRED_RESULT QByteArray sliced(qsizetype pos) const
[[nodiscard]] QByteArray sliced(qsizetype pos) const
{ Q_ASSERT(pos >= 0); Q_ASSERT(pos <= size()); return QByteArray(data() + pos, size() - pos); }
Q_REQUIRED_RESULT QByteArray sliced(qsizetype pos, qsizetype n) const
[[nodiscard]] QByteArray 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 QByteArray(data() + pos, n); }
Q_REQUIRED_RESULT QByteArray chopped(qsizetype len) const
[[nodiscard]] QByteArray chopped(qsizetype len) const
{ Q_ASSERT(len >= 0); Q_ASSERT(len <= size()); return first(size() - len); }
bool startsWith(QByteArrayView bv) const
@ -251,31 +251,31 @@ public:
void chop(qsizetype n);
#if !defined(Q_CLANG_QDOC)
Q_REQUIRED_RESULT QByteArray toLower() const &
[[nodiscard]] QByteArray toLower() const &
{ return toLower_helper(*this); }
Q_REQUIRED_RESULT QByteArray toLower() &&
[[nodiscard]] QByteArray toLower() &&
{ return toLower_helper(*this); }
Q_REQUIRED_RESULT QByteArray toUpper() const &
[[nodiscard]] QByteArray toUpper() const &
{ return toUpper_helper(*this); }
Q_REQUIRED_RESULT QByteArray toUpper() &&
[[nodiscard]] QByteArray toUpper() &&
{ return toUpper_helper(*this); }
Q_REQUIRED_RESULT QByteArray trimmed() const &
[[nodiscard]] QByteArray trimmed() const &
{ return trimmed_helper(*this); }
Q_REQUIRED_RESULT QByteArray trimmed() &&
[[nodiscard]] QByteArray trimmed() &&
{ return trimmed_helper(*this); }
Q_REQUIRED_RESULT QByteArray simplified() const &
[[nodiscard]] QByteArray simplified() const &
{ return simplified_helper(*this); }
Q_REQUIRED_RESULT QByteArray simplified() &&
[[nodiscard]] QByteArray simplified() &&
{ return simplified_helper(*this); }
#else
Q_REQUIRED_RESULT QByteArray toLower() const;
Q_REQUIRED_RESULT QByteArray toUpper() const;
Q_REQUIRED_RESULT QByteArray trimmed() const;
Q_REQUIRED_RESULT QByteArray simplified() const;
[[nodiscard]] QByteArray toLower() const;
[[nodiscard]] QByteArray toUpper() const;
[[nodiscard]] QByteArray trimmed() const;
[[nodiscard]] QByteArray simplified() const;
#endif
Q_REQUIRED_RESULT QByteArray leftJustified(qsizetype width, char fill = ' ', bool truncate = false) const;
Q_REQUIRED_RESULT QByteArray rightJustified(qsizetype width, char fill = ' ', bool truncate = false) const;
[[nodiscard]] QByteArray leftJustified(qsizetype width, char fill = ' ', bool truncate = false) const;
[[nodiscard]] QByteArray rightJustified(qsizetype width, char fill = ' ', bool truncate = false) const;
QByteArray &prepend(char c)
{ return insert(0, QByteArrayView(&c, 1)); }
@ -329,7 +329,7 @@ public:
QList<QByteArray> split(char sep) const;
Q_REQUIRED_RESULT QByteArray repeated(qsizetype times) const;
[[nodiscard]] QByteArray repeated(qsizetype times) const;
#if !defined(QT_NO_CAST_FROM_ASCII) && !defined(QT_RESTRICTED_CAST_FROM_ASCII)
inline QT_ASCII_CAST_WARN bool operator==(const QString &s2) const;
@ -368,24 +368,24 @@ public:
QByteArray &setNum(double, char f = 'g', int prec = 6);
QByteArray &setRawData(const char *a, qsizetype n);
Q_REQUIRED_RESULT static QByteArray number(int, int base = 10);
Q_REQUIRED_RESULT static QByteArray number(uint, int base = 10);
Q_REQUIRED_RESULT static QByteArray number(long, int base = 10);
Q_REQUIRED_RESULT static QByteArray number(ulong, int base = 10);
Q_REQUIRED_RESULT static QByteArray number(qlonglong, int base = 10);
Q_REQUIRED_RESULT static QByteArray number(qulonglong, int base = 10);
Q_REQUIRED_RESULT static QByteArray number(double, char f = 'g', int prec = 6);
Q_REQUIRED_RESULT static QByteArray fromRawData(const char *data, qsizetype size)
[[nodiscard]] static QByteArray number(int, int base = 10);
[[nodiscard]] static QByteArray number(uint, int base = 10);
[[nodiscard]] static QByteArray number(long, int base = 10);
[[nodiscard]] static QByteArray number(ulong, int base = 10);
[[nodiscard]] static QByteArray number(qlonglong, int base = 10);
[[nodiscard]] static QByteArray number(qulonglong, int base = 10);
[[nodiscard]] static QByteArray number(double, char f = 'g', int prec = 6);
[[nodiscard]] static QByteArray fromRawData(const char *data, qsizetype size)
{
return QByteArray(DataPointer(nullptr, const_cast<char *>(data), size));
}
class FromBase64Result;
Q_REQUIRED_RESULT static FromBase64Result fromBase64Encoding(QByteArray &&base64, Base64Options options = Base64Encoding);
Q_REQUIRED_RESULT static FromBase64Result fromBase64Encoding(const QByteArray &base64, Base64Options options = Base64Encoding);
Q_REQUIRED_RESULT static QByteArray fromBase64(const QByteArray &base64, Base64Options options = Base64Encoding);
Q_REQUIRED_RESULT static QByteArray fromHex(const QByteArray &hexEncoded);
Q_REQUIRED_RESULT static QByteArray fromPercentEncoding(const QByteArray &pctEncoded, char percent = '%');
[[nodiscard]] static FromBase64Result fromBase64Encoding(QByteArray &&base64, Base64Options options = Base64Encoding);
[[nodiscard]] static FromBase64Result fromBase64Encoding(const QByteArray &base64, Base64Options options = Base64Encoding);
[[nodiscard]] static QByteArray fromBase64(const QByteArray &base64, Base64Options options = Base64Encoding);
[[nodiscard]] static QByteArray fromHex(const QByteArray &hexEncoded);
[[nodiscard]] static QByteArray fromPercentEncoding(const QByteArray &pctEncoded, char percent = '%');
#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
static QByteArray fromCFData(CFDataRef data);

View File

@ -100,40 +100,40 @@ public:
constexpr bool isEmpty() const noexcept { return !size(); }
template <typename...Args>
Q_REQUIRED_RESULT inline QString arg(Args &&...args) const;
[[nodiscard]] inline QString arg(Args &&...args) const;
[[nodiscard]] constexpr QLatin1Char at(qsizetype i) const
{ return Q_ASSERT(i >= 0), Q_ASSERT(i < size()), QLatin1Char(m_data[i]); }
[[nodiscard]] constexpr QLatin1Char operator[](qsizetype i) const { return at(i); }
Q_REQUIRED_RESULT constexpr QLatin1Char front() const { return at(0); }
Q_REQUIRED_RESULT constexpr QLatin1Char back() const { return at(size() - 1); }
[[nodiscard]] constexpr QLatin1Char front() const { return at(0); }
[[nodiscard]] constexpr QLatin1Char back() const { return at(size() - 1); }
Q_REQUIRED_RESULT int compare(QStringView other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
[[nodiscard]] 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
[[nodiscard]] int compare(QLatin1String other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ return QtPrivate::compareStrings(*this, other, cs); }
Q_REQUIRED_RESULT constexpr int compare(QChar c) const noexcept
[[nodiscard]] 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
[[nodiscard]] int compare(QChar c, Qt::CaseSensitivity cs) const noexcept
{ return QtPrivate::compareStrings(*this, QStringView(&c, 1), cs); }
Q_REQUIRED_RESULT bool startsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
[[nodiscard]] bool startsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ return QtPrivate::startsWith(*this, s, cs); }
Q_REQUIRED_RESULT bool startsWith(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
[[nodiscard]] bool startsWith(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ return QtPrivate::startsWith(*this, s, cs); }
Q_REQUIRED_RESULT constexpr bool startsWith(QChar c) const noexcept
[[nodiscard]] constexpr bool startsWith(QChar c) const noexcept
{ return !isEmpty() && front() == c; }
Q_REQUIRED_RESULT inline bool startsWith(QChar c, Qt::CaseSensitivity cs) const noexcept
[[nodiscard]] inline bool startsWith(QChar c, Qt::CaseSensitivity cs) const noexcept
{ return QtPrivate::startsWith(*this, QStringView(&c, 1), cs); }
Q_REQUIRED_RESULT bool endsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
[[nodiscard]] bool endsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ return QtPrivate::endsWith(*this, s, cs); }
Q_REQUIRED_RESULT bool endsWith(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
[[nodiscard]] bool endsWith(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ return QtPrivate::endsWith(*this, s, cs); }
Q_REQUIRED_RESULT constexpr bool endsWith(QChar c) const noexcept
[[nodiscard]] constexpr bool endsWith(QChar c) const noexcept
{ return !isEmpty() && back() == c; }
Q_REQUIRED_RESULT inline bool endsWith(QChar c, Qt::CaseSensitivity cs) const noexcept
[[nodiscard]] inline bool endsWith(QChar c, Qt::CaseSensitivity cs) const noexcept
{ return QtPrivate::endsWith(*this, QStringView(&c, 1), cs); }
[[nodiscard]] qsizetype indexOf(QStringView s, qsizetype from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
@ -143,11 +143,11 @@ public:
[[nodiscard]] qsizetype indexOf(QChar c, qsizetype from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ return QtPrivate::findString(*this, from, QStringView(&c, 1), cs); }
Q_REQUIRED_RESULT bool contains(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
[[nodiscard]] bool contains(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ return indexOf(s, 0, cs) != -1; }
Q_REQUIRED_RESULT bool contains(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
[[nodiscard]] bool contains(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ return indexOf(s, 0, cs) != -1; }
Q_REQUIRED_RESULT inline bool contains(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
[[nodiscard]] inline bool contains(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ return indexOf(QStringView(&c, 1), 0, cs) != -1; }
[[nodiscard]] qsizetype lastIndexOf(QStringView s, qsizetype from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
@ -213,10 +213,10 @@ public:
constexpr void truncate(qsizetype n)
{ verify(n); m_size = n; }
Q_REQUIRED_RESULT QLatin1String trimmed() const noexcept { return QtPrivate::trimmed(*this); }
[[nodiscard]] QLatin1String trimmed() const noexcept { return QtPrivate::trimmed(*this); }
template <typename Needle, typename...Flags>
Q_REQUIRED_RESULT inline constexpr auto tokenize(Needle &&needle, Flags...flags) const
[[nodiscard]] inline constexpr auto tokenize(Needle &&needle, Flags...flags) const
noexcept(noexcept(qTokenize(std::declval<const QLatin1String &>(), std::forward<Needle>(needle), flags...)))
-> decltype(qTokenize(*this, std::forward<Needle>(needle), flags...))
{ return qTokenize(*this, std::forward<Needle>(needle), flags...); }
@ -367,42 +367,42 @@ public:
inline const QChar at(qsizetype i) const;
const QChar operator[](qsizetype i) const;
Q_REQUIRED_RESULT QChar &operator[](qsizetype i);
[[nodiscard]] QChar &operator[](qsizetype i);
Q_REQUIRED_RESULT inline QChar front() const { return at(0); }
Q_REQUIRED_RESULT inline QChar &front();
Q_REQUIRED_RESULT inline QChar back() const { return at(size() - 1); }
Q_REQUIRED_RESULT inline QChar &back();
[[nodiscard]] inline QChar front() const { return at(0); }
[[nodiscard]] inline QChar &front();
[[nodiscard]] inline QChar back() const { return at(size() - 1); }
[[nodiscard]] inline QChar &back();
Q_REQUIRED_RESULT QString arg(qlonglong a, int fieldwidth=0, int base=10,
[[nodiscard]] QString arg(qlonglong a, int fieldwidth=0, int base=10,
QChar fillChar = QLatin1Char(' ')) const;
Q_REQUIRED_RESULT QString arg(qulonglong a, int fieldwidth=0, int base=10,
[[nodiscard]] QString arg(qulonglong a, int fieldwidth=0, int base=10,
QChar fillChar = QLatin1Char(' ')) const;
Q_REQUIRED_RESULT QString arg(long a, int fieldwidth=0, int base=10,
[[nodiscard]] QString arg(long a, int fieldwidth=0, int base=10,
QChar fillChar = QLatin1Char(' ')) const;
Q_REQUIRED_RESULT QString arg(ulong a, int fieldwidth=0, int base=10,
[[nodiscard]] QString arg(ulong a, int fieldwidth=0, int base=10,
QChar fillChar = QLatin1Char(' ')) const;
Q_REQUIRED_RESULT QString arg(int a, int fieldWidth = 0, int base = 10,
[[nodiscard]] QString arg(int a, int fieldWidth = 0, int base = 10,
QChar fillChar = QLatin1Char(' ')) const;
Q_REQUIRED_RESULT QString arg(uint a, int fieldWidth = 0, int base = 10,
[[nodiscard]] QString arg(uint a, int fieldWidth = 0, int base = 10,
QChar fillChar = QLatin1Char(' ')) const;
Q_REQUIRED_RESULT QString arg(short a, int fieldWidth = 0, int base = 10,
[[nodiscard]] QString arg(short a, int fieldWidth = 0, int base = 10,
QChar fillChar = QLatin1Char(' ')) const;
Q_REQUIRED_RESULT QString arg(ushort a, int fieldWidth = 0, int base = 10,
[[nodiscard]] QString arg(ushort a, int fieldWidth = 0, int base = 10,
QChar fillChar = QLatin1Char(' ')) const;
Q_REQUIRED_RESULT QString arg(double a, int fieldWidth = 0, char fmt = 'g', int prec = -1,
[[nodiscard]] QString arg(double a, int fieldWidth = 0, char fmt = 'g', int prec = -1,
QChar fillChar = QLatin1Char(' ')) const;
Q_REQUIRED_RESULT QString arg(char a, int fieldWidth = 0,
[[nodiscard]] QString arg(char a, int fieldWidth = 0,
QChar fillChar = QLatin1Char(' ')) const;
Q_REQUIRED_RESULT QString arg(QChar a, int fieldWidth = 0,
[[nodiscard]] QString arg(QChar a, int fieldWidth = 0,
QChar fillChar = QLatin1Char(' ')) const;
#if QT_STRINGVIEW_LEVEL < 2
Q_REQUIRED_RESULT QString arg(const QString &a, int fieldWidth = 0,
[[nodiscard]] QString arg(const QString &a, int fieldWidth = 0,
QChar fillChar = QLatin1Char(' ')) const;
#endif
Q_REQUIRED_RESULT QString arg(QStringView a, int fieldWidth = 0,
[[nodiscard]] QString arg(QStringView a, int fieldWidth = 0,
QChar fillChar = QLatin1Char(' ')) const;
Q_REQUIRED_RESULT QString arg(QLatin1String a, int fieldWidth = 0,
[[nodiscard]] QString arg(QLatin1String a, int fieldWidth = 0,
QChar fillChar = QLatin1Char(' ')) const;
private:
template <typename T>
@ -416,7 +416,7 @@ private:
: is_convertible_to_view_or_qstring_helper<typename std::decay<T>::type> {};
public:
template <typename...Args>
Q_REQUIRED_RESULT
[[nodiscard]]
#ifdef Q_CLANG_QDOC
QString
#else
@ -439,7 +439,7 @@ public:
#if QT_STRINGVIEW_LEVEL < 2
qsizetype indexOf(const QString &s, qsizetype from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
#endif
Q_REQUIRED_RESULT qsizetype indexOf(QStringView s, qsizetype from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
[[nodiscard]] qsizetype indexOf(QStringView s, qsizetype from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ return QtPrivate::findString(*this, from, s, cs); }
qsizetype lastIndexOf(QChar c, qsizetype from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
qsizetype lastIndexOf(QLatin1String s, qsizetype from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
@ -447,7 +447,7 @@ public:
qsizetype lastIndexOf(const QString &s, qsizetype from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
#endif
Q_REQUIRED_RESULT qsizetype lastIndexOf(QStringView s, qsizetype from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
[[nodiscard]] qsizetype lastIndexOf(QStringView s, qsizetype from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ return QtPrivate::lastIndexOf(*this, from, s, cs); }
inline bool contains(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
@ -483,26 +483,26 @@ public:
#if QT_CONFIG(regularexpression)
QString section(const QRegularExpression &re, qsizetype start, qsizetype end = -1, SectionFlags flags = SectionDefault) const;
#endif
Q_REQUIRED_RESULT QString left(qsizetype n) const;
Q_REQUIRED_RESULT QString right(qsizetype n) const;
Q_REQUIRED_RESULT QString mid(qsizetype position, qsizetype n = -1) const;
[[nodiscard]] QString left(qsizetype n) const;
[[nodiscard]] QString right(qsizetype n) const;
[[nodiscard]] QString mid(qsizetype position, qsizetype n = -1) const;
Q_REQUIRED_RESULT QString first(qsizetype n) const
[[nodiscard]] QString first(qsizetype n) const
{ Q_ASSERT(n >= 0); Q_ASSERT(n <= size()); return QString(data(), n); }
Q_REQUIRED_RESULT QString last(qsizetype n) const
[[nodiscard]] QString last(qsizetype n) const
{ Q_ASSERT(n >= 0); Q_ASSERT(n <= size()); return QString(data() + size() - n, n); }
Q_REQUIRED_RESULT QString sliced(qsizetype pos) const
[[nodiscard]] QString sliced(qsizetype pos) const
{ Q_ASSERT(pos >= 0); Q_ASSERT(pos <= size()); return QString(data() + pos, size() - pos); }
Q_REQUIRED_RESULT QString sliced(qsizetype pos, qsizetype n) const
[[nodiscard]] QString 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 QString(data() + pos, n); }
Q_REQUIRED_RESULT QString chopped(qsizetype n) const
[[nodiscard]] QString chopped(qsizetype n) const
{ Q_ASSERT(n >= 0); Q_ASSERT(n <= size()); return first(size() - n); }
#if QT_STRINGVIEW_LEVEL < 2
bool startsWith(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
#endif
Q_REQUIRED_RESULT bool startsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
[[nodiscard]] bool startsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ return QtPrivate::startsWith(*this, s, cs); }
bool startsWith(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
bool startsWith(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
@ -510,7 +510,7 @@ public:
#if QT_STRINGVIEW_LEVEL < 2
bool endsWith(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
#endif
Q_REQUIRED_RESULT bool endsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
[[nodiscard]] bool endsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ return QtPrivate::endsWith(*this, s, cs); }
bool endsWith(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
bool endsWith(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
@ -518,38 +518,38 @@ public:
bool isUpper() const;
bool isLower() const;
Q_REQUIRED_RESULT QString leftJustified(qsizetype width, QChar fill = QLatin1Char(' '), bool trunc = false) const;
Q_REQUIRED_RESULT QString rightJustified(qsizetype width, QChar fill = QLatin1Char(' '), bool trunc = false) const;
[[nodiscard]] QString leftJustified(qsizetype width, QChar fill = QLatin1Char(' '), bool trunc = false) const;
[[nodiscard]] QString rightJustified(qsizetype width, QChar fill = QLatin1Char(' '), bool trunc = false) const;
#if !defined(Q_CLANG_QDOC)
Q_REQUIRED_RESULT QString toLower() const &
[[nodiscard]] QString toLower() const &
{ return toLower_helper(*this); }
Q_REQUIRED_RESULT QString toLower() &&
[[nodiscard]] QString toLower() &&
{ return toLower_helper(*this); }
Q_REQUIRED_RESULT QString toUpper() const &
[[nodiscard]] QString toUpper() const &
{ return toUpper_helper(*this); }
Q_REQUIRED_RESULT QString toUpper() &&
[[nodiscard]] QString toUpper() &&
{ return toUpper_helper(*this); }
Q_REQUIRED_RESULT QString toCaseFolded() const &
[[nodiscard]] QString toCaseFolded() const &
{ return toCaseFolded_helper(*this); }
Q_REQUIRED_RESULT QString toCaseFolded() &&
[[nodiscard]] QString toCaseFolded() &&
{ return toCaseFolded_helper(*this); }
Q_REQUIRED_RESULT QString trimmed() const &
[[nodiscard]] QString trimmed() const &
{ return trimmed_helper(*this); }
Q_REQUIRED_RESULT QString trimmed() &&
[[nodiscard]] QString trimmed() &&
{ return trimmed_helper(*this); }
Q_REQUIRED_RESULT QString simplified() const &
[[nodiscard]] QString simplified() const &
{ return simplified_helper(*this); }
Q_REQUIRED_RESULT QString simplified() &&
[[nodiscard]] QString simplified() &&
{ return simplified_helper(*this); }
#else
Q_REQUIRED_RESULT QString toLower() const;
Q_REQUIRED_RESULT QString toUpper() const;
Q_REQUIRED_RESULT QString toCaseFolded() const;
Q_REQUIRED_RESULT QString trimmed() const;
Q_REQUIRED_RESULT QString simplified() const;
[[nodiscard]] QString toLower() const;
[[nodiscard]] QString toUpper() const;
[[nodiscard]] QString toCaseFolded() const;
[[nodiscard]] QString trimmed() const;
[[nodiscard]] QString simplified() const;
#endif
Q_REQUIRED_RESULT QString toHtmlEscaped() const;
[[nodiscard]] QString toHtmlEscaped() const;
QString &insert(qsizetype i, QChar c);
QString &insert(qsizetype i, const QChar *uc, qsizetype len);
@ -606,32 +606,32 @@ public:
#endif
public:
Q_REQUIRED_RESULT
[[nodiscard]]
QStringList split(const QString &sep, Qt::SplitBehavior behavior = Qt::KeepEmptyParts,
Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
Q_REQUIRED_RESULT
[[nodiscard]]
QStringList split(QChar sep, Qt::SplitBehavior behavior = Qt::KeepEmptyParts,
Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
#ifndef QT_NO_REGULAREXPRESSION
Q_REQUIRED_RESULT
[[nodiscard]]
QStringList split(const QRegularExpression &sep,
Qt::SplitBehavior behavior = Qt::KeepEmptyParts) const;
#endif
template <typename Needle, typename...Flags>
Q_REQUIRED_RESULT inline auto tokenize(Needle &&needle, Flags...flags) const &
[[nodiscard]] inline auto tokenize(Needle &&needle, Flags...flags) const &
noexcept(noexcept(qTokenize(std::declval<const QString &>(), std::forward<Needle>(needle), flags...)))
-> decltype(qTokenize(*this, std::forward<Needle>(needle), flags...))
{ return qTokenize(qToStringViewIgnoringNull(*this), std::forward<Needle>(needle), flags...); }
template <typename Needle, typename...Flags>
Q_REQUIRED_RESULT inline auto tokenize(Needle &&needle, Flags...flags) const &&
[[nodiscard]] inline auto tokenize(Needle &&needle, Flags...flags) const &&
noexcept(noexcept(qTokenize(std::declval<const QString>(), std::forward<Needle>(needle), flags...)))
-> decltype(qTokenize(std::move(*this), std::forward<Needle>(needle), flags...))
{ return qTokenize(std::move(*this), std::forward<Needle>(needle), flags...); }
template <typename Needle, typename...Flags>
Q_REQUIRED_RESULT inline auto tokenize(Needle &&needle, Flags...flags) &&
[[nodiscard]] inline auto tokenize(Needle &&needle, Flags...flags) &&
noexcept(noexcept(qTokenize(std::declval<QString>(), std::forward<Needle>(needle), flags...)))
-> decltype(qTokenize(std::move(*this), std::forward<Needle>(needle), flags...))
{ return qTokenize(std::move(*this), std::forward<Needle>(needle), flags...); }
@ -643,31 +643,31 @@ public:
NormalizationForm_KD,
NormalizationForm_KC
};
Q_REQUIRED_RESULT QString normalized(NormalizationForm mode, QChar::UnicodeVersion version = QChar::Unicode_Unassigned) const;
[[nodiscard]] QString normalized(NormalizationForm mode, QChar::UnicodeVersion version = QChar::Unicode_Unassigned) const;
Q_REQUIRED_RESULT QString repeated(qsizetype times) const;
[[nodiscard]] QString repeated(qsizetype times) const;
const ushort *utf16() const;
#if defined(Q_COMPILER_REF_QUALIFIERS) && !defined(QT_COMPILING_QSTRING_COMPAT_CPP) && !defined(Q_CLANG_QDOC)
Q_REQUIRED_RESULT QByteArray toLatin1() const &
[[nodiscard]] QByteArray toLatin1() const &
{ return toLatin1_helper(*this); }
Q_REQUIRED_RESULT QByteArray toLatin1() &&
[[nodiscard]] QByteArray toLatin1() &&
{ return toLatin1_helper_inplace(*this); }
Q_REQUIRED_RESULT QByteArray toUtf8() const &
[[nodiscard]] QByteArray toUtf8() const &
{ return toUtf8_helper(*this); }
Q_REQUIRED_RESULT QByteArray toUtf8() &&
[[nodiscard]] QByteArray toUtf8() &&
{ return toUtf8_helper(*this); }
Q_REQUIRED_RESULT QByteArray toLocal8Bit() const &
[[nodiscard]] QByteArray toLocal8Bit() const &
{ return toLocal8Bit_helper(isNull() ? nullptr : constData(), size()); }
Q_REQUIRED_RESULT QByteArray toLocal8Bit() &&
[[nodiscard]] QByteArray toLocal8Bit() &&
{ return toLocal8Bit_helper(isNull() ? nullptr : constData(), size()); }
#else
Q_REQUIRED_RESULT QByteArray toLatin1() const;
Q_REQUIRED_RESULT QByteArray toUtf8() const;
Q_REQUIRED_RESULT QByteArray toLocal8Bit() const;
[[nodiscard]] QByteArray toLatin1() const;
[[nodiscard]] QByteArray toUtf8() const;
[[nodiscard]] QByteArray toLocal8Bit() const;
#endif
Q_REQUIRED_RESULT QList<uint> toUcs4() const;
[[nodiscard]] QList<uint> toUcs4() const;
// note - this are all inline so we can benefit from strlen() compile time optimizations
static inline QString fromLatin1(const char *str, qsizetype size = -1)
@ -707,7 +707,7 @@ public:
#endif
inline qsizetype toWCharArray(wchar_t *array) const;
Q_REQUIRED_RESULT static inline QString fromWCharArray(const wchar_t *string, qsizetype size = -1);
[[nodiscard]] static inline QString fromWCharArray(const wchar_t *string, qsizetype size = -1);
QString &setRawData(const QChar *unicode, qsizetype size);
QString &setUnicode(const QChar *unicode, qsizetype size);
@ -916,7 +916,7 @@ public:
bool isSimpleText() const;
bool isRightToLeft() const;
Q_REQUIRED_RESULT bool isValidUtf16() const noexcept
[[nodiscard]] bool isValidUtf16() const noexcept
{ return QStringView(*this).isValidUtf16(); }
QString(qsizetype size, Qt::Initialization);
@ -1512,11 +1512,11 @@ struct QLatin1StringArg : ArgBase {
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);
Q_REQUIRED_RESULT Q_CORE_EXPORT QString argToQString(QLatin1String pattern, size_t n, const ArgBase **args);
[[nodiscard]] Q_CORE_EXPORT QString argToQString(QStringView pattern, size_t n, const ArgBase **args);
[[nodiscard]] Q_CORE_EXPORT QString argToQString(QLatin1String pattern, size_t n, const ArgBase **args);
template <typename StringView, typename...Args>
Q_REQUIRED_RESULT Q_ALWAYS_INLINE QString argToQStringDispatch(StringView pattern, const Args &...args)
[[nodiscard]] Q_ALWAYS_INLINE QString argToQStringDispatch(StringView pattern, const Args &...args)
{
const ArgBase *argBases[] = {&args..., /* avoid zero-sized array */ nullptr};
return QtPrivate::argToQString(pattern, sizeof...(Args), argBases);

View File

@ -73,59 +73,59 @@ class QChar;
namespace QtPrivate {
Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype qustrlen(const char16_t *str) noexcept;
Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION const char16_t *qustrchr(QStringView str, char16_t ch) noexcept;
[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype qustrlen(const char16_t *str) noexcept;
[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION const char16_t *qustrchr(QStringView str, char16_t ch) noexcept;
Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QStringView lhs, QStringView rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QStringView lhs, QLatin1String rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QStringView lhs, QBasicUtf8StringView<false> rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QLatin1String lhs, QStringView rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QLatin1String lhs, QLatin1String rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QLatin1String lhs, QBasicUtf8StringView<false> rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QBasicUtf8StringView<false> lhs, QStringView rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QBasicUtf8StringView<false> lhs, QLatin1String rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QBasicUtf8StringView<false> lhs, QBasicUtf8StringView<false> rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QStringView lhs, QStringView rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QStringView lhs, QLatin1String rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QStringView lhs, QBasicUtf8StringView<false> rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QLatin1String lhs, QStringView rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QLatin1String lhs, QLatin1String rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QLatin1String lhs, QBasicUtf8StringView<false> rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QBasicUtf8StringView<false> lhs, QStringView rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QBasicUtf8StringView<false> lhs, QLatin1String rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QBasicUtf8StringView<false> lhs, QBasicUtf8StringView<false> rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool startsWith(QStringView haystack, QStringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool startsWith(QStringView haystack, QLatin1String needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool startsWith(QLatin1String haystack, QStringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool startsWith(QLatin1String haystack, QLatin1String needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool startsWith(QStringView haystack, QStringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool startsWith(QStringView haystack, QLatin1String needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool startsWith(QLatin1String haystack, QStringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool startsWith(QLatin1String haystack, QLatin1String needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool endsWith(QStringView haystack, QStringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool endsWith(QStringView haystack, QLatin1String needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool endsWith(QLatin1String haystack, QStringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool endsWith(QLatin1String haystack, QLatin1String needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool endsWith(QStringView haystack, QStringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool endsWith(QStringView haystack, QLatin1String needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool endsWith(QLatin1String haystack, QStringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool endsWith(QLatin1String haystack, QLatin1String needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype findString(QStringView haystack, qsizetype from, QStringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype findString(QStringView haystack, qsizetype from, QLatin1String needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype findString(QLatin1String haystack, qsizetype from, QStringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype findString(QLatin1String haystack, qsizetype from, QLatin1String needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype findString(QStringView haystack, qsizetype from, QStringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype findString(QStringView haystack, qsizetype from, QLatin1String needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype findString(QLatin1String haystack, qsizetype from, QStringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype findString(QLatin1String haystack, qsizetype from, QLatin1String needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype lastIndexOf(QStringView haystack, qsizetype from, QStringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype lastIndexOf(QStringView haystack, qsizetype from, QLatin1String needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype lastIndexOf(QLatin1String haystack, qsizetype from, QStringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype lastIndexOf(QLatin1String haystack, qsizetype from, QLatin1String needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype lastIndexOf(QStringView haystack, qsizetype from, QStringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype lastIndexOf(QStringView haystack, qsizetype from, QLatin1String needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype lastIndexOf(QLatin1String haystack, qsizetype from, QStringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype lastIndexOf(QLatin1String haystack, qsizetype from, QLatin1String needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION QStringView trimmed(QStringView s) noexcept;
Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION QLatin1String trimmed(QLatin1String s) noexcept;
[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION QStringView trimmed(QStringView s) noexcept;
[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION QLatin1String trimmed(QLatin1String s) noexcept;
Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype count(QStringView haystack, QChar needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype count(QStringView haystack, QStringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype count(QStringView haystack, QChar needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype count(QStringView haystack, QStringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
Q_REQUIRED_RESULT Q_CORE_EXPORT QString convertToQString(QAnyStringView s);
[[nodiscard]] Q_CORE_EXPORT QString convertToQString(QAnyStringView s);
Q_REQUIRED_RESULT Q_CORE_EXPORT QByteArray convertToLatin1(QStringView str);
Q_REQUIRED_RESULT Q_CORE_EXPORT QByteArray convertToUtf8(QStringView str);
Q_REQUIRED_RESULT Q_CORE_EXPORT QByteArray convertToLocal8Bit(QStringView str);
Q_REQUIRED_RESULT Q_CORE_EXPORT QList<uint> convertToUcs4(QStringView str);
[[nodiscard]] Q_CORE_EXPORT QByteArray convertToLatin1(QStringView str);
[[nodiscard]] Q_CORE_EXPORT QByteArray convertToUtf8(QStringView str);
[[nodiscard]] Q_CORE_EXPORT QByteArray convertToLocal8Bit(QStringView str);
[[nodiscard]] Q_CORE_EXPORT QList<uint> convertToUcs4(QStringView str);
Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool isRightToLeft(QStringView string) noexcept;
[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool isRightToLeft(QStringView string) noexcept;
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 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;
[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool isAscii(QLatin1String s) noexcept;
[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool isAscii(QStringView s) noexcept;
[[nodiscard]] constexpr inline bool isLatin1(QLatin1String s) noexcept;
[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool isLatin1(QStringView s) noexcept;
[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool isValidUtf16(QStringView s) noexcept;
} // namespace QtPRivate

View File

@ -109,8 +109,8 @@ public:
iterator() noexcept = default;
// violates std::forward_iterator (returns a reference into the iterator)
Q_REQUIRED_RESULT constexpr const Haystack* operator->() const { return Q_ASSERT(current.ok), &current.value; }
Q_REQUIRED_RESULT constexpr const Haystack& operator*() const { return *operator->(); }
[[nodiscard]] constexpr const Haystack* operator->() const { return Q_ASSERT(current.ok), &current.value; }
[[nodiscard]] constexpr const Haystack& operator*() const { return *operator->(); }
iterator& operator++() { advance(); return *this; }
iterator operator++(int) { auto tmp = *this; advance(); return tmp; }
@ -145,12 +145,12 @@ public:
using reference = typename iterator::reference;
using const_reference = reference;
Q_REQUIRED_RESULT iterator begin() const noexcept { return iterator{*this}; }
Q_REQUIRED_RESULT iterator cbegin() const noexcept { return begin(); }
[[nodiscard]] iterator begin() const noexcept { return iterator{*this}; }
[[nodiscard]] iterator cbegin() const noexcept { return begin(); }
template <bool = std::is_same<iterator, sentinel>::value> // ODR protection
Q_REQUIRED_RESULT constexpr sentinel end() const noexcept { return {}; }
[[nodiscard]] constexpr sentinel end() const noexcept { return {}; }
template <bool = std::is_same<iterator, sentinel>::value> // ODR protection
Q_REQUIRED_RESULT constexpr sentinel cend() const noexcept { return {}; }
[[nodiscard]] constexpr sentinel cend() const noexcept { return {}; }
private:
Haystack m_haystack;
@ -395,7 +395,7 @@ QStringTokenizer(Haystack&&, Needle&&, Qt::CaseSensitivity, Qt::SplitBehavior)
#undef Q_TOK_RESULT
template <typename Haystack, typename Needle, typename...Flags>
Q_REQUIRED_RESULT constexpr auto
[[nodiscard]] constexpr auto
qTokenize(Haystack &&h, Needle &&n, Flags...flags)
noexcept(QtPrivate::Tok::is_nothrow_constructible_from<Haystack, Needle>::value)
-> decltype(QtPrivate::Tok::TokenizerResult<Haystack, Needle>{std::forward<Haystack>(h),

View File

@ -229,19 +229,19 @@ public:
[[nodiscard]] constexpr static QStringView fromArray(const Char (&string)[Size]) noexcept
{ return QStringView(string, Size); }
Q_REQUIRED_RESULT inline QString toString() const; // defined in qstring.h
[[nodiscard]] inline QString toString() const; // defined in qstring.h
#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
// defined in qcore_foundation.mm
Q_REQUIRED_RESULT Q_CORE_EXPORT CFStringRef toCFString() const Q_DECL_CF_RETURNS_RETAINED;
Q_REQUIRED_RESULT Q_CORE_EXPORT NSString *toNSString() const Q_DECL_NS_RETURNS_AUTORELEASED;
[[nodiscard]] Q_CORE_EXPORT CFStringRef toCFString() const Q_DECL_CF_RETURNS_RETAINED;
[[nodiscard]] Q_CORE_EXPORT NSString *toNSString() const Q_DECL_NS_RETURNS_AUTORELEASED;
#endif
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 constexpr const storage_type *utf16() const noexcept { return m_data; }
[[nodiscard]] constexpr qsizetype size() const noexcept { return m_size; }
[[nodiscard]] const_pointer data() const noexcept { return reinterpret_cast<const_pointer>(m_data); }
[[nodiscard]] const_pointer constData() const noexcept { return data(); }
[[nodiscard]] constexpr const storage_type *utf16() const noexcept { return m_data; }
Q_REQUIRED_RESULT constexpr QChar operator[](qsizetype n) const
[[nodiscard]] constexpr QChar operator[](qsizetype n) const
{ return Q_ASSERT(n >= 0), Q_ASSERT(n < size()), QChar(m_data[n]); }
//
@ -249,43 +249,43 @@ public:
//
template <typename...Args>
Q_REQUIRED_RESULT inline QString arg(Args &&...args) const; // defined in qstring.h
[[nodiscard]] inline QString arg(Args &&...args) const; // defined in qstring.h
Q_REQUIRED_RESULT QByteArray toLatin1() const { return QtPrivate::convertToLatin1(*this); }
Q_REQUIRED_RESULT QByteArray toUtf8() const { return QtPrivate::convertToUtf8(*this); }
Q_REQUIRED_RESULT QByteArray toLocal8Bit() const { return QtPrivate::convertToLocal8Bit(*this); }
Q_REQUIRED_RESULT inline QList<uint> toUcs4() const; // defined in qlist.h
[[nodiscard]] QByteArray toLatin1() const { return QtPrivate::convertToLatin1(*this); }
[[nodiscard]] QByteArray toUtf8() const { return QtPrivate::convertToUtf8(*this); }
[[nodiscard]] QByteArray toLocal8Bit() const { return QtPrivate::convertToLocal8Bit(*this); }
[[nodiscard]] inline QList<uint> toUcs4() const; // defined in qlist.h
Q_REQUIRED_RESULT constexpr QChar at(qsizetype n) const { return (*this)[n]; }
[[nodiscard]] constexpr QChar at(qsizetype n) const { return (*this)[n]; }
Q_REQUIRED_RESULT constexpr QStringView mid(qsizetype pos, qsizetype n = -1) const
[[nodiscard]] constexpr QStringView mid(qsizetype pos, qsizetype n = -1) const
{
using namespace QtPrivate;
auto result = QContainerImplHelper::mid(size(), &pos, &n);
return result == QContainerImplHelper::Null ? QStringView() : QStringView(m_data + pos, n);
}
Q_REQUIRED_RESULT constexpr QStringView left(qsizetype n) const
[[nodiscard]] constexpr QStringView left(qsizetype n) const
{
if (size_t(n) >= size_t(size()))
n = size();
return QStringView(m_data, n);
}
Q_REQUIRED_RESULT constexpr QStringView right(qsizetype n) const
[[nodiscard]] constexpr QStringView right(qsizetype n) const
{
if (size_t(n) >= size_t(size()))
n = size();
return QStringView(m_data + m_size - n, n);
}
Q_REQUIRED_RESULT constexpr QStringView first(qsizetype n) const
[[nodiscard]] constexpr QStringView first(qsizetype n) const
{ Q_ASSERT(n >= 0); Q_ASSERT(n <= size()); return QStringView(m_data, n); }
Q_REQUIRED_RESULT constexpr QStringView last(qsizetype n) const
[[nodiscard]] constexpr QStringView last(qsizetype n) const
{ Q_ASSERT(n >= 0); Q_ASSERT(n <= size()); return QStringView(m_data + size() - n, n); }
Q_REQUIRED_RESULT constexpr QStringView sliced(qsizetype pos) const
[[nodiscard]] constexpr QStringView sliced(qsizetype pos) const
{ 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
[[nodiscard]] 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 constexpr QStringView chopped(qsizetype n) const
[[nodiscard]] constexpr QStringView chopped(qsizetype n) const
{ return Q_ASSERT(n >= 0), Q_ASSERT(n <= size()), QStringView(m_data, m_size - n); }
constexpr void truncate(qsizetype n)
@ -293,90 +293,90 @@ public:
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); }
[[nodiscard]] QStringView trimmed() const noexcept { return QtPrivate::trimmed(*this); }
template <typename Needle, typename...Flags>
Q_REQUIRED_RESULT constexpr inline auto tokenize(Needle &&needle, Flags...flags) const
[[nodiscard]] constexpr inline auto tokenize(Needle &&needle, Flags...flags) const
noexcept(noexcept(qTokenize(std::declval<const QStringView&>(), std::forward<Needle>(needle), flags...)))
-> decltype(qTokenize(*this, std::forward<Needle>(needle), flags...))
{ return qTokenize(*this, std::forward<Needle>(needle), flags...); }
Q_REQUIRED_RESULT int compare(QStringView other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
[[nodiscard]] 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 constexpr int compare(QChar c) const noexcept
[[nodiscard]] inline int compare(QLatin1String other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept;
[[nodiscard]] 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
[[nodiscard]] int compare(QChar c, Qt::CaseSensitivity cs) const noexcept
{ return QtPrivate::compareStrings(*this, QStringView(&c, 1), cs); }
Q_REQUIRED_RESULT bool startsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
[[nodiscard]] bool startsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ return QtPrivate::startsWith(*this, s, cs); }
Q_REQUIRED_RESULT inline bool startsWith(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept;
Q_REQUIRED_RESULT bool startsWith(QChar c) const noexcept
[[nodiscard]] inline bool startsWith(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept;
[[nodiscard]] bool startsWith(QChar c) const noexcept
{ return !empty() && front() == c; }
Q_REQUIRED_RESULT bool startsWith(QChar c, Qt::CaseSensitivity cs) const noexcept
[[nodiscard]] bool startsWith(QChar c, Qt::CaseSensitivity cs) const noexcept
{ return QtPrivate::startsWith(*this, QStringView(&c, 1), cs); }
Q_REQUIRED_RESULT bool endsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
[[nodiscard]] bool endsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ return QtPrivate::endsWith(*this, s, cs); }
Q_REQUIRED_RESULT inline bool endsWith(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept;
Q_REQUIRED_RESULT bool endsWith(QChar c) const noexcept
[[nodiscard]] inline bool endsWith(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept;
[[nodiscard]] bool endsWith(QChar c) const noexcept
{ return !empty() && back() == c; }
Q_REQUIRED_RESULT bool endsWith(QChar c, Qt::CaseSensitivity cs) const noexcept
[[nodiscard]] bool endsWith(QChar c, Qt::CaseSensitivity cs) const noexcept
{ return QtPrivate::endsWith(*this, QStringView(&c, 1), cs); }
Q_REQUIRED_RESULT qsizetype indexOf(QChar c, qsizetype from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
[[nodiscard]] qsizetype indexOf(QChar c, qsizetype from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ return QtPrivate::findString(*this, from, QStringView(&c, 1), cs); }
Q_REQUIRED_RESULT qsizetype indexOf(QStringView s, qsizetype from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
[[nodiscard]] qsizetype indexOf(QStringView s, qsizetype from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ return QtPrivate::findString(*this, from, s, cs); }
Q_REQUIRED_RESULT inline qsizetype indexOf(QLatin1String s, qsizetype from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept;
[[nodiscard]] inline qsizetype indexOf(QLatin1String s, qsizetype from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept;
Q_REQUIRED_RESULT bool contains(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
[[nodiscard]] bool contains(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ return indexOf(QStringView(&c, 1), 0, cs) != qsizetype(-1); }
Q_REQUIRED_RESULT bool contains(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
[[nodiscard]] bool contains(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ return indexOf(s, 0, cs) != qsizetype(-1); }
Q_REQUIRED_RESULT inline bool contains(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept;
[[nodiscard]] inline bool contains(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept;
Q_REQUIRED_RESULT qsizetype count(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
[[nodiscard]] qsizetype count(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ return QtPrivate::count(*this, c, cs); }
Q_REQUIRED_RESULT qsizetype count(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
[[nodiscard]] qsizetype count(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ return QtPrivate::count(*this, s, cs); }
Q_REQUIRED_RESULT qsizetype lastIndexOf(QChar c, qsizetype from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
[[nodiscard]] qsizetype lastIndexOf(QChar c, qsizetype from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ return QtPrivate::lastIndexOf(*this, from, QStringView(&c, 1), cs); }
Q_REQUIRED_RESULT qsizetype lastIndexOf(QStringView s, qsizetype from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
[[nodiscard]] qsizetype lastIndexOf(QStringView s, qsizetype from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ return QtPrivate::lastIndexOf(*this, from, s, cs); }
Q_REQUIRED_RESULT inline qsizetype lastIndexOf(QLatin1String s, qsizetype from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept;
[[nodiscard]] inline qsizetype lastIndexOf(QLatin1String s, qsizetype from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept;
Q_REQUIRED_RESULT bool isRightToLeft() const noexcept
[[nodiscard]] bool isRightToLeft() const noexcept
{ return QtPrivate::isRightToLeft(*this); }
Q_REQUIRED_RESULT bool isValidUtf16() const noexcept
[[nodiscard]] bool isValidUtf16() const noexcept
{ return QtPrivate::isValidUtf16(*this); }
Q_REQUIRED_RESULT inline short toShort(bool *ok = nullptr, int base = 10) const;
Q_REQUIRED_RESULT inline ushort toUShort(bool *ok = nullptr, int base = 10) const;
Q_REQUIRED_RESULT inline int toInt(bool *ok = nullptr, int base = 10) const;
Q_REQUIRED_RESULT inline uint toUInt(bool *ok = nullptr, int base = 10) const;
Q_REQUIRED_RESULT inline long toLong(bool *ok = nullptr, int base = 10) const;
Q_REQUIRED_RESULT inline ulong toULong(bool *ok = nullptr, int base = 10) const;
Q_REQUIRED_RESULT inline qlonglong toLongLong(bool *ok = nullptr, int base = 10) const;
Q_REQUIRED_RESULT inline qulonglong toULongLong(bool *ok = nullptr, int base = 10) const;
Q_REQUIRED_RESULT Q_CORE_EXPORT float toFloat(bool *ok = nullptr) const;
Q_REQUIRED_RESULT Q_CORE_EXPORT double toDouble(bool *ok = nullptr) const;
[[nodiscard]] inline short toShort(bool *ok = nullptr, int base = 10) const;
[[nodiscard]] inline ushort toUShort(bool *ok = nullptr, int base = 10) const;
[[nodiscard]] inline int toInt(bool *ok = nullptr, int base = 10) const;
[[nodiscard]] inline uint toUInt(bool *ok = nullptr, int base = 10) const;
[[nodiscard]] inline long toLong(bool *ok = nullptr, int base = 10) const;
[[nodiscard]] inline ulong toULong(bool *ok = nullptr, int base = 10) const;
[[nodiscard]] inline qlonglong toLongLong(bool *ok = nullptr, int base = 10) const;
[[nodiscard]] inline qulonglong toULongLong(bool *ok = nullptr, int base = 10) const;
[[nodiscard]] Q_CORE_EXPORT float toFloat(bool *ok = nullptr) const;
[[nodiscard]] Q_CORE_EXPORT double toDouble(bool *ok = nullptr) const;
Q_REQUIRED_RESULT inline qsizetype toWCharArray(wchar_t *array) const; // defined in qstring.h
[[nodiscard]] inline qsizetype toWCharArray(wchar_t *array) const; // defined in qstring.h
Q_REQUIRED_RESULT Q_CORE_EXPORT
[[nodiscard]] Q_CORE_EXPORT
QList<QStringView> split(QStringView sep,
Qt::SplitBehavior behavior = Qt::KeepEmptyParts,
Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
Q_REQUIRED_RESULT Q_CORE_EXPORT
[[nodiscard]] Q_CORE_EXPORT
QList<QStringView> split(QChar sep, Qt::SplitBehavior behavior = Qt::KeepEmptyParts,
Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
#if QT_CONFIG(regularexpression)
Q_REQUIRED_RESULT Q_CORE_EXPORT
[[nodiscard]] Q_CORE_EXPORT
QList<QStringView> split(const QRegularExpression &sep,
Qt::SplitBehavior behavior = Qt::KeepEmptyParts) const;
#endif
@ -384,28 +384,28 @@ public:
//
// STL compatibility API:
//
Q_REQUIRED_RESULT const_iterator begin() const noexcept { return data(); }
Q_REQUIRED_RESULT const_iterator end() const noexcept { return data() + size(); }
Q_REQUIRED_RESULT const_iterator cbegin() const noexcept { return begin(); }
Q_REQUIRED_RESULT const_iterator cend() const noexcept { return end(); }
Q_REQUIRED_RESULT const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); }
Q_REQUIRED_RESULT const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); }
Q_REQUIRED_RESULT const_reverse_iterator crbegin() const noexcept { return rbegin(); }
Q_REQUIRED_RESULT const_reverse_iterator crend() const noexcept { return rend(); }
[[nodiscard]] const_iterator begin() const noexcept { return data(); }
[[nodiscard]] const_iterator end() const noexcept { return data() + size(); }
[[nodiscard]] const_iterator cbegin() const noexcept { return begin(); }
[[nodiscard]] const_iterator cend() const noexcept { return end(); }
[[nodiscard]] const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); }
[[nodiscard]] const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); }
[[nodiscard]] const_reverse_iterator crbegin() const noexcept { return rbegin(); }
[[nodiscard]] const_reverse_iterator crend() const noexcept { return rend(); }
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]); }
[[nodiscard]] constexpr bool empty() const noexcept { return size() == 0; }
[[nodiscard]] constexpr QChar front() const { return Q_ASSERT(!empty()), QChar(m_data[0]); }
[[nodiscard]] constexpr QChar back() const { return Q_ASSERT(!empty()), QChar(m_data[m_size - 1]); }
//
// Qt compatibility API:
//
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! */
[[nodiscard]] constexpr bool isNull() const noexcept { return !m_data; }
[[nodiscard]] constexpr bool isEmpty() const noexcept { return empty(); }
[[nodiscard]] constexpr int length() const /* not nothrow! */
{ return Q_ASSERT(int(size()) == size()), int(size()); }
Q_REQUIRED_RESULT constexpr QChar first() const { return front(); }
Q_REQUIRED_RESULT constexpr QChar last() const { return back(); }
[[nodiscard]] constexpr QChar first() const { return front(); }
[[nodiscard]] constexpr QChar last() const { return back(); }
private:
qsizetype m_size;
const storage_type *m_data;
@ -423,14 +423,14 @@ inline QStringView qToStringViewIgnoringNull(const QStringLike &s) noexcept
// QChar inline functions:
Q_REQUIRED_RESULT constexpr auto QChar::fromUcs4(char32_t c) noexcept
[[nodiscard]] constexpr auto QChar::fromUcs4(char32_t c) noexcept
{
struct R {
char16_t chars[2];
Q_REQUIRED_RESULT constexpr operator QStringView() const noexcept { return {begin(), end()}; }
Q_REQUIRED_RESULT constexpr qsizetype size() const noexcept { return chars[1] ? 2 : 1; }
Q_REQUIRED_RESULT constexpr const char16_t *begin() const noexcept { return chars; }
Q_REQUIRED_RESULT constexpr const char16_t *end() const noexcept { return begin() + size(); }
[[nodiscard]] constexpr operator QStringView() const noexcept { return {begin(), end()}; }
[[nodiscard]] constexpr qsizetype size() const noexcept { return chars[1] ? 2 : 1; }
[[nodiscard]] constexpr const char16_t *begin() const noexcept { return chars; }
[[nodiscard]] constexpr const char16_t *end() const noexcept { return begin() + size(); }
};
return requiresSurrogates(c) ? R{{QChar::highSurrogate(c),
QChar::lowSurrogate(c)}} :

View File

@ -95,7 +95,7 @@ public:
bool contains(const QThread *thread) const;
Q_REQUIRED_RESULT bool tryTake(QRunnable *runnable);
[[nodiscard]] bool tryTake(QRunnable *runnable);
};
QT_END_NAMESPACE

View File

@ -109,12 +109,12 @@ public:
void getDate(int *year, int *month, int *day) const;
Q_REQUIRED_RESULT QDate addDays(qint64 days) const;
[[nodiscard]] QDate addDays(qint64 days) const;
// Gregorian-optimized:
Q_REQUIRED_RESULT QDate addMonths(int months) const;
Q_REQUIRED_RESULT QDate addYears(int years) const;
Q_REQUIRED_RESULT QDate addMonths(int months, QCalendar cal) const;
Q_REQUIRED_RESULT QDate addYears(int years, QCalendar cal) const;
[[nodiscard]] QDate addMonths(int months) const;
[[nodiscard]] QDate addYears(int years) const;
[[nodiscard]] QDate addMonths(int months, QCalendar cal) const;
[[nodiscard]] QDate addYears(int years, QCalendar cal) const;
qint64 daysTo(QDate d) const;
constexpr bool operator==(QDate other) const { return jd == other.jd; }
@ -183,9 +183,9 @@ public:
#endif
bool setHMS(int h, int m, int s, int ms = 0);
Q_REQUIRED_RESULT QTime addSecs(int secs) const;
[[nodiscard]] QTime addSecs(int secs) const;
int secsTo(QTime t) const;
Q_REQUIRED_RESULT QTime addMSecs(int ms) const;
[[nodiscard]] QTime addMSecs(int ms) const;
int msecsTo(QTime t) const;
constexpr bool operator==(QTime other) const { return mds == other.mds; }
@ -310,11 +310,11 @@ public:
# endif
QString toString(QStringView format, QCalendar cal = QCalendar()) const;
#endif
Q_REQUIRED_RESULT QDateTime addDays(qint64 days) const;
Q_REQUIRED_RESULT QDateTime addMonths(int months) const;
Q_REQUIRED_RESULT QDateTime addYears(int years) const;
Q_REQUIRED_RESULT QDateTime addSecs(qint64 secs) const;
Q_REQUIRED_RESULT QDateTime addMSecs(qint64 msecs) const;
[[nodiscard]] QDateTime addDays(qint64 days) const;
[[nodiscard]] QDateTime addMonths(int months) const;
[[nodiscard]] QDateTime addYears(int years) const;
[[nodiscard]] QDateTime addSecs(qint64 secs) const;
[[nodiscard]] QDateTime addMSecs(qint64 msecs) const;
QDateTime toTimeSpec(Qt::TimeSpec spec) const;
inline QDateTime toLocalTime() const { return toTimeSpec(Qt::LocalTime); }

View File

@ -155,12 +155,12 @@ public:
QLocale::Country country);
// returns "UTC" QString and QByteArray
Q_REQUIRED_RESULT static inline QString utcQString()
[[nodiscard]] static inline QString utcQString()
{
return QStringLiteral("UTC");
}
Q_REQUIRED_RESULT static inline QByteArray utcQByteArray()
[[nodiscard]] static inline QByteArray utcQByteArray()
{
return QByteArrayLiteral("UTC");
}

View File

@ -115,13 +115,13 @@ struct Q_CORE_EXPORT QArrayData
return result;
}
Q_REQUIRED_RESULT
[[nodiscard]]
#if defined(Q_CC_GNU)
__attribute__((__malloc__))
#endif
static void *allocate(QArrayData **pdata, qsizetype objectSize, qsizetype alignment,
qsizetype capacity, ArrayOptions options = DefaultAllocationFlags) noexcept;
Q_REQUIRED_RESULT static QPair<QArrayData *, void *> reallocateUnaligned(QArrayData *data, void *dataPointer,
[[nodiscard]] static QPair<QArrayData *, void *> reallocateUnaligned(QArrayData *data, void *dataPointer,
qsizetype objectSize, qsizetype newCapacity, ArrayOptions newOptions = DefaultAllocationFlags) noexcept;
static void deallocate(QArrayData *data, qsizetype objectSize,
qsizetype alignment) noexcept;
@ -208,7 +208,7 @@ struct QTypedArrayData
class AlignmentDummy { QArrayData header; T data; };
Q_REQUIRED_RESULT static QPair<QTypedArrayData *, T *> allocate(qsizetype capacity,
[[nodiscard]] static QPair<QTypedArrayData *, T *> allocate(qsizetype capacity,
ArrayOptions options = DefaultAllocationFlags)
{
static_assert(sizeof(QTypedArrayData) == sizeof(QArrayData));

View File

@ -243,7 +243,7 @@ public:
}
private:
Q_REQUIRED_RESULT QPair<Data *, T *> clone(QArrayData::ArrayOptions options) const
[[nodiscard]] QPair<Data *, T *> clone(QArrayData::ArrayOptions options) const
{
QPair<Data *, T *> pair = Data::allocate(detachCapacity(size), options);
QArrayDataPointer copy(pair.first, pair.second, 0);

View File

@ -75,7 +75,7 @@ class QDuplicateTracker {
public:
QDuplicateTracker() = default;
void reserve(int n) { set.reserve(n); }
Q_REQUIRED_RESULT bool hasSeen(const T &s)
[[nodiscard]] bool hasSeen(const T &s)
{
bool inserted;
#ifdef __cpp_lib_memory_resource
@ -87,7 +87,7 @@ public:
#endif
return !inserted;
}
Q_REQUIRED_RESULT bool hasSeen(T &&s)
[[nodiscard]] bool hasSeen(T &&s)
{
bool inserted;
#ifdef __cpp_lib_memory_resource

View File

@ -75,10 +75,10 @@ public:
inline void translate(const QPoint &p);
inline void translate(int dx, int dy);
Q_REQUIRED_RESULT constexpr inline QLine translated(const QPoint &p) const;
Q_REQUIRED_RESULT constexpr inline QLine translated(int dx, int dy) const;
[[nodiscard]] constexpr inline QLine translated(const QPoint &p) const;
[[nodiscard]] constexpr inline QLine translated(int dx, int dy) const;
Q_REQUIRED_RESULT constexpr inline QPoint center() const;
[[nodiscard]] constexpr inline QPoint center() const;
inline void setP1(const QPoint &p1);
inline void setP2(const QPoint &p2);
@ -225,7 +225,7 @@ public:
constexpr inline QLineF(qreal x1, qreal y1, qreal x2, qreal y2);
constexpr inline QLineF(const QLine &line) : pt1(line.p1()), pt2(line.p2()) { }
Q_REQUIRED_RESULT static QLineF fromPolar(qreal length, qreal angle);
[[nodiscard]] static QLineF fromPolar(qreal length, qreal angle);
constexpr bool isNull() const;
@ -249,8 +249,8 @@ public:
qreal angleTo(const QLineF &l) const;
Q_REQUIRED_RESULT QLineF unitVector() const;
Q_REQUIRED_RESULT constexpr inline QLineF normalVector() const;
[[nodiscard]] QLineF unitVector() const;
[[nodiscard]] constexpr inline QLineF normalVector() const;
IntersectionType intersects(const QLineF &l, QPointF *intersectionPoint = nullptr) const;
@ -258,10 +258,10 @@ public:
inline void translate(const QPointF &p);
inline void translate(qreal dx, qreal dy);
Q_REQUIRED_RESULT constexpr inline QLineF translated(const QPointF &p) const;
Q_REQUIRED_RESULT constexpr inline QLineF translated(qreal dx, qreal dy) const;
[[nodiscard]] constexpr inline QLineF translated(const QPointF &p) const;
[[nodiscard]] constexpr inline QLineF translated(qreal dx, qreal dy) const;
Q_REQUIRED_RESULT constexpr inline QPointF center() const;
[[nodiscard]] constexpr inline QPointF center() const;
inline void setP1(const QPointF &p1);
inline void setP2(const QPointF &p2);

View File

@ -96,7 +96,7 @@ public:
friend constexpr inline const QPoint operator/(const QPoint &, qreal);
#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
Q_REQUIRED_RESULT Q_CORE_EXPORT CGPoint toCGPoint() const noexcept;
[[nodiscard]] Q_CORE_EXPORT CGPoint toCGPoint() const noexcept;
#endif
private:
@ -261,8 +261,8 @@ public:
constexpr QPoint toPoint() const;
#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
Q_REQUIRED_RESULT Q_CORE_EXPORT static QPointF fromCGPoint(CGPoint point) noexcept;
Q_REQUIRED_RESULT Q_CORE_EXPORT CGPoint toCGPoint() const noexcept;
[[nodiscard]] Q_CORE_EXPORT static QPointF fromCGPoint(CGPoint point) noexcept;
[[nodiscard]] Q_CORE_EXPORT CGPoint toCGPoint() const noexcept;
#endif
private:

View File

@ -71,7 +71,7 @@ public:
constexpr inline int top() const noexcept;
constexpr inline int right() const noexcept;
constexpr inline int bottom() const noexcept;
Q_REQUIRED_RESULT QRect normalized() const noexcept;
[[nodiscard]] QRect normalized() const noexcept;
constexpr inline int x() const noexcept;
constexpr inline int y() const noexcept;
@ -105,9 +105,9 @@ public:
constexpr inline void translate(int dx, int dy) noexcept;
constexpr inline void translate(const QPoint &p) noexcept;
Q_REQUIRED_RESULT constexpr inline QRect translated(int dx, int dy) const noexcept;
Q_REQUIRED_RESULT constexpr inline QRect translated(const QPoint &p) const noexcept;
Q_REQUIRED_RESULT constexpr inline QRect transposed() const noexcept;
[[nodiscard]] constexpr inline QRect translated(int dx, int dy) const noexcept;
[[nodiscard]] constexpr inline QRect translated(const QPoint &p) const noexcept;
[[nodiscard]] constexpr inline QRect transposed() const noexcept;
constexpr inline void moveTo(int x, int t) noexcept;
constexpr inline void moveTo(const QPoint &p) noexcept;
@ -119,7 +119,7 @@ public:
constexpr inline void getCoords(int *x1, int *y1, int *x2, int *y2) const;
constexpr inline void adjust(int x1, int y1, int x2, int y2) noexcept;
Q_REQUIRED_RESULT constexpr inline QRect adjusted(int x1, int y1, int x2, int y2) const noexcept;
[[nodiscard]] constexpr inline QRect adjusted(int x1, int y1, int x2, int y2) const noexcept;
constexpr inline QSize size() const noexcept;
constexpr inline int width() const noexcept;
@ -137,8 +137,8 @@ public:
bool contains(const QPoint &p, bool proper=false) const noexcept;
inline bool contains(int x, int y) const noexcept;
inline bool contains(int x, int y, bool proper) const noexcept;
Q_REQUIRED_RESULT inline QRect united(const QRect &other) const noexcept;
Q_REQUIRED_RESULT inline QRect intersected(const QRect &other) const noexcept;
[[nodiscard]] inline QRect united(const QRect &other) const noexcept;
[[nodiscard]] inline QRect intersected(const QRect &other) const noexcept;
bool intersects(const QRect &r) const noexcept;
constexpr inline QRect marginsAdded(const QMargins &margins) const noexcept;
@ -146,14 +146,14 @@ public:
constexpr inline QRect &operator+=(const QMargins &margins) noexcept;
constexpr inline QRect &operator-=(const QMargins &margins) noexcept;
Q_REQUIRED_RESULT static constexpr inline QRect span(const QPoint &p1, const QPoint &p2) noexcept;
[[nodiscard]] static constexpr inline QRect span(const QPoint &p1, const QPoint &p2) noexcept;
friend constexpr inline bool operator==(const QRect &, const QRect &) noexcept;
friend constexpr inline bool operator!=(const QRect &, const QRect &) noexcept;
friend constexpr inline size_t qHash(const QRect &, size_t) noexcept;
#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
Q_REQUIRED_RESULT CGRect toCGRect() const noexcept;
[[nodiscard]] CGRect toCGRect() const noexcept;
#endif
private:
@ -530,7 +530,7 @@ public:
constexpr inline bool isNull() const noexcept;
constexpr inline bool isEmpty() const noexcept;
constexpr inline bool isValid() const noexcept;
Q_REQUIRED_RESULT QRectF normalized() const noexcept;
[[nodiscard]] QRectF normalized() const noexcept;
constexpr inline qreal left() const noexcept { return xp; }
constexpr inline qreal top() const noexcept { return yp; }
@ -570,10 +570,10 @@ public:
constexpr inline void translate(qreal dx, qreal dy) noexcept;
constexpr inline void translate(const QPointF &p) noexcept;
Q_REQUIRED_RESULT constexpr inline QRectF translated(qreal dx, qreal dy) const noexcept;
Q_REQUIRED_RESULT constexpr inline QRectF translated(const QPointF &p) const noexcept;
[[nodiscard]] constexpr inline QRectF translated(qreal dx, qreal dy) const noexcept;
[[nodiscard]] constexpr inline QRectF translated(const QPointF &p) const noexcept;
Q_REQUIRED_RESULT constexpr inline QRectF transposed() const noexcept;
[[nodiscard]] constexpr inline QRectF transposed() const noexcept;
constexpr inline void moveTo(qreal x, qreal y) noexcept;
constexpr inline void moveTo(const QPointF &p) noexcept;
@ -585,7 +585,7 @@ public:
constexpr inline void getCoords(qreal *x1, qreal *y1, qreal *x2, qreal *y2) const;
constexpr inline void adjust(qreal x1, qreal y1, qreal x2, qreal y2) noexcept;
Q_REQUIRED_RESULT constexpr inline QRectF adjusted(qreal x1, qreal y1, qreal x2, qreal y2) const noexcept;
[[nodiscard]] constexpr inline QRectF adjusted(qreal x1, qreal y1, qreal x2, qreal y2) const noexcept;
constexpr inline QSizeF size() const noexcept;
constexpr inline qreal width() const noexcept;
@ -602,8 +602,8 @@ public:
bool contains(const QRectF &r) const noexcept;
bool contains(const QPointF &p) const noexcept;
inline bool contains(qreal x, qreal y) const noexcept;
Q_REQUIRED_RESULT inline QRectF united(const QRectF &other) const noexcept;
Q_REQUIRED_RESULT inline QRectF intersected(const QRectF &other) const noexcept;
[[nodiscard]] inline QRectF united(const QRectF &other) const noexcept;
[[nodiscard]] inline QRectF intersected(const QRectF &other) const noexcept;
bool intersects(const QRectF &r) const noexcept;
constexpr inline QRectF marginsAdded(const QMarginsF &margins) const noexcept;
@ -614,12 +614,12 @@ public:
friend constexpr inline bool operator==(const QRectF &, const QRectF &) noexcept;
friend constexpr inline bool operator!=(const QRectF &, const QRectF &) noexcept;
Q_REQUIRED_RESULT constexpr inline QRect toRect() const noexcept;
Q_REQUIRED_RESULT QRect toAlignedRect() const noexcept;
[[nodiscard]] constexpr inline QRect toRect() const noexcept;
[[nodiscard]] QRect toAlignedRect() const noexcept;
#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
Q_REQUIRED_RESULT static QRectF fromCGRect(CGRect rect) noexcept;
Q_REQUIRED_RESULT CGRect toCGRect() const noexcept;
[[nodiscard]] static QRectF fromCGRect(CGRect rect) noexcept;
[[nodiscard]] CGRect toCGRect() const noexcept;
#endif
private:

View File

@ -45,11 +45,7 @@
QT_BEGIN_NAMESPACE
template <typename T>
class
#if QT_HAS_CPP_ATTRIBUTE(nodiscard) && __cplusplus >= 201703L
[[nodiscard]]
#endif
QScopedValueRollback
class [[nodiscard]] QScopedValueRollback
{
public:
explicit constexpr QScopedValueRollback(T &var)

View File

@ -49,13 +49,7 @@
QT_BEGIN_NAMESPACE
template <typename F>
class
#if __has_cpp_attribute(nodiscard)
// Q_REQUIRED_RESULT can be defined as __warn_unused_result__ or as [[nodiscard]]
// but the 1st one has some limitations for example can be placed only on functions.
Q_REQUIRED_RESULT
#endif
QScopeGuard
class [[nodiscard]] QScopeGuard
{
public:
explicit QScopeGuard(F &&f) noexcept
@ -98,10 +92,7 @@ template <typename F> QScopeGuard(F(&)()) -> QScopeGuard<F(*)()>;
//! [qScopeGuard]
template <typename F>
#if __has_cpp_attribute(nodiscard)
Q_REQUIRED_RESULT
#endif
QScopeGuard<typename std::decay<F>::type> qScopeGuard(F &&f)
[[nodiscard]] QScopeGuard<typename std::decay<F>::type> qScopeGuard(F &&f)
{
return QScopeGuard<typename std::decay<F>::type>(std::forward<F>(f));
}

View File

@ -66,19 +66,19 @@ public:
constexpr inline void setWidth(int w) noexcept;
constexpr inline void setHeight(int h) noexcept;
void transpose() noexcept;
Q_REQUIRED_RESULT constexpr inline QSize transposed() const noexcept;
[[nodiscard]] constexpr inline QSize transposed() const noexcept;
inline void scale(int w, int h, Qt::AspectRatioMode mode) noexcept;
inline void scale(const QSize &s, Qt::AspectRatioMode mode) noexcept;
Q_REQUIRED_RESULT QSize scaled(int w, int h, Qt::AspectRatioMode mode) const noexcept;
Q_REQUIRED_RESULT QSize scaled(const QSize &s, Qt::AspectRatioMode mode) const noexcept;
[[nodiscard]] QSize scaled(int w, int h, Qt::AspectRatioMode mode) const noexcept;
[[nodiscard]] QSize scaled(const QSize &s, Qt::AspectRatioMode mode) const noexcept;
Q_REQUIRED_RESULT constexpr inline QSize expandedTo(const QSize &) const noexcept;
Q_REQUIRED_RESULT constexpr inline QSize boundedTo(const QSize &) const noexcept;
[[nodiscard]] constexpr inline QSize expandedTo(const QSize &) const noexcept;
[[nodiscard]] constexpr inline QSize boundedTo(const QSize &) const noexcept;
Q_REQUIRED_RESULT constexpr QSize grownBy(QMargins m) const noexcept
[[nodiscard]] constexpr QSize grownBy(QMargins m) const noexcept
{ return {width() + m.left() + m.right(), height() + m.top() + m.bottom()}; }
Q_REQUIRED_RESULT constexpr QSize shrunkBy(QMargins m) const noexcept
[[nodiscard]] constexpr QSize shrunkBy(QMargins m) const noexcept
{ return {width() - m.left() - m.right(), height() - m.top() - m.bottom()}; }
constexpr inline int &rwidth() noexcept;
@ -99,7 +99,7 @@ public:
friend inline const QSize operator/(const QSize &, qreal);
#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
Q_REQUIRED_RESULT CGSize toCGSize() const noexcept;
[[nodiscard]] CGSize toCGSize() const noexcept;
#endif
private:
@ -239,19 +239,19 @@ public:
constexpr inline void setWidth(qreal w) noexcept;
constexpr inline void setHeight(qreal h) noexcept;
void transpose() noexcept;
Q_REQUIRED_RESULT constexpr inline QSizeF transposed() const noexcept;
[[nodiscard]] constexpr inline QSizeF transposed() const noexcept;
inline void scale(qreal w, qreal h, Qt::AspectRatioMode mode) noexcept;
inline void scale(const QSizeF &s, Qt::AspectRatioMode mode) noexcept;
Q_REQUIRED_RESULT QSizeF scaled(qreal w, qreal h, Qt::AspectRatioMode mode) const noexcept;
Q_REQUIRED_RESULT QSizeF scaled(const QSizeF &s, Qt::AspectRatioMode mode) const noexcept;
[[nodiscard]] QSizeF scaled(qreal w, qreal h, Qt::AspectRatioMode mode) const noexcept;
[[nodiscard]] QSizeF scaled(const QSizeF &s, Qt::AspectRatioMode mode) const noexcept;
Q_REQUIRED_RESULT constexpr inline QSizeF expandedTo(const QSizeF &) const noexcept;
Q_REQUIRED_RESULT constexpr inline QSizeF boundedTo(const QSizeF &) const noexcept;
[[nodiscard]] constexpr inline QSizeF expandedTo(const QSizeF &) const noexcept;
[[nodiscard]] constexpr inline QSizeF boundedTo(const QSizeF &) const noexcept;
Q_REQUIRED_RESULT constexpr QSizeF grownBy(QMarginsF m) const noexcept
[[nodiscard]] constexpr QSizeF grownBy(QMarginsF m) const noexcept
{ return {width() + m.left() + m.right(), height() + m.top() + m.bottom()}; }
Q_REQUIRED_RESULT constexpr QSizeF shrunkBy(QMarginsF m) const noexcept
[[nodiscard]] constexpr QSizeF shrunkBy(QMarginsF m) const noexcept
{ return {width() - m.left() - m.right(), height() - m.top() - m.bottom()}; }
constexpr inline qreal &rwidth() noexcept;
@ -273,8 +273,8 @@ public:
constexpr inline QSize toSize() const noexcept;
#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
Q_REQUIRED_RESULT static QSizeF fromCGSize(CGSize size) noexcept;
Q_REQUIRED_RESULT CGSize toCGSize() const noexcept;
[[nodiscard]] static QSizeF fromCGSize(CGSize size) noexcept;
[[nodiscard]] CGSize toCGSize() const noexcept;
#endif
private:

View File

@ -237,43 +237,43 @@ public:
inline explicit QVersionNumber(int maj, int min, int mic)
{ m_segments.setSegments(3, maj, min, mic); }
Q_REQUIRED_RESULT inline bool isNull() const noexcept
[[nodiscard]] inline bool isNull() const noexcept
{ return segmentCount() == 0; }
Q_REQUIRED_RESULT inline bool isNormalized() const noexcept
[[nodiscard]] inline bool isNormalized() const noexcept
{ return isNull() || segmentAt(segmentCount() - 1) != 0; }
Q_REQUIRED_RESULT inline int majorVersion() const noexcept
[[nodiscard]] inline int majorVersion() const noexcept
{ return segmentAt(0); }
Q_REQUIRED_RESULT inline int minorVersion() const noexcept
[[nodiscard]] inline int minorVersion() const noexcept
{ return segmentAt(1); }
Q_REQUIRED_RESULT inline int microVersion() const noexcept
[[nodiscard]] inline int microVersion() const noexcept
{ return segmentAt(2); }
Q_REQUIRED_RESULT Q_CORE_EXPORT QVersionNumber normalized() const;
[[nodiscard]] Q_CORE_EXPORT QVersionNumber normalized() const;
Q_REQUIRED_RESULT Q_CORE_EXPORT QList<int> segments() const;
[[nodiscard]] Q_CORE_EXPORT QList<int> segments() const;
Q_REQUIRED_RESULT inline int segmentAt(int index) const noexcept
[[nodiscard]] inline int segmentAt(int index) const noexcept
{ return (m_segments.size() > index) ? m_segments.at(index) : 0; }
Q_REQUIRED_RESULT inline int segmentCount() const noexcept
[[nodiscard]] inline int segmentCount() const noexcept
{ return m_segments.size(); }
Q_REQUIRED_RESULT Q_CORE_EXPORT bool isPrefixOf(const QVersionNumber &other) const noexcept;
[[nodiscard]] Q_CORE_EXPORT bool isPrefixOf(const QVersionNumber &other) const noexcept;
Q_REQUIRED_RESULT Q_CORE_EXPORT static int compare(const QVersionNumber &v1, const QVersionNumber &v2) noexcept;
[[nodiscard]] Q_CORE_EXPORT static int compare(const QVersionNumber &v1, const QVersionNumber &v2) noexcept;
Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber commonPrefix(const QVersionNumber &v1, const QVersionNumber &v2);
[[nodiscard]] Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber commonPrefix(const QVersionNumber &v1, const QVersionNumber &v2);
Q_REQUIRED_RESULT Q_CORE_EXPORT QString toString() const;
[[nodiscard]] Q_CORE_EXPORT QString toString() const;
#if QT_STRINGVIEW_LEVEL < 2
Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(const QString &string, int *suffixIndex = nullptr);
[[nodiscard]] Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(const QString &string, int *suffixIndex = nullptr);
#endif
Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QLatin1String string, int *suffixIndex = nullptr);
Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QStringView string, int *suffixIndex = nullptr);
[[nodiscard]] Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QLatin1String string, int *suffixIndex = nullptr);
[[nodiscard]] Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QStringView string, int *suffixIndex = nullptr);
private:
#ifndef QT_NO_DATASTREAM
@ -288,22 +288,22 @@ Q_DECLARE_TYPEINFO(QVersionNumber, Q_MOVABLE_TYPE);
Q_CORE_EXPORT QDebug operator<<(QDebug, const QVersionNumber &version);
#endif
Q_REQUIRED_RESULT inline bool operator> (const QVersionNumber &lhs, const QVersionNumber &rhs) noexcept
[[nodiscard]] inline bool operator> (const QVersionNumber &lhs, const QVersionNumber &rhs) noexcept
{ return QVersionNumber::compare(lhs, rhs) > 0; }
Q_REQUIRED_RESULT inline bool operator>=(const QVersionNumber &lhs, const QVersionNumber &rhs) noexcept
[[nodiscard]] inline bool operator>=(const QVersionNumber &lhs, const QVersionNumber &rhs) noexcept
{ return QVersionNumber::compare(lhs, rhs) >= 0; }
Q_REQUIRED_RESULT inline bool operator< (const QVersionNumber &lhs, const QVersionNumber &rhs) noexcept
[[nodiscard]] inline bool operator< (const QVersionNumber &lhs, const QVersionNumber &rhs) noexcept
{ return QVersionNumber::compare(lhs, rhs) < 0; }
Q_REQUIRED_RESULT inline bool operator<=(const QVersionNumber &lhs, const QVersionNumber &rhs) noexcept
[[nodiscard]] inline bool operator<=(const QVersionNumber &lhs, const QVersionNumber &rhs) noexcept
{ return QVersionNumber::compare(lhs, rhs) <= 0; }
Q_REQUIRED_RESULT inline bool operator==(const QVersionNumber &lhs, const QVersionNumber &rhs) noexcept
[[nodiscard]] inline bool operator==(const QVersionNumber &lhs, const QVersionNumber &rhs) noexcept
{ return QVersionNumber::compare(lhs, rhs) == 0; }
Q_REQUIRED_RESULT inline bool operator!=(const QVersionNumber &lhs, const QVersionNumber &rhs) noexcept
[[nodiscard]] inline bool operator!=(const QVersionNumber &lhs, const QVersionNumber &rhs) noexcept
{ return QVersionNumber::compare(lhs, rhs) != 0; }
class QTypeRevision;

View File

@ -156,22 +156,22 @@ public:
Format format() const;
Q_REQUIRED_RESULT Q_ALWAYS_INLINE QImage convertToFormat(Format f, Qt::ImageConversionFlags flags = Qt::AutoColor) const &
[[nodiscard]] Q_ALWAYS_INLINE QImage convertToFormat(Format f, Qt::ImageConversionFlags flags = Qt::AutoColor) const &
{ return convertToFormat_helper(f, flags); }
Q_REQUIRED_RESULT Q_ALWAYS_INLINE QImage convertToFormat(Format f, Qt::ImageConversionFlags flags = Qt::AutoColor) &&
[[nodiscard]] Q_ALWAYS_INLINE QImage convertToFormat(Format f, Qt::ImageConversionFlags flags = Qt::AutoColor) &&
{
if (convertToFormat_inplace(f, flags))
return std::move(*this);
else
return convertToFormat_helper(f, flags);
}
Q_REQUIRED_RESULT QImage convertToFormat(Format f, const QList<QRgb> &colorTable,
[[nodiscard]] QImage convertToFormat(Format f, const QList<QRgb> &colorTable,
Qt::ImageConversionFlags flags = Qt::AutoColor) const;
bool reinterpretAsFormat(Format f);
Q_REQUIRED_RESULT QImage convertedTo(Format f, Qt::ImageConversionFlags flags = Qt::AutoColor) const &
[[nodiscard]] QImage convertedTo(Format f, Qt::ImageConversionFlags flags = Qt::AutoColor) const &
{ return convertToFormat(f, flags); }
Q_REQUIRED_RESULT QImage convertedTo(Format f, Qt::ImageConversionFlags flags = Qt::AutoColor) &&
[[nodiscard]] QImage convertedTo(Format f, Qt::ImageConversionFlags flags = Qt::AutoColor) &&
{ return convertToFormat(f, flags); }
void convertTo(Format f, Qt::ImageConversionFlags flags = Qt::AutoColor);
@ -248,13 +248,13 @@ public:
QImage scaledToHeight(int h, Qt::TransformationMode mode = Qt::FastTransformation) const;
QImage transformed(const QTransform &matrix, Qt::TransformationMode mode = Qt::FastTransformation) const;
static QTransform trueMatrix(const QTransform &, int w, int h);
Q_REQUIRED_RESULT QImage mirrored(bool horizontally = false, bool vertically = true) const &
[[nodiscard]] QImage mirrored(bool horizontally = false, bool vertically = true) const &
{ return mirrored_helper(horizontally, vertically); }
Q_REQUIRED_RESULT QImage mirrored(bool horizontally = false, bool vertically = true) &&
[[nodiscard]] QImage mirrored(bool horizontally = false, bool vertically = true) &&
{ mirrored_inplace(horizontally, vertically); return std::move(*this); }
Q_REQUIRED_RESULT QImage rgbSwapped() const &
[[nodiscard]] QImage rgbSwapped() const &
{ return rgbSwapped_helper(); }
Q_REQUIRED_RESULT QImage rgbSwapped() &&
[[nodiscard]] QImage rgbSwapped() &&
{ rgbSwapped_inplace(); return std::move(*this); }
void mirror(bool horizontally = false, bool vertically = true)
{ mirrored_inplace(horizontally, vertically); }

View File

@ -54,8 +54,8 @@ Q_GUI_EXPORT void qt_handleTouchEvent(QWindow *w, const QPointingDevice *device
namespace QTest {
Q_REQUIRED_RESULT Q_GUI_EXPORT bool qWaitForWindowActive(QWindow *window, int timeout = 5000);
Q_REQUIRED_RESULT Q_GUI_EXPORT bool qWaitForWindowExposed(QWindow *window, int timeout = 5000);
[[nodiscard]] Q_GUI_EXPORT bool qWaitForWindowActive(QWindow *window, int timeout = 5000);
[[nodiscard]] Q_GUI_EXPORT bool qWaitForWindowExposed(QWindow *window, int timeout = 5000);
Q_GUI_EXPORT QPointingDevice * createTouchDevice(QInputDevice::DeviceType devType = QInputDevice::DeviceType::TouchScreen,
QInputDevice::Capabilities caps = QInputDevice::Capability::Position);

View File

@ -64,7 +64,7 @@ public:
void fill(T value);
Q_REQUIRED_RESULT QGenericMatrix<M, N, T> transposed() const;
[[nodiscard]] QGenericMatrix<M, N, T> transposed() const;
QGenericMatrix<N, M, T>& operator+=(const QGenericMatrix<N, M, T>& other);
QGenericMatrix<N, M, T>& operator-=(const QGenericMatrix<N, M, T>& other);

View File

@ -90,12 +90,12 @@ public:
float length() const;
float lengthSquared() const;
Q_REQUIRED_RESULT QQuaternion normalized() const;
[[nodiscard]] QQuaternion normalized() const;
void normalize();
inline QQuaternion inverted() const;
Q_REQUIRED_RESULT QQuaternion conjugated() const;
[[nodiscard]] QQuaternion conjugated() const;
QVector3D rotatedVector(const QVector3D& vector) const;

View File

@ -82,7 +82,7 @@ public:
float length() const;
float lengthSquared() const; //In Qt 6 convert to inline and constexpr
Q_REQUIRED_RESULT QVector2D normalized() const;
[[nodiscard]] QVector2D normalized() const;
void normalize();
float distanceToPoint(const QVector2D &point) const;

View File

@ -88,7 +88,7 @@ public:
float length() const;
float lengthSquared() const; //In Qt 6 convert to inline and constexpr
Q_REQUIRED_RESULT QVector4D normalized() const;
[[nodiscard]] QVector4D normalized() const;
void normalize();
QVector4D &operator+=(const QVector4D &vector);

View File

@ -195,7 +195,7 @@ public:
QColor toHsl() const noexcept;
QColor toExtendedRgb() const noexcept;
Q_REQUIRED_RESULT QColor convertTo(Spec colorSpec) const noexcept;
[[nodiscard]] QColor convertTo(Spec colorSpec) const noexcept;
static QColor fromRgb(QRgb rgb) noexcept;
static QColor fromRgba(QRgb rgba) noexcept;
@ -215,8 +215,8 @@ public:
static QColor fromHsl(int h, int s, int l, int a = 255);
static QColor fromHslF(float h, float s, float l, float a = 1.0);
Q_REQUIRED_RESULT QColor lighter(int f = 150) const noexcept;
Q_REQUIRED_RESULT QColor darker(int f = 200) const noexcept;
[[nodiscard]] QColor lighter(int f = 150) const noexcept;
[[nodiscard]] QColor darker(int f = 200) const noexcept;
bool operator==(const QColor &c) const noexcept;
bool operator!=(const QColor &c) const noexcept;

View File

@ -150,8 +150,8 @@ public:
void translate(qreal dx, qreal dy);
inline void translate(const QPointF &offset);
Q_REQUIRED_RESULT QPainterPath translated(qreal dx, qreal dy) const;
Q_REQUIRED_RESULT inline QPainterPath translated(const QPointF &offset) const;
[[nodiscard]] QPainterPath translated(qreal dx, qreal dy) const;
[[nodiscard]] inline QPainterPath translated(const QPointF &offset) const;
QRectF boundingRect() const;
QRectF controlPointRect() const;
@ -161,7 +161,7 @@ public:
bool isEmpty() const;
Q_REQUIRED_RESULT QPainterPath toReversed() const;
[[nodiscard]] QPainterPath toReversed() const;
QList<QPolygonF> toSubpathPolygons(const QTransform &matrix = QTransform()) const;
QList<QPolygonF> toFillPolygons(const QTransform &matrix = QTransform()) const;
@ -179,11 +179,11 @@ public:
bool intersects(const QPainterPath &p) const;
bool contains(const QPainterPath &p) const;
Q_REQUIRED_RESULT QPainterPath united(const QPainterPath &r) const;
Q_REQUIRED_RESULT QPainterPath intersected(const QPainterPath &r) const;
Q_REQUIRED_RESULT QPainterPath subtracted(const QPainterPath &r) const;
[[nodiscard]] QPainterPath united(const QPainterPath &r) const;
[[nodiscard]] QPainterPath intersected(const QPainterPath &r) const;
[[nodiscard]] QPainterPath subtracted(const QPainterPath &r) const;
Q_REQUIRED_RESULT QPainterPath simplified() const;
[[nodiscard]] QPainterPath simplified() const;
bool operator==(const QPainterPath &other) const;
bool operator!=(const QPainterPath &other) const;

View File

@ -69,8 +69,8 @@ public:
Q_GUI_EXPORT void translate(int dx, int dy);
void translate(const QPoint &offset);
Q_REQUIRED_RESULT Q_GUI_EXPORT QPolygon translated(int dx, int dy) const;
Q_REQUIRED_RESULT inline QPolygon translated(const QPoint &offset) const;
[[nodiscard]] Q_GUI_EXPORT QPolygon translated(int dx, int dy) const;
[[nodiscard]] inline QPolygon translated(const QPoint &offset) const;
Q_GUI_EXPORT QRect boundingRect() const;
@ -86,9 +86,9 @@ public:
Q_GUI_EXPORT bool containsPoint(const QPoint &pt, Qt::FillRule fillRule) const;
Q_REQUIRED_RESULT Q_GUI_EXPORT QPolygon united(const QPolygon &r) const;
Q_REQUIRED_RESULT Q_GUI_EXPORT QPolygon intersected(const QPolygon &r) const;
Q_REQUIRED_RESULT Q_GUI_EXPORT QPolygon subtracted(const QPolygon &r) const;
[[nodiscard]] Q_GUI_EXPORT QPolygon united(const QPolygon &r) const;
[[nodiscard]] Q_GUI_EXPORT QPolygon intersected(const QPolygon &r) const;
[[nodiscard]] Q_GUI_EXPORT QPolygon subtracted(const QPolygon &r) const;
Q_GUI_EXPORT bool intersects(const QPolygon &r) const;
};
@ -144,7 +144,7 @@ public:
void Q_GUI_EXPORT translate(const QPointF &offset);
inline QPolygonF translated(qreal dx, qreal dy) const;
Q_REQUIRED_RESULT Q_GUI_EXPORT QPolygonF translated(const QPointF &offset) const;
[[nodiscard]] Q_GUI_EXPORT QPolygonF translated(const QPointF &offset) const;
QPolygon Q_GUI_EXPORT toPolygon() const;
@ -154,9 +154,9 @@ public:
Q_GUI_EXPORT bool containsPoint(const QPointF &pt, Qt::FillRule fillRule) const;
Q_REQUIRED_RESULT Q_GUI_EXPORT QPolygonF united(const QPolygonF &r) const;
Q_REQUIRED_RESULT Q_GUI_EXPORT QPolygonF intersected(const QPolygonF &r) const;
Q_REQUIRED_RESULT Q_GUI_EXPORT QPolygonF subtracted(const QPolygonF &r) const;
[[nodiscard]] Q_GUI_EXPORT QPolygonF united(const QPolygonF &r) const;
[[nodiscard]] Q_GUI_EXPORT QPolygonF intersected(const QPolygonF &r) const;
[[nodiscard]] Q_GUI_EXPORT QPolygonF subtracted(const QPolygonF &r) const;
Q_GUI_EXPORT bool intersects(const QPolygonF &r) const;
};

View File

@ -97,15 +97,15 @@ public:
void translate(int dx, int dy);
inline void translate(const QPoint &p) { translate(p.x(), p.y()); }
Q_REQUIRED_RESULT QRegion translated(int dx, int dy) const;
Q_REQUIRED_RESULT inline QRegion translated(const QPoint &p) const { return translated(p.x(), p.y()); }
[[nodiscard]] QRegion translated(int dx, int dy) const;
[[nodiscard]] inline QRegion translated(const QPoint &p) const { return translated(p.x(), p.y()); }
Q_REQUIRED_RESULT QRegion united(const QRegion &r) const;
Q_REQUIRED_RESULT QRegion united(const QRect &r) const;
Q_REQUIRED_RESULT QRegion intersected(const QRegion &r) const;
Q_REQUIRED_RESULT QRegion intersected(const QRect &r) const;
Q_REQUIRED_RESULT QRegion subtracted(const QRegion &r) const;
Q_REQUIRED_RESULT QRegion xored(const QRegion &r) const;
[[nodiscard]] QRegion united(const QRegion &r) const;
[[nodiscard]] QRegion united(const QRect &r) const;
[[nodiscard]] QRegion intersected(const QRegion &r) const;
[[nodiscard]] QRegion intersected(const QRect &r) const;
[[nodiscard]] QRegion subtracted(const QRegion &r) const;
[[nodiscard]] QRegion xored(const QRegion &r) const;
bool intersects(const QRegion &r) const;
bool intersects(const QRect &r) const;

View File

@ -113,9 +113,9 @@ public:
qreal m21, qreal m22, qreal m23,
qreal m31, qreal m32, qreal m33);
Q_REQUIRED_RESULT QTransform inverted(bool *invertible = nullptr) const;
Q_REQUIRED_RESULT QTransform adjoint() const;
Q_REQUIRED_RESULT QTransform transposed() const;
[[nodiscard]] QTransform inverted(bool *invertible = nullptr) const;
[[nodiscard]] QTransform adjoint() const;
[[nodiscard]] QTransform transposed() const;
QTransform &translate(qreal dx, qreal dy);
QTransform &scale(qreal sx, qreal sy);

View File

@ -122,11 +122,11 @@ public:
HRESULT STDMETHODCALLTYPE NetworkConnectionPropertyChanged(
GUID connectionId, NLM_CONNECTION_PROPERTY_CHANGE flags) override;
Q_REQUIRED_RESULT
[[nodiscard]]
bool setTarget(const QNetworkInterface &iface);
Q_REQUIRED_RESULT
[[nodiscard]]
bool startMonitoring();
Q_REQUIRED_RESULT
[[nodiscard]]
bool stopMonitoring();
private:
@ -151,9 +151,9 @@ public:
QNetworkConnectionMonitorPrivate();
~QNetworkConnectionMonitorPrivate();
Q_REQUIRED_RESULT
[[nodiscard]]
bool setTargets(const QHostAddress &local, const QHostAddress &remote);
Q_REQUIRED_RESULT
[[nodiscard]]
bool startMonitoring();
void stopMonitoring();
@ -510,7 +510,7 @@ public:
HRESULT STDMETHODCALLTYPE ConnectivityChanged(NLM_CONNECTIVITY newConnectivity) override;
Q_REQUIRED_RESULT
[[nodiscard]]
bool start();
bool stop();
@ -532,7 +532,7 @@ public:
QNetworkStatusMonitorPrivate();
~QNetworkStatusMonitorPrivate();
Q_REQUIRED_RESULT
[[nodiscard]]
bool start();
void stop();

View File

@ -64,8 +64,8 @@ public:
Q_NETWORK_EXPORT static QSslEllipticCurve fromShortName(const QString &name);
Q_NETWORK_EXPORT static QSslEllipticCurve fromLongName(const QString &name);
Q_REQUIRED_RESULT Q_NETWORK_EXPORT QString shortName() const;
Q_REQUIRED_RESULT Q_NETWORK_EXPORT QString longName() const;
[[nodiscard]] Q_NETWORK_EXPORT QString shortName() const;
[[nodiscard]] Q_NETWORK_EXPORT QString longName() const;
constexpr bool isValid() const noexcept
{

View File

@ -134,7 +134,7 @@ public:
constexpr void setRetainSizeWhenHidden(bool retainSize) noexcept { bits.retainSizeWhenHidden = retainSize; }
constexpr void transpose() noexcept { *this = transposed(); }
Q_REQUIRED_RESULT constexpr QSizePolicy transposed() const noexcept
[[nodiscard]] constexpr QSizePolicy transposed() const noexcept
{
return QSizePolicy(bits.transposed());
}

View File

@ -50,8 +50,8 @@ class QWidget;
namespace QTest {
Q_REQUIRED_RESULT Q_WIDGETS_EXPORT bool qWaitForWindowActive(QWidget *widget, int timeout = 5000);
Q_REQUIRED_RESULT Q_WIDGETS_EXPORT bool qWaitForWindowExposed(QWidget *widget, int timeout = 5000);
[[nodiscard]] Q_WIDGETS_EXPORT bool qWaitForWindowActive(QWidget *widget, int timeout = 5000);
[[nodiscard]] Q_WIDGETS_EXPORT bool qWaitForWindowExposed(QWidget *widget, int timeout = 5000);
class Q_WIDGETS_EXPORT QTouchEventWidgetSequence : public QTouchEventSequence
{

View File

@ -58,7 +58,7 @@ int intFunc()
return 0;
}
Q_REQUIRED_RESULT int noDiscardFunc()
[[nodiscard]] int noDiscardFunc()
{
return 0;
}