diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-08-12 14:14:02 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-08-14 15:52:58 +0200 |
commit | 6f0df02d002356625f10683ef84da7685d92a2c4 (patch) | |
tree | 46713209af459ebda534c3404f48c5f5c80ba3f8 /src/corelib/kernel | |
parent | 44cce1a2ea9dadd8b2de93f40de34269dda703c0 (diff) |
Replace Qt CONSTEXPR defines with constexpr
Both normal and relaxed constexpr are required by our new minimum of
C++17.
Change-Id: Ic028b88a2e7a6cb7d5925f3133b9d54859a81744
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r-- | src/corelib/kernel/qdeadlinetimer.h | 6 | ||||
-rw-r--r-- | src/corelib/kernel/qelapsedtimer.h | 2 | ||||
-rw-r--r-- | src/corelib/kernel/qmath.h | 14 | ||||
-rw-r--r-- | src/corelib/kernel/qmetaobject.h | 6 | ||||
-rw-r--r-- | src/corelib/kernel/qmetatype.h | 18 | ||||
-rw-r--r-- | src/corelib/kernel/qsystemerror_p.h | 8 | ||||
-rw-r--r-- | src/corelib/kernel/qtimer.h | 2 | ||||
-rw-r--r-- | src/corelib/kernel/qtmetamacros.h | 8 |
8 files changed, 32 insertions, 32 deletions
diff --git a/src/corelib/kernel/qdeadlinetimer.h b/src/corelib/kernel/qdeadlinetimer.h index 99e09eb31f..180d5fe431 100644 --- a/src/corelib/kernel/qdeadlinetimer.h +++ b/src/corelib/kernel/qdeadlinetimer.h @@ -63,16 +63,16 @@ class Q_CORE_EXPORT QDeadlineTimer public: enum ForeverConstant { Forever }; - Q_DECL_CONSTEXPR QDeadlineTimer(Qt::TimerType type_ = Qt::CoarseTimer) noexcept + constexpr QDeadlineTimer(Qt::TimerType type_ = Qt::CoarseTimer) noexcept : t1(0), t2(0), type(type_) {} - Q_DECL_CONSTEXPR QDeadlineTimer(ForeverConstant, Qt::TimerType type_ = Qt::CoarseTimer) noexcept + constexpr QDeadlineTimer(ForeverConstant, Qt::TimerType type_ = Qt::CoarseTimer) noexcept : t1(std::numeric_limits<qint64>::max()), t2(0), type(type_) {} explicit QDeadlineTimer(qint64 msecs, Qt::TimerType type = Qt::CoarseTimer) noexcept; void swap(QDeadlineTimer &other) noexcept { qSwap(t1, other.t1); qSwap(t2, other.t2); qSwap(type, other.type); } - Q_DECL_CONSTEXPR bool isForever() const noexcept + constexpr bool isForever() const noexcept { return t1 == (std::numeric_limits<qint64>::max)(); } bool hasExpired() const noexcept; diff --git a/src/corelib/kernel/qelapsedtimer.h b/src/corelib/kernel/qelapsedtimer.h index 873847f6b6..8d5704859b 100644 --- a/src/corelib/kernel/qelapsedtimer.h +++ b/src/corelib/kernel/qelapsedtimer.h @@ -56,7 +56,7 @@ public: PerformanceCounter }; - Q_DECL_CONSTEXPR QElapsedTimer() + constexpr QElapsedTimer() : t1(Q_INT64_C(0x8000000000000000)), t2(Q_INT64_C(0x8000000000000000)) { diff --git a/src/corelib/kernel/qmath.h b/src/corelib/kernel/qmath.h index e7b6ab9c0e..5f36de303c 100644 --- a/src/corelib/kernel/qmath.h +++ b/src/corelib/kernel/qmath.h @@ -223,38 +223,38 @@ inline qreal qFastCos(qreal x) return qt_sine_table[si] - (qt_sine_table[ci] + 0.5 * qt_sine_table[si] * d) * d; } -Q_DECL_CONSTEXPR inline float qDegreesToRadians(float degrees) +constexpr inline float qDegreesToRadians(float degrees) { return degrees * float(M_PI/180); } -Q_DECL_CONSTEXPR inline double qDegreesToRadians(double degrees) +constexpr inline double qDegreesToRadians(double degrees) { return degrees * (M_PI / 180); } -Q_DECL_CONSTEXPR inline long double qDegreesToRadians(long double degrees) +constexpr inline long double qDegreesToRadians(long double degrees) { return degrees * (M_PI / 180); } template <typename T, std::enable_if_t<std::is_integral_v<T>, bool> = true> -Q_DECL_CONSTEXPR inline double qDegreesToRadians(T degrees) +constexpr inline double qDegreesToRadians(T degrees) { return qDegreesToRadians(static_cast<double>(degrees)); } -Q_DECL_CONSTEXPR inline float qRadiansToDegrees(float radians) +constexpr inline float qRadiansToDegrees(float radians) { return radians * float(180/M_PI); } -Q_DECL_CONSTEXPR inline double qRadiansToDegrees(double radians) +constexpr inline double qRadiansToDegrees(double radians) { return radians * (180 / M_PI); } -Q_DECL_CONSTEXPR inline long double qRadiansToDegrees(long double radians) +constexpr inline long double qRadiansToDegrees(long double radians) { return radians * (180 / M_PI); } diff --git a/src/corelib/kernel/qmetaobject.h b/src/corelib/kernel/qmetaobject.h index 20a5c67586..d013bfce65 100644 --- a/src/corelib/kernel/qmetaobject.h +++ b/src/corelib/kernel/qmetaobject.h @@ -51,7 +51,7 @@ QT_BEGIN_NAMESPACE class Q_CORE_EXPORT QMetaMethod { public: - Q_DECL_CONSTEXPR inline QMetaMethod() : mobj(nullptr), data({ nullptr }) {} + constexpr inline QMetaMethod() : mobj(nullptr), data({ nullptr }) {} QByteArray methodSignature() const; QByteArray name() const; @@ -218,7 +218,7 @@ inline bool operator!=(const QMetaMethod &m1, const QMetaMethod &m2) class Q_CORE_EXPORT QMetaEnum { public: - Q_DECL_CONSTEXPR inline QMetaEnum() : mobj(nullptr), data({ nullptr }) {} + constexpr inline QMetaEnum() : mobj(nullptr), data({ nullptr }) {} const char *name() const; const char *enumName() const; @@ -347,7 +347,7 @@ private: class Q_CORE_EXPORT QMetaClassInfo { public: - Q_DECL_CONSTEXPR inline QMetaClassInfo() : mobj(nullptr), data({ nullptr }) {} + constexpr inline QMetaClassInfo() : mobj(nullptr), data({ nullptr }) {} const char *name() const; const char *value() const; inline const QMetaObject *enclosingMetaObject() const { return mobj; } diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index 88a888c956..527feffa54 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -71,7 +71,7 @@ template <typename T> struct QMetaTypeId2; template <typename T> -inline Q_DECL_CONSTEXPR int qMetaTypeId(); +inline constexpr int qMetaTypeId(); // F is a tuple: (QMetaType::TypeName, QMetaType::TypeNameID, RealType) // ### Qt6: reorder the types to match the C++ integral type ranking @@ -1636,7 +1636,7 @@ template <typename T> struct QMetaTypeId2 { enum { Defined = QMetaTypeId<T>::Defined, IsBuiltIn=false }; - static inline Q_DECL_CONSTEXPR int qt_metatype_id() { return QMetaTypeId<T>::qt_metatype_id(); } + static inline constexpr int qt_metatype_id() { return QMetaTypeId<T>::qt_metatype_id(); } }; template <typename T> @@ -1648,11 +1648,11 @@ struct QMetaTypeId2<T&> { enum {Defined = false }; }; namespace QtPrivate { template <typename T, bool Defined = QMetaTypeId2<T>::Defined> struct QMetaTypeIdHelper { - static inline Q_DECL_CONSTEXPR int qt_metatype_id() + static inline constexpr int qt_metatype_id() { return QMetaTypeId2<T>::qt_metatype_id(); } }; template <typename T> struct QMetaTypeIdHelper<T, false> { - static inline Q_DECL_CONSTEXPR int qt_metatype_id() + static inline constexpr int qt_metatype_id() { return -1; } }; @@ -1764,7 +1764,7 @@ void qRegisterMetaTypeStreamOperators(const char *typeName #endif // QT_NO_DATASTREAM template <typename T> -inline Q_DECL_CONSTEXPR int qMetaTypeId() +inline constexpr int qMetaTypeId() { if constexpr (bool(QMetaTypeId2<T>::IsBuiltIn)) { return QMetaTypeId2<T>::MetaType; @@ -1774,7 +1774,7 @@ inline Q_DECL_CONSTEXPR int qMetaTypeId() } template <typename T> -inline Q_DECL_CONSTEXPR int qRegisterMetaType() +inline constexpr int qRegisterMetaType() { return qMetaTypeId<T>(); } @@ -1782,11 +1782,11 @@ inline Q_DECL_CONSTEXPR int qRegisterMetaType() #if QT_DEPRECATED_SINCE(5, 1) && !defined(Q_CLANG_QDOC) // There used to be a T *dummy = 0 argument in Qt 4.0 to support MSVC6 template <typename T> -QT_DEPRECATED inline Q_DECL_CONSTEXPR int qMetaTypeId(T *) +QT_DEPRECATED inline constexpr int qMetaTypeId(T *) { return qMetaTypeId<T>(); } #ifndef Q_CC_SUN template <typename T> -QT_DEPRECATED inline Q_DECL_CONSTEXPR int qRegisterMetaType(T *) +QT_DEPRECATED inline constexpr int qRegisterMetaType(T *) { return qRegisterMetaType<T>(); } #endif #endif @@ -1935,7 +1935,7 @@ inline int qRegisterMetaTypeStreamOperators() template<> struct QMetaTypeId2<NAME> \ { \ enum { Defined = 1, IsBuiltIn = true, MetaType = METATYPEID }; \ - static inline Q_DECL_CONSTEXPR int qt_metatype_id() { return METATYPEID; } \ + static inline constexpr int qt_metatype_id() { return METATYPEID; } \ static constexpr const char * const name = #NAME; \ }; \ QT_END_NAMESPACE diff --git a/src/corelib/kernel/qsystemerror_p.h b/src/corelib/kernel/qsystemerror_p.h index abc2f1efc1..cae04aeaa1 100644 --- a/src/corelib/kernel/qsystemerror_p.h +++ b/src/corelib/kernel/qsystemerror_p.h @@ -66,15 +66,15 @@ public: NativeError }; - Q_DECL_CONSTEXPR explicit QSystemError(int error, ErrorScope scope) + constexpr explicit QSystemError(int error, ErrorScope scope) : errorCode(error), errorScope(scope) { } - Q_DECL_CONSTEXPR QSystemError() = default; + constexpr QSystemError() = default; QString toString() const { return string(errorScope, errorCode); } - Q_DECL_CONSTEXPR ErrorScope scope() const { return errorScope; } - Q_DECL_CONSTEXPR int error() const { return errorCode; } + constexpr ErrorScope scope() const { return errorScope; } + constexpr int error() const { return errorCode; } static Q_CORE_EXPORT QString string(ErrorScope errorScope, int errorCode); static Q_CORE_EXPORT QString stdString(int errorCode = -1); diff --git a/src/corelib/kernel/qtimer.h b/src/corelib/kernel/qtimer.h index c55fd8d6c3..66df5a7d4d 100644 --- a/src/corelib/kernel/qtimer.h +++ b/src/corelib/kernel/qtimer.h @@ -218,7 +218,7 @@ private: inline int startTimer(int){ return -1;} inline void killTimer(int){} - static Q_DECL_CONSTEXPR Qt::TimerType defaultTypeFor(int msecs) noexcept + static constexpr Qt::TimerType defaultTypeFor(int msecs) noexcept { return msecs >= 2000 ? Qt::CoarseTimer : Qt::PreciseTimer; } static void singleShotImpl(int msec, Qt::TimerType timerType, const QObject *receiver, QtPrivate::QSlotObjectBase *slotObj); diff --git a/src/corelib/kernel/qtmetamacros.h b/src/corelib/kernel/qtmetamacros.h index 0d7b8c0543..8612cc4fc5 100644 --- a/src/corelib/kernel/qtmetamacros.h +++ b/src/corelib/kernel/qtmetamacros.h @@ -134,13 +134,13 @@ QT_BEGIN_NAMESPACE #define Q_ENUMS(x) QT_ANNOTATE_CLASS(qt_enums, x) #define Q_FLAGS(x) QT_ANNOTATE_CLASS(qt_enums, x) #define Q_ENUM_IMPL(ENUM) \ - friend Q_DECL_CONSTEXPR const QMetaObject *qt_getEnumMetaObject(ENUM) noexcept { return &staticMetaObject; } \ - friend Q_DECL_CONSTEXPR const char *qt_getEnumName(ENUM) noexcept { return #ENUM; } + friend constexpr const QMetaObject *qt_getEnumMetaObject(ENUM) noexcept { return &staticMetaObject; } \ + friend constexpr const char *qt_getEnumName(ENUM) noexcept { return #ENUM; } #define Q_ENUM(x) Q_ENUMS(x) Q_ENUM_IMPL(x) #define Q_FLAG(x) Q_FLAGS(x) Q_ENUM_IMPL(x) #define Q_ENUM_NS_IMPL(ENUM) \ - inline Q_DECL_CONSTEXPR const QMetaObject *qt_getEnumMetaObject(ENUM) noexcept { return &staticMetaObject; } \ - inline Q_DECL_CONSTEXPR const char *qt_getEnumName(ENUM) noexcept { return #ENUM; } + inline constexpr const QMetaObject *qt_getEnumMetaObject(ENUM) noexcept { return &staticMetaObject; } \ + inline constexpr const char *qt_getEnumName(ENUM) noexcept { return #ENUM; } #define Q_ENUM_NS(x) Q_ENUMS(x) Q_ENUM_NS_IMPL(x) #define Q_FLAG_NS(x) Q_FLAGS(x) Q_ENUM_NS_IMPL(x) #define Q_SCRIPTABLE QT_ANNOTATE_FUNCTION(qt_scriptable) |