diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-09-23 10:09:42 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-09-25 07:10:45 +0200 |
commit | c2be9180b7430221e9136afb1a8c2a752ac2710f (patch) | |
tree | 5b390c53f4744c7bd4faeaf4d3a12d77ce3c0ba7 /src/corelib/tools | |
parent | 31a1b3280cf076fcdb45a658d0140af3737be138 (diff) |
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>
Diffstat (limited to 'src/corelib/tools')
-rw-r--r-- | src/corelib/tools/qarraydata.h | 6 | ||||
-rw-r--r-- | src/corelib/tools/qarraydatapointer.h | 2 | ||||
-rw-r--r-- | src/corelib/tools/qduplicatetracker_p.h | 4 | ||||
-rw-r--r-- | src/corelib/tools/qline.h | 18 | ||||
-rw-r--r-- | src/corelib/tools/qpoint.h | 6 | ||||
-rw-r--r-- | src/corelib/tools/qrect.h | 40 | ||||
-rw-r--r-- | src/corelib/tools/qscopedvaluerollback.h | 6 | ||||
-rw-r--r-- | src/corelib/tools/qscopeguard.h | 13 | ||||
-rw-r--r-- | src/corelib/tools/qsize.h | 34 | ||||
-rw-r--r-- | src/corelib/tools/qversionnumber.h | 44 |
10 files changed, 80 insertions, 93 deletions
diff --git a/src/corelib/tools/qarraydata.h b/src/corelib/tools/qarraydata.h index 856a9521ad..c984f700be 100644 --- a/src/corelib/tools/qarraydata.h +++ b/src/corelib/tools/qarraydata.h @@ -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)); diff --git a/src/corelib/tools/qarraydatapointer.h b/src/corelib/tools/qarraydatapointer.h index ad5acdb7fd..f92eb78a6f 100644 --- a/src/corelib/tools/qarraydatapointer.h +++ b/src/corelib/tools/qarraydatapointer.h @@ -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); diff --git a/src/corelib/tools/qduplicatetracker_p.h b/src/corelib/tools/qduplicatetracker_p.h index baf21bfd12..e5bb11793a 100644 --- a/src/corelib/tools/qduplicatetracker_p.h +++ b/src/corelib/tools/qduplicatetracker_p.h @@ -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 diff --git a/src/corelib/tools/qline.h b/src/corelib/tools/qline.h index c3fb2fd5f5..adef545d86 100644 --- a/src/corelib/tools/qline.h +++ b/src/corelib/tools/qline.h @@ -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); diff --git a/src/corelib/tools/qpoint.h b/src/corelib/tools/qpoint.h index e854e77198..dd0f177fa6 100644 --- a/src/corelib/tools/qpoint.h +++ b/src/corelib/tools/qpoint.h @@ -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: diff --git a/src/corelib/tools/qrect.h b/src/corelib/tools/qrect.h index 5deb220b2d..dbabc4eb0b 100644 --- a/src/corelib/tools/qrect.h +++ b/src/corelib/tools/qrect.h @@ -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: diff --git a/src/corelib/tools/qscopedvaluerollback.h b/src/corelib/tools/qscopedvaluerollback.h index d076b67330..9b14308ec2 100644 --- a/src/corelib/tools/qscopedvaluerollback.h +++ b/src/corelib/tools/qscopedvaluerollback.h @@ -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) diff --git a/src/corelib/tools/qscopeguard.h b/src/corelib/tools/qscopeguard.h index d288fd63fc..8270f41a2e 100644 --- a/src/corelib/tools/qscopeguard.h +++ b/src/corelib/tools/qscopeguard.h @@ -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)); } diff --git a/src/corelib/tools/qsize.h b/src/corelib/tools/qsize.h index d2598afbea..d89d9e0426 100644 --- a/src/corelib/tools/qsize.h +++ b/src/corelib/tools/qsize.h @@ -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: diff --git a/src/corelib/tools/qversionnumber.h b/src/corelib/tools/qversionnumber.h index 4704db2c10..51d61004f6 100644 --- a/src/corelib/tools/qversionnumber.h +++ b/src/corelib/tools/qversionnumber.h @@ -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; |