From a92dbddac7ba8d72301a43f3e934bccb2822670c Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 26 Dec 2014 21:43:40 +0100 Subject: QRect: plaster API with Q_DECL_NOTHROW This is mostly straight-forward, but some things are worth noting: 1. Yes, this is necessary. The noexcept operator looks for noexcept tagging, not at the contents of the function to determine whether to return true. The more conditionally-noexcept functions are used, the more important it becomes that low-level classes are correctly marked noexcept. In that, it is like constexpr. 2. In accordance with the rules governing noexcept specifications for the standard library itself, the get*()-family of functions are not marked as noexcept, since they have preconditions and thus a narrow contract. Narrow-contract functions should not be noexcept. All other functions have wide contracts (ie. no preconditions). Change-Id: I82e5d34a0293d73ddc98ee231e17e26463ab6686 Reviewed-by: Thiago Macieira --- src/corelib/tools/qrect.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src/corelib/tools/qrect.cpp') diff --git a/src/corelib/tools/qrect.cpp b/src/corelib/tools/qrect.cpp index dc46f85fb51..25e86d91606 100644 --- a/src/corelib/tools/qrect.cpp +++ b/src/corelib/tools/qrect.cpp @@ -295,7 +295,7 @@ QT_BEGIN_NAMESPACE \sa isValid(), isEmpty() */ -QRect QRect::normalized() const +QRect QRect::normalized() const Q_DECL_NOTHROW { QRect r; if (x2 < x1 - 1) { // swap bad x values @@ -804,7 +804,7 @@ QRect QRect::normalized() const \sa intersects() */ -bool QRect::contains(const QPoint &p, bool proper) const +bool QRect::contains(const QPoint &p, bool proper) const Q_DECL_NOTHROW { int l, r; if (x2 < x1 - 1) { @@ -868,7 +868,7 @@ bool QRect::contains(const QPoint &p, bool proper) const rectangle (not on the edge). */ -bool QRect::contains(const QRect &r, bool proper) const +bool QRect::contains(const QRect &r, bool proper) const Q_DECL_NOTHROW { if (isNull() || r.isNull()) return false; @@ -946,7 +946,7 @@ bool QRect::contains(const QRect &r, bool proper) const \sa operator|=(), united() */ -QRect QRect::operator|(const QRect &r) const +QRect QRect::operator|(const QRect &r) const Q_DECL_NOTHROW { if (isNull()) return r; @@ -1017,7 +1017,7 @@ QRect QRect::operator|(const QRect &r) const \sa operator&=(), intersected() */ -QRect QRect::operator&(const QRect &r) const +QRect QRect::operator&(const QRect &r) const Q_DECL_NOTHROW { if (isNull() || r.isNull()) return QRect(); @@ -1096,7 +1096,7 @@ QRect QRect::operator&(const QRect &r) const \sa contains() */ -bool QRect::intersects(const QRect &r) const +bool QRect::intersects(const QRect &r) const Q_DECL_NOTHROW { if (isNull() || r.isNull()) return false; @@ -1522,7 +1522,7 @@ QDebug operator<<(QDebug dbg, const QRect &r) \sa isValid(), isEmpty() */ -QRectF QRectF::normalized() const +QRectF QRectF::normalized() const Q_DECL_NOTHROW { QRectF r = *this; if (r.w < 0) { @@ -1935,7 +1935,7 @@ QRectF QRectF::normalized() const \sa intersects() */ -bool QRectF::contains(const QPointF &p) const +bool QRectF::contains(const QPointF &p) const Q_DECL_NOTHROW { qreal l = xp; qreal r = xp; @@ -1981,7 +1981,7 @@ bool QRectF::contains(const QPointF &p) const otherwise returns \c false. */ -bool QRectF::contains(const QRectF &r) const +bool QRectF::contains(const QRectF &r) const Q_DECL_NOTHROW { qreal l1 = xp; qreal r1 = xp; @@ -2119,7 +2119,7 @@ bool QRectF::contains(const QRectF &r) const \sa united(), operator|=() */ -QRectF QRectF::operator|(const QRectF &r) const +QRectF QRectF::operator|(const QRectF &r) const Q_DECL_NOTHROW { if (isNull()) return r; @@ -2188,7 +2188,7 @@ QRectF QRectF::operator|(const QRectF &r) const \sa operator&=(), intersected() */ -QRectF QRectF::operator&(const QRectF &r) const +QRectF QRectF::operator&(const QRectF &r) const Q_DECL_NOTHROW { qreal l1 = xp; qreal r1 = xp; @@ -2273,7 +2273,7 @@ QRectF QRectF::operator&(const QRectF &r) const \sa contains() */ -bool QRectF::intersects(const QRectF &r) const +bool QRectF::intersects(const QRectF &r) const Q_DECL_NOTHROW { qreal l1 = xp; qreal r1 = xp; @@ -2340,7 +2340,7 @@ bool QRectF::intersects(const QRectF &r) const \sa toRect() */ -QRect QRectF::toAlignedRect() const +QRect QRectF::toAlignedRect() const Q_DECL_NOTHROW { int xmin = int(qFloor(xp)); int xmax = int(qCeil(xp + w)); -- cgit v1.2.3