diff options
Diffstat (limited to 'src/corelib/global')
-rw-r--r-- | src/corelib/global/qendian.h | 52 | ||||
-rw-r--r-- | src/corelib/global/qendian_p.h | 2 | ||||
-rw-r--r-- | src/corelib/global/qflags.h | 90 | ||||
-rw-r--r-- | src/corelib/global/qglobal.h | 44 | ||||
-rw-r--r-- | src/corelib/global/qlogging.h | 10 | ||||
-rw-r--r-- | src/corelib/global/qnumeric_p.h | 6 | ||||
-rw-r--r-- | src/corelib/global/qoperatingsystemversion.h | 14 | ||||
-rw-r--r-- | src/corelib/global/qrandom.cpp | 4 | ||||
-rw-r--r-- | src/corelib/global/qrandom.h | 10 |
9 files changed, 116 insertions, 116 deletions
diff --git a/src/corelib/global/qendian.h b/src/corelib/global/qendian.h index a50ade4aa4..99b529f17c 100644 --- a/src/corelib/global/qendian.h +++ b/src/corelib/global/qendian.h @@ -89,7 +89,7 @@ template <typename T> Q_ALWAYS_INLINE T qFromUnaligned(const void *src) // These definitions are written so that they are recognized by most compilers // as bswap and replaced with single instruction builtins if available. -inline Q_DECL_CONSTEXPR quint64 qbswap_helper(quint64 source) +inline constexpr quint64 qbswap_helper(quint64 source) { return 0 | ((source & Q_UINT64_C(0x00000000000000ff)) << 56) @@ -102,7 +102,7 @@ inline Q_DECL_CONSTEXPR quint64 qbswap_helper(quint64 source) | ((source & Q_UINT64_C(0xff00000000000000)) >> 56); } -inline Q_DECL_CONSTEXPR quint32 qbswap_helper(quint32 source) +inline constexpr quint32 qbswap_helper(quint32 source) { return 0 | ((source & 0x000000ff) << 24) @@ -111,14 +111,14 @@ inline Q_DECL_CONSTEXPR quint32 qbswap_helper(quint32 source) | ((source & 0xff000000) >> 24); } -inline Q_DECL_CONSTEXPR quint16 qbswap_helper(quint16 source) +inline constexpr quint16 qbswap_helper(quint16 source) { return quint16( 0 | ((source & 0x00ff) << 8) | ((source & 0xff00) >> 8) ); } -inline Q_DECL_CONSTEXPR quint8 qbswap_helper(quint8 source) +inline constexpr quint8 qbswap_helper(quint8 source) { return source; } @@ -130,7 +130,7 @@ inline Q_DECL_CONSTEXPR quint8 qbswap_helper(quint8 source) * and it is therefore a bit more convenient and in most cases more efficient. */ template <typename T, typename = std::enable_if_t<std::is_integral_v<T>>> -inline Q_DECL_CONSTEXPR T qbswap(T source) +inline constexpr T qbswap(T source) { return T(qbswap_helper(typename QIntegerForSizeof<T>::Unsigned(source))); } @@ -182,13 +182,13 @@ template<> Q_CORE_EXPORT void *qbswap<8>(const void *source, qsizetype count, vo #if Q_BYTE_ORDER == Q_BIG_ENDIAN -template <typename T> inline Q_DECL_CONSTEXPR T qToBigEndian(T source) +template <typename T> inline constexpr T qToBigEndian(T source) { return source; } -template <typename T> inline Q_DECL_CONSTEXPR T qFromBigEndian(T source) +template <typename T> inline constexpr T qFromBigEndian(T source) { return source; } -template <typename T> inline Q_DECL_CONSTEXPR T qToLittleEndian(T source) +template <typename T> inline constexpr T qToLittleEndian(T source) { return qbswap(source); } -template <typename T> inline Q_DECL_CONSTEXPR T qFromLittleEndian(T source) +template <typename T> inline constexpr T qFromLittleEndian(T source) { return qbswap(source); } template <typename T> inline void qToBigEndian(T src, void *dest) { qToUnaligned<T>(src, dest); } @@ -205,13 +205,13 @@ template <typename T> inline void qFromLittleEndian(const void *source, qsizetyp { qbswap<sizeof(T)>(source, count, dest); } #else // Q_LITTLE_ENDIAN -template <typename T> inline Q_DECL_CONSTEXPR T qToBigEndian(T source) +template <typename T> inline constexpr T qToBigEndian(T source) { return qbswap(source); } -template <typename T> inline Q_DECL_CONSTEXPR T qFromBigEndian(T source) +template <typename T> inline constexpr T qFromBigEndian(T source) { return qbswap(source); } -template <typename T> inline Q_DECL_CONSTEXPR T qToLittleEndian(T source) +template <typename T> inline constexpr T qToLittleEndian(T source) { return source; } -template <typename T> inline Q_DECL_CONSTEXPR T qFromLittleEndian(T source) +template <typename T> inline constexpr T qFromLittleEndian(T source) { return source; } template <typename T> inline void qToBigEndian(T src, void *dest) { qbswap<T>(src, dest); } @@ -265,7 +265,7 @@ class QSpecialInteger T val; public: QSpecialInteger() = default; - explicit Q_DECL_CONSTEXPR QSpecialInteger(T i) : val(S::toSpecial(i)) {} + explicit constexpr QSpecialInteger(T i) : val(S::toSpecial(i)) {} QSpecialInteger &operator =(T i) { val = S::toSpecial(i); return *this; } operator T() const { return S::fromSpecial(val); } @@ -310,9 +310,9 @@ public: return pre; } - static Q_DECL_CONSTEXPR QSpecialInteger max() + static constexpr QSpecialInteger max() { return QSpecialInteger(std::numeric_limits<T>::max()); } - static Q_DECL_CONSTEXPR QSpecialInteger min() + static constexpr QSpecialInteger min() { return QSpecialInteger(std::numeric_limits<T>::min()); } }; @@ -320,23 +320,23 @@ template<typename T> class QLittleEndianStorageType { public: typedef T StorageType; - static Q_DECL_CONSTEXPR T toSpecial(T source) { return qToLittleEndian(source); } - static Q_DECL_CONSTEXPR T fromSpecial(T source) { return qFromLittleEndian(source); } + static constexpr T toSpecial(T source) { return qToLittleEndian(source); } + static constexpr T fromSpecial(T source) { return qFromLittleEndian(source); } }; template<typename T> class QBigEndianStorageType { public: typedef T StorageType; - static Q_DECL_CONSTEXPR T toSpecial(T source) { return qToBigEndian(source); } - static Q_DECL_CONSTEXPR T fromSpecial(T source) { return qFromBigEndian(source); } + static constexpr T toSpecial(T source) { return qToBigEndian(source); } + static constexpr T fromSpecial(T source) { return qFromBigEndian(source); } }; #ifdef Q_CLANG_QDOC template<typename T> class QLEInteger { public: - explicit Q_DECL_CONSTEXPR QLEInteger(T i); + explicit constexpr QLEInteger(T i); QLEInteger &operator =(T i); operator T() const; bool operator ==(QLEInteger i) const; @@ -356,14 +356,14 @@ public: QLEInteger &operator ++(int); QLEInteger &operator --(int); - static Q_DECL_CONSTEXPR QLEInteger max(); - static Q_DECL_CONSTEXPR QLEInteger min(); + static constexpr QLEInteger max(); + static constexpr QLEInteger min(); }; template<typename T> class QBEInteger { public: - explicit Q_DECL_CONSTEXPR QBEInteger(T i); + explicit constexpr QBEInteger(T i); QBEInteger &operator =(T i); operator T() const; bool operator ==(QBEInteger i) const; @@ -383,8 +383,8 @@ public: QBEInteger &operator ++(int); QBEInteger &operator --(int); - static Q_DECL_CONSTEXPR QBEInteger max(); - static Q_DECL_CONSTEXPR QBEInteger min(); + static constexpr QBEInteger max(); + static constexpr QBEInteger min(); }; #else diff --git a/src/corelib/global/qendian_p.h b/src/corelib/global/qendian_p.h index c830e65b54..d0d79d4ce4 100644 --- a/src/corelib/global/qendian_p.h +++ b/src/corelib/global/qendian_p.h @@ -65,7 +65,7 @@ protected: typedef typename S::StorageType T; typedef typename std::make_unsigned<T>::type UT; - static Q_DECL_CONSTEXPR UT mask() + static constexpr UT mask() { return ((UT(1) << width) - 1) << pos; } diff --git a/src/corelib/global/qflags.h b/src/corelib/global/qflags.h index 3cb46e3a01..cf0cd4b155 100644 --- a/src/corelib/global/qflags.h +++ b/src/corelib/global/qflags.h @@ -52,21 +52,21 @@ class QFlag { int i; public: - Q_DECL_CONSTEXPR inline QFlag(int value) noexcept : i(value) {} - Q_DECL_CONSTEXPR inline operator int() const noexcept { return i; } + constexpr inline QFlag(int value) noexcept : i(value) {} + constexpr inline operator int() const noexcept { return i; } #if !defined(Q_CC_MSVC) // Microsoft Visual Studio has buggy behavior when it comes to // unsigned enums: even if the enum is unsigned, the enum tags are // always signed # if !defined(__LP64__) && !defined(Q_CLANG_QDOC) - Q_DECL_CONSTEXPR inline QFlag(long value) noexcept : i(int(value)) {} - Q_DECL_CONSTEXPR inline QFlag(ulong value) noexcept : i(int(long(value))) {} + constexpr inline QFlag(long value) noexcept : i(int(value)) {} + constexpr inline QFlag(ulong value) noexcept : i(int(long(value))) {} # endif - Q_DECL_CONSTEXPR inline QFlag(uint value) noexcept : i(int(value)) {} - Q_DECL_CONSTEXPR inline QFlag(short value) noexcept : i(int(value)) {} - Q_DECL_CONSTEXPR inline QFlag(ushort value) noexcept : i(int(uint(value))) {} - Q_DECL_CONSTEXPR inline operator uint() const noexcept { return uint(i); } + constexpr inline QFlag(uint value) noexcept : i(int(value)) {} + constexpr inline QFlag(short value) noexcept : i(int(value)) {} + constexpr inline QFlag(ushort value) noexcept : i(int(uint(value))) {} + constexpr inline operator uint() const noexcept { return uint(i); } #endif }; Q_DECLARE_TYPEINFO(QFlag, Q_PRIMITIVE_TYPE); @@ -75,12 +75,12 @@ class QIncompatibleFlag { int i; public: - Q_DECL_CONSTEXPR inline explicit QIncompatibleFlag(int i) noexcept; - Q_DECL_CONSTEXPR inline operator int() const noexcept { return i; } + constexpr inline explicit QIncompatibleFlag(int i) noexcept; + constexpr inline operator int() const noexcept { return i; } }; Q_DECLARE_TYPEINFO(QIncompatibleFlag, Q_PRIMITIVE_TYPE); -Q_DECL_CONSTEXPR inline QIncompatibleFlag::QIncompatibleFlag(int value) noexcept : i(value) {} +constexpr inline QIncompatibleFlag::QIncompatibleFlag(int value) noexcept : i(value) {} #ifndef Q_NO_TYPESAFE_FLAGS @@ -114,48 +114,48 @@ public: typedef Enum enum_type; // compiler-generated copy/move ctor/assignment operators are fine! #ifdef Q_CLANG_QDOC - Q_DECL_CONSTEXPR inline QFlags(const QFlags &other); - Q_DECL_CONSTEXPR inline QFlags &operator=(const QFlags &other); + constexpr inline QFlags(const QFlags &other); + constexpr inline QFlags &operator=(const QFlags &other); #endif - Q_DECL_CONSTEXPR inline QFlags() noexcept : i(0) {} - Q_DECL_CONSTEXPR inline QFlags(Enum flags) noexcept : i(Int(flags)) {} + constexpr inline QFlags() noexcept : i(0) {} + constexpr inline QFlags(Enum flags) noexcept : i(Int(flags)) {} #if QT_DEPRECATED_SINCE(5,15) - QT_DEPRECATED_X("Use default constructor instead") Q_DECL_CONSTEXPR inline QFlags(Zero) noexcept : i(0) {} + QT_DEPRECATED_X("Use default constructor instead") constexpr inline QFlags(Zero) noexcept : i(0) {} #endif - Q_DECL_CONSTEXPR inline QFlags(QFlag flag) noexcept : i(flag) {} + constexpr inline QFlags(QFlag flag) noexcept : i(flag) {} - Q_DECL_CONSTEXPR inline QFlags(std::initializer_list<Enum> flags) noexcept + constexpr inline QFlags(std::initializer_list<Enum> flags) noexcept : i(initializer_list_helper(flags.begin(), flags.end())) {} - Q_DECL_RELAXED_CONSTEXPR inline QFlags &operator&=(int mask) noexcept { i &= mask; return *this; } - Q_DECL_RELAXED_CONSTEXPR inline QFlags &operator&=(uint mask) noexcept { i &= mask; return *this; } - Q_DECL_RELAXED_CONSTEXPR inline QFlags &operator&=(Enum mask) noexcept { i &= Int(mask); return *this; } - Q_DECL_RELAXED_CONSTEXPR inline QFlags &operator|=(QFlags other) noexcept { i |= other.i; return *this; } - Q_DECL_RELAXED_CONSTEXPR inline QFlags &operator|=(Enum other) noexcept { i |= Int(other); return *this; } - Q_DECL_RELAXED_CONSTEXPR inline QFlags &operator^=(QFlags other) noexcept { i ^= other.i; return *this; } - Q_DECL_RELAXED_CONSTEXPR inline QFlags &operator^=(Enum other) noexcept { i ^= Int(other); return *this; } - - Q_DECL_CONSTEXPR inline operator Int() const noexcept { return i; } - - Q_DECL_CONSTEXPR inline QFlags operator|(QFlags other) const noexcept { return QFlags(QFlag(i | other.i)); } - Q_DECL_CONSTEXPR inline QFlags operator|(Enum other) const noexcept { return QFlags(QFlag(i | Int(other))); } - Q_DECL_CONSTEXPR inline QFlags operator^(QFlags other) const noexcept { return QFlags(QFlag(i ^ other.i)); } - Q_DECL_CONSTEXPR inline QFlags operator^(Enum other) const noexcept { return QFlags(QFlag(i ^ Int(other))); } - Q_DECL_CONSTEXPR inline QFlags operator&(int mask) const noexcept { return QFlags(QFlag(i & mask)); } - Q_DECL_CONSTEXPR inline QFlags operator&(uint mask) const noexcept { return QFlags(QFlag(i & mask)); } - Q_DECL_CONSTEXPR inline QFlags operator&(Enum other) const noexcept { return QFlags(QFlag(i & Int(other))); } - Q_DECL_CONSTEXPR inline QFlags operator~() const noexcept { return QFlags(QFlag(~i)); } - - Q_DECL_CONSTEXPR inline bool operator!() const noexcept { return !i; } - - Q_DECL_CONSTEXPR inline bool testFlag(Enum flag) const noexcept { return (i & Int(flag)) == Int(flag) && (Int(flag) != 0 || i == Int(flag) ); } - Q_DECL_RELAXED_CONSTEXPR inline QFlags &setFlag(Enum flag, bool on = true) noexcept + constexpr inline QFlags &operator&=(int mask) noexcept { i &= mask; return *this; } + constexpr inline QFlags &operator&=(uint mask) noexcept { i &= mask; return *this; } + constexpr inline QFlags &operator&=(Enum mask) noexcept { i &= Int(mask); return *this; } + constexpr inline QFlags &operator|=(QFlags other) noexcept { i |= other.i; return *this; } + constexpr inline QFlags &operator|=(Enum other) noexcept { i |= Int(other); return *this; } + constexpr inline QFlags &operator^=(QFlags other) noexcept { i ^= other.i; return *this; } + constexpr inline QFlags &operator^=(Enum other) noexcept { i ^= Int(other); return *this; } + + constexpr inline operator Int() const noexcept { return i; } + + constexpr inline QFlags operator|(QFlags other) const noexcept { return QFlags(QFlag(i | other.i)); } + constexpr inline QFlags operator|(Enum other) const noexcept { return QFlags(QFlag(i | Int(other))); } + constexpr inline QFlags operator^(QFlags other) const noexcept { return QFlags(QFlag(i ^ other.i)); } + constexpr inline QFlags operator^(Enum other) const noexcept { return QFlags(QFlag(i ^ Int(other))); } + constexpr inline QFlags operator&(int mask) const noexcept { return QFlags(QFlag(i & mask)); } + constexpr inline QFlags operator&(uint mask) const noexcept { return QFlags(QFlag(i & mask)); } + constexpr inline QFlags operator&(Enum other) const noexcept { return QFlags(QFlag(i & Int(other))); } + constexpr inline QFlags operator~() const noexcept { return QFlags(QFlag(~i)); } + + constexpr inline bool operator!() const noexcept { return !i; } + + constexpr inline bool testFlag(Enum flag) const noexcept { return (i & Int(flag)) == Int(flag) && (Int(flag) != 0 || i == Int(flag) ); } + constexpr inline QFlags &setFlag(Enum flag, bool on = true) noexcept { return on ? (*this |= flag) : (*this &= ~Int(flag)); } private: - Q_DECL_CONSTEXPR static inline Int initializer_list_helper(typename std::initializer_list<Enum>::const_iterator it, + constexpr static inline Int initializer_list_helper(typename std::initializer_list<Enum>::const_iterator it, typename std::initializer_list<Enum>::const_iterator end) noexcept { @@ -171,13 +171,13 @@ typedef QFlags<Enum> Flags; #endif #define Q_DECLARE_INCOMPATIBLE_FLAGS(Flags) \ -Q_DECL_CONSTEXPR inline QIncompatibleFlag operator|(Flags::enum_type f1, int f2) noexcept \ +constexpr inline QIncompatibleFlag operator|(Flags::enum_type f1, int f2) noexcept \ { return QIncompatibleFlag(int(f1) | f2); } #define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags) \ -Q_DECL_CONSTEXPR inline QFlags<Flags::enum_type> operator|(Flags::enum_type f1, Flags::enum_type f2) noexcept \ +constexpr inline QFlags<Flags::enum_type> operator|(Flags::enum_type f1, Flags::enum_type f2) noexcept \ { return QFlags<Flags::enum_type>(f1) | f2; } \ -Q_DECL_CONSTEXPR inline QFlags<Flags::enum_type> operator|(Flags::enum_type f1, QFlags<Flags::enum_type> f2) noexcept \ +constexpr inline QFlags<Flags::enum_type> operator|(Flags::enum_type f1, QFlags<Flags::enum_type> f2) noexcept \ { return f2 | f1; } Q_DECLARE_INCOMPATIBLE_FLAGS(Flags) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index db858c44b3..140a9562c0 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -603,16 +603,16 @@ using qsizetype = QIntegerForSizeof<std::size_t>::Signed; */ template <typename T> -Q_DECL_CONSTEXPR inline T qAbs(const T &t) { return t >= 0 ? t : -t; } +constexpr inline T qAbs(const T &t) { return t >= 0 ? t : -t; } -Q_DECL_CONSTEXPR inline int qRound(double d) +constexpr inline int qRound(double d) { return d >= 0.0 ? int(d + 0.5) : int(d - double(int(d-1)) + 0.5) + int(d-1); } -Q_DECL_CONSTEXPR inline int qRound(float d) +constexpr inline int qRound(float d) { return d >= 0.0f ? int(d + 0.5f) : int(d - float(int(d-1)) + 0.5f) + int(d-1); } -Q_DECL_CONSTEXPR inline qint64 qRound64(double d) +constexpr inline qint64 qRound64(double d) { return d >= 0.0 ? qint64(d + 0.5) : qint64(d - double(qint64(d-1)) + 0.5) + qint64(d-1); } -Q_DECL_CONSTEXPR inline qint64 qRound64(float d) +constexpr inline qint64 qRound64(float d) { return d >= 0.0f ? qint64(d + 0.5f) : qint64(d - float(qint64(d-1)) + 0.5f) + qint64(d-1); } namespace QTypeTraits { @@ -888,22 +888,22 @@ typedef void (*QFunctionPointer)(); # define Q_UNIMPLEMENTED() qWarning("Unimplemented code.") #endif -Q_REQUIRED_RESULT Q_DECL_CONSTEXPR static inline Q_DECL_UNUSED bool qFuzzyCompare(double p1, double p2) +Q_REQUIRED_RESULT constexpr static inline Q_DECL_UNUSED bool qFuzzyCompare(double p1, double p2) { return (qAbs(p1 - p2) * 1000000000000. <= qMin(qAbs(p1), qAbs(p2))); } -Q_REQUIRED_RESULT Q_DECL_CONSTEXPR static inline Q_DECL_UNUSED bool qFuzzyCompare(float p1, float p2) +Q_REQUIRED_RESULT constexpr static inline Q_DECL_UNUSED bool qFuzzyCompare(float p1, float p2) { return (qAbs(p1 - p2) * 100000.f <= qMin(qAbs(p1), qAbs(p2))); } -Q_REQUIRED_RESULT Q_DECL_CONSTEXPR static inline Q_DECL_UNUSED bool qFuzzyIsNull(double d) +Q_REQUIRED_RESULT constexpr static inline Q_DECL_UNUSED bool qFuzzyIsNull(double d) { return qAbs(d) <= 0.000000000001; } -Q_REQUIRED_RESULT Q_DECL_CONSTEXPR static inline Q_DECL_UNUSED bool qFuzzyIsNull(float f) +Q_REQUIRED_RESULT constexpr static inline Q_DECL_UNUSED bool qFuzzyIsNull(float f) { return qAbs(f) <= 0.00001f; } @@ -911,12 +911,12 @@ Q_REQUIRED_RESULT Q_DECL_CONSTEXPR static inline Q_DECL_UNUSED bool qFuzzyIsNul QT_WARNING_PUSH QT_WARNING_DISABLE_FLOAT_COMPARE -Q_REQUIRED_RESULT Q_DECL_CONSTEXPR static inline Q_DECL_UNUSED bool qIsNull(double d) noexcept +Q_REQUIRED_RESULT constexpr static inline Q_DECL_UNUSED bool qIsNull(double d) noexcept { return d == 0.0; } -Q_REQUIRED_RESULT Q_DECL_CONSTEXPR static inline Q_DECL_UNUSED bool qIsNull(float f) noexcept +Q_REQUIRED_RESULT constexpr static inline Q_DECL_UNUSED bool qIsNull(float f) noexcept { return f == 0.0f; } @@ -1029,14 +1029,14 @@ inline bool qt_is_permutation(ForwardIterator1 first1, ForwardIterator1 last1, // this adds const to non-const objects (like std::as_const) template <typename T> -Q_DECL_CONSTEXPR typename std::add_const<T>::type &qAsConst(T &t) noexcept { return t; } +constexpr typename std::add_const<T>::type &qAsConst(T &t) noexcept { return t; } // prevent rvalue arguments: template <typename T> void qAsConst(const T &&) = delete; // like std::exchange template <typename T, typename U = T> -Q_DECL_RELAXED_CONSTEXPR T qExchange(T &t, U &&newValue) +constexpr T qExchange(T &t, U &&newValue) { T old = std::move(t); t = std::forward<U>(newValue); @@ -1200,11 +1200,11 @@ template <typename... Args> struct QNonConstOverload { template <typename R, typename T> - Q_DECL_CONSTEXPR auto operator()(R (T::*ptr)(Args...)) const noexcept -> decltype(ptr) + constexpr auto operator()(R (T::*ptr)(Args...)) const noexcept -> decltype(ptr) { return ptr; } template <typename R, typename T> - static Q_DECL_CONSTEXPR auto of(R (T::*ptr)(Args...)) noexcept -> decltype(ptr) + static constexpr auto of(R (T::*ptr)(Args...)) noexcept -> decltype(ptr) { return ptr; } }; @@ -1212,11 +1212,11 @@ template <typename... Args> struct QConstOverload { template <typename R, typename T> - Q_DECL_CONSTEXPR auto operator()(R (T::*ptr)(Args...) const) const noexcept -> decltype(ptr) + constexpr auto operator()(R (T::*ptr)(Args...) const) const noexcept -> decltype(ptr) { return ptr; } template <typename R, typename T> - static Q_DECL_CONSTEXPR auto of(R (T::*ptr)(Args...) const) noexcept -> decltype(ptr) + static constexpr auto of(R (T::*ptr)(Args...) const) noexcept -> decltype(ptr) { return ptr; } }; @@ -1229,18 +1229,18 @@ struct QOverload : QConstOverload<Args...>, QNonConstOverload<Args...> using QNonConstOverload<Args...>::operator(); template <typename R> - Q_DECL_CONSTEXPR auto operator()(R (*ptr)(Args...)) const noexcept -> decltype(ptr) + constexpr auto operator()(R (*ptr)(Args...)) const noexcept -> decltype(ptr) { return ptr; } template <typename R> - static Q_DECL_CONSTEXPR auto of(R (*ptr)(Args...)) noexcept -> decltype(ptr) + static constexpr auto of(R (*ptr)(Args...)) noexcept -> decltype(ptr) { return ptr; } }; #if defined(__cpp_variable_templates) && __cpp_variable_templates >= 201304 // C++14 -template <typename... Args> Q_CONSTEXPR Q_DECL_UNUSED QOverload<Args...> qOverload = {}; -template <typename... Args> Q_CONSTEXPR Q_DECL_UNUSED QConstOverload<Args...> qConstOverload = {}; -template <typename... Args> Q_CONSTEXPR Q_DECL_UNUSED QNonConstOverload<Args...> qNonConstOverload = {}; +template <typename... Args> constexpr Q_DECL_UNUSED QOverload<Args...> qOverload = {}; +template <typename... Args> constexpr Q_DECL_UNUSED QConstOverload<Args...> qConstOverload = {}; +template <typename... Args> constexpr Q_DECL_UNUSED QNonConstOverload<Args...> qNonConstOverload = {}; #endif #endif diff --git a/src/corelib/global/qlogging.h b/src/corelib/global/qlogging.h index be9707ff06..e905929c78 100644 --- a/src/corelib/global/qlogging.h +++ b/src/corelib/global/qlogging.h @@ -63,8 +63,8 @@ class QMessageLogContext { Q_DISABLE_COPY(QMessageLogContext) public: - Q_DECL_CONSTEXPR QMessageLogContext() noexcept = default; - Q_DECL_CONSTEXPR QMessageLogContext(const char *fileName, int lineNumber, const char *functionName, const char *categoryName) noexcept + constexpr QMessageLogContext() noexcept = default; + constexpr QMessageLogContext(const char *fileName, int lineNumber, const char *functionName, const char *categoryName) noexcept : line(lineNumber), file(fileName), function(functionName), category(categoryName) {} int version = 2; @@ -86,10 +86,10 @@ class Q_CORE_EXPORT QMessageLogger { Q_DISABLE_COPY(QMessageLogger) public: - Q_DECL_CONSTEXPR QMessageLogger() : context() {} - Q_DECL_CONSTEXPR QMessageLogger(const char *file, int line, const char *function) + constexpr QMessageLogger() : context() {} + constexpr QMessageLogger(const char *file, int line, const char *function) : context(file, line, function, "default") {} - Q_DECL_CONSTEXPR QMessageLogger(const char *file, int line, const char *function, const char *category) + constexpr QMessageLogger(const char *file, int line, const char *function, const char *category) : context(file, line, function, category) {} void debug(const char *msg, ...) const Q_ATTRIBUTE_FORMAT_PRINTF(2, 3); diff --git a/src/corelib/global/qnumeric_p.h b/src/corelib/global/qnumeric_p.h index 790a00bdb5..2c5d19d274 100644 --- a/src/corelib/global/qnumeric_p.h +++ b/src/corelib/global/qnumeric_p.h @@ -126,7 +126,7 @@ Q_DECL_CONST_FUNCTION static inline int fpclassify(float f) { return std::fpclas #endif } -Q_DECL_CONSTEXPR Q_DECL_CONST_FUNCTION static inline double qt_inf() noexcept +constexpr Q_DECL_CONST_FUNCTION static inline double qt_inf() noexcept { static_assert(std::numeric_limits<double>::has_infinity, "platform has no definition for infinity for type double"); @@ -134,7 +134,7 @@ Q_DECL_CONSTEXPR Q_DECL_CONST_FUNCTION static inline double qt_inf() noexcept } #if QT_CONFIG(signaling_nan) -Q_DECL_CONSTEXPR Q_DECL_CONST_FUNCTION static inline double qt_snan() noexcept +constexpr Q_DECL_CONST_FUNCTION static inline double qt_snan() noexcept { static_assert(std::numeric_limits<double>::has_signaling_NaN, "platform has no definition for signaling NaN for type double"); @@ -143,7 +143,7 @@ Q_DECL_CONSTEXPR Q_DECL_CONST_FUNCTION static inline double qt_snan() noexcept #endif // Quiet NaN -Q_DECL_CONSTEXPR Q_DECL_CONST_FUNCTION static inline double qt_qnan() noexcept +constexpr Q_DECL_CONST_FUNCTION static inline double qt_qnan() noexcept { static_assert(std::numeric_limits<double>::has_quiet_NaN, "platform has no definition for quiet NaN for type double"); diff --git a/src/corelib/global/qoperatingsystemversion.h b/src/corelib/global/qoperatingsystemversion.h index 1a8d38400b..37ace76755 100644 --- a/src/corelib/global/qoperatingsystemversion.h +++ b/src/corelib/global/qoperatingsystemversion.h @@ -85,7 +85,7 @@ public: static const QOperatingSystemVersion AndroidNougat_MR1; static const QOperatingSystemVersion AndroidOreo; - Q_DECL_CONSTEXPR QOperatingSystemVersion(OSType osType, + constexpr QOperatingSystemVersion(OSType osType, int vmajor, int vminor = -1, int vmicro = -1) : m_os(osType), m_major(qMax(-1, vmajor)), @@ -95,7 +95,7 @@ public: static QOperatingSystemVersion current(); - static Q_DECL_CONSTEXPR OSType currentType() + static constexpr OSType currentType() { #if defined(Q_OS_WIN) return Windows; @@ -114,15 +114,15 @@ public: #endif } - Q_DECL_CONSTEXPR int majorVersion() const { return m_major; } - Q_DECL_CONSTEXPR int minorVersion() const { return m_minor; } - Q_DECL_CONSTEXPR int microVersion() const { return m_micro; } + constexpr int majorVersion() const { return m_major; } + constexpr int minorVersion() const { return m_minor; } + constexpr int microVersion() const { return m_micro; } - Q_DECL_CONSTEXPR int segmentCount() const + constexpr int segmentCount() const { return m_micro >= 0 ? 3 : m_minor >= 0 ? 2 : m_major >= 0 ? 1 : 0; } bool isAnyOfType(std::initializer_list<OSType> types) const; - Q_DECL_CONSTEXPR OSType type() const { return m_os; } + constexpr OSType type() const { return m_os; } QString name() const; friend bool operator>(const QOperatingSystemVersion &lhs, const QOperatingSystemVersion &rhs) diff --git a/src/corelib/global/qrandom.cpp b/src/corelib/global/qrandom.cpp index 1d2a29c074..424fa4449e 100644 --- a/src/corelib/global/qrandom.cpp +++ b/src/corelib/global/qrandom.cpp @@ -155,7 +155,7 @@ struct QRandomGenerator::SystemGenerator qt_safe_close(fd); } - Q_DECL_CONSTEXPR SystemGenerator() : fdp1 Q_BASIC_ATOMIC_INITIALIZER(0) {} + constexpr SystemGenerator() : fdp1 Q_BASIC_ATOMIC_INITIALIZER(0) {} qsizetype fillBuffer(void *buffer, qsizetype count) { @@ -1057,7 +1057,7 @@ inline QRandomGenerator::SystemGenerator &QRandomGenerator::SystemGenerator::sel \sa QRandomGenerator::generate(), QRandomGenerator::generate64() */ -Q_DECL_CONSTEXPR QRandomGenerator::Storage::Storage() +constexpr QRandomGenerator::Storage::Storage() : dummy(0) { // nothing diff --git a/src/corelib/global/qrandom.h b/src/corelib/global/qrandom.h index 4e27ef1edc..7bb90de2bb 100644 --- a/src/corelib/global/qrandom.h +++ b/src/corelib/global/qrandom.h @@ -169,8 +169,8 @@ public: void seed(quint32 s = 1) { *this = { s }; } void seed(std::seed_seq &sseq) noexcept { *this = { sseq }; } Q_CORE_EXPORT void discard(unsigned long long z); - static Q_DECL_CONSTEXPR result_type min() { return std::numeric_limits<result_type>::min(); } - static Q_DECL_CONSTEXPR result_type max() { return std::numeric_limits<result_type>::max(); } + static constexpr result_type min() { return std::numeric_limits<result_type>::min(); } + static constexpr result_type max() { return std::numeric_limits<result_type>::max(); } static inline Q_DECL_CONST_FUNCTION QRandomGenerator *system(); static inline Q_DECL_CONST_FUNCTION QRandomGenerator *global(); @@ -203,7 +203,7 @@ private: static_assert(std::is_trivially_destructible<RandomEngine>::value, "std::mersenne_twister not trivially destructible as expected"); - Q_DECL_CONSTEXPR Storage(); + constexpr Storage(); }; uint type; Storage storage; @@ -245,8 +245,8 @@ public: QRandomGenerator::discard(z * 2); } - static Q_DECL_CONSTEXPR result_type min() { return std::numeric_limits<result_type>::min(); } - static Q_DECL_CONSTEXPR result_type max() { return std::numeric_limits<result_type>::max(); } + static constexpr result_type min() { return std::numeric_limits<result_type>::min(); } + static constexpr result_type max() { return std::numeric_limits<result_type>::max(); } static Q_DECL_CONST_FUNCTION Q_CORE_EXPORT QRandomGenerator64 *system(); static Q_DECL_CONST_FUNCTION Q_CORE_EXPORT QRandomGenerator64 *global(); static Q_CORE_EXPORT QRandomGenerator64 securelySeeded(); |