summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2020-10-25 13:10:21 +0100
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2020-10-27 12:49:39 +0100
commitdc77b86be5010ef639d8222c4cb1866379101b5b (patch)
treecbb0ce892bc76279f66976038987c2b0bdeb1735
parentf8a83fc5c0aee1290a3e6b9a64ea3d50a07ee71d (diff)
Make QElapsedTimer comparison operators hidden friends
Reduce ADL noise. Clean up documentation and parameter naming a bit, while at it. Change-Id: Ie9eb2a63b8e87a9ffc019b8fff5bd1c6bafaaf43 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
-rw-r--r--src/corelib/kernel/qelapsedtimer.cpp17
-rw-r--r--src/corelib/kernel/qelapsedtimer.h10
-rw-r--r--src/corelib/kernel/qelapsedtimer_generic.cpp13
3 files changed, 20 insertions, 20 deletions
diff --git a/src/corelib/kernel/qelapsedtimer.cpp b/src/corelib/kernel/qelapsedtimer.cpp
index 662b9968be..af26a523c0 100644
--- a/src/corelib/kernel/qelapsedtimer.cpp
+++ b/src/corelib/kernel/qelapsedtimer.cpp
@@ -213,15 +213,24 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn bool QElapsedTimer::operator ==(const QElapsedTimer &other) const
+ \fn bool QElapsedTimer::operator==(const QElapsedTimer &lhs, const QElapsedTimer &rhs) noexcept
- Returns \c true if this object and \a other contain the same time.
+ Returns \c true if \a lhs and \a rhs contain the same time, false otherwise.
*/
+/*!
+ \fn bool QElapsedTimer::operator!=(const QElapsedTimer &lhs, const QElapsedTimer &rhs) noexcept
+ Returns \c true if \a lhs and \a rhs contain different times, false otherwise.
+*/
/*!
- \fn bool QElapsedTimer::operator !=(const QElapsedTimer &other) const
+ \fn bool operator<(const QElapsedTimer &lhs, const QElapsedTimer &rhs) noexcept
+ \relates QElapsedTimer
+
+ Returns \c true if \a lhs was started before \a rhs, false otherwise.
- Returns \c true if this object and \a other contain different times.
+ The returned value is undefined if one of the two parameters is invalid
+ and the other isn't. However, two invalid timers are equal and thus this
+ function will return false.
*/
static const qint64 invalidData = Q_INT64_C(0x8000000000000000);
diff --git a/src/corelib/kernel/qelapsedtimer.h b/src/corelib/kernel/qelapsedtimer.h
index 8d5704859b..a7523add19 100644
--- a/src/corelib/kernel/qelapsedtimer.h
+++ b/src/corelib/kernel/qelapsedtimer.h
@@ -78,12 +78,12 @@ public:
qint64 msecsTo(const QElapsedTimer &other) const noexcept;
qint64 secsTo(const QElapsedTimer &other) const noexcept;
- bool operator==(const QElapsedTimer &other) const noexcept
- { return t1 == other.t1 && t2 == other.t2; }
- bool operator!=(const QElapsedTimer &other) const noexcept
- { return !(*this == other); }
+ friend bool operator==(const QElapsedTimer &lhs, const QElapsedTimer &rhs) noexcept
+ { return lhs.t1 == rhs.t1 && lhs.t2 == rhs.t2; }
+ friend bool operator!=(const QElapsedTimer &lhs, const QElapsedTimer &rhs) noexcept
+ { return !(lhs == rhs); }
- friend bool Q_CORE_EXPORT operator<(const QElapsedTimer &v1, const QElapsedTimer &v2) noexcept;
+ friend bool Q_CORE_EXPORT operator<(const QElapsedTimer &lhs, const QElapsedTimer &rhs) noexcept;
private:
qint64 t1;
diff --git a/src/corelib/kernel/qelapsedtimer_generic.cpp b/src/corelib/kernel/qelapsedtimer_generic.cpp
index fe959e3c94..4201e37c0b 100644
--- a/src/corelib/kernel/qelapsedtimer_generic.cpp
+++ b/src/corelib/kernel/qelapsedtimer_generic.cpp
@@ -188,18 +188,9 @@ qint64 QElapsedTimer::secsTo(const QElapsedTimer &other) const noexcept
return msecsTo(other) / 1000;
}
-/*!
- \relates QElapsedTimer
-
- Returns \c true if \a v1 was started before \a v2, false otherwise.
-
- The returned value is undefined if one of the two parameters is invalid
- and the other isn't. However, two invalid timers are equal and thus this
- function will return false.
-*/
-bool operator<(const QElapsedTimer &v1, const QElapsedTimer &v2) noexcept
+bool operator<(const QElapsedTimer &lhs, const QElapsedTimer &rhs) noexcept
{
- return v1.t1 < v2.t1;
+ return lhs.t1 < rhs.t1;
}
QDeadlineTimer QDeadlineTimer::current(Qt::TimerType timerType) noexcept