From a1e62e7ba14b00ac7c361936a18e7bc42bf1286d Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 2 Apr 2019 10:54:54 +0200 Subject: [PATCH] Replace Q_DECL_NOEXCEPT with noexcept in corelib In preparation of Qt6 move away from pre-C++11 macros. Change-Id: I44126693c20c18eca5620caab4f7e746218e0ce3 Reviewed-by: Thiago Macieira --- src/corelib/codecs/qtextcodec.cpp | 2 +- src/corelib/codecs/qutfcodec.cpp | 4 +- src/corelib/codecs/qutfcodec_p.h | 2 +- src/corelib/global/qflags.h | 76 +-- src/corelib/global/qfloat16.cpp | 16 +- src/corelib/global/qfloat16.h | 82 +-- src/corelib/global/qglobal.cpp | 18 +- src/corelib/global/qglobal.h | 32 +- src/corelib/global/qglobalstatic.h | 2 +- src/corelib/global/qlibraryinfo.cpp | 4 +- src/corelib/global/qlibraryinfo.h | 4 +- src/corelib/global/qlogging.cpp | 6 +- src/corelib/global/qlogging.h | 4 +- src/corelib/global/qnamespace.h | 6 +- src/corelib/global/qnumeric_p.h | 6 +- src/corelib/global/qrandom.cpp | 20 +- src/corelib/global/qrandom.h | 6 +- src/corelib/io/qdebug.h | 2 +- src/corelib/io/qdir.h | 6 +- src/corelib/io/qfileinfo.h | 4 +- src/corelib/io/qprocess.h | 4 +- src/corelib/io/qstorageinfo.h | 4 +- src/corelib/io/qurl.cpp | 2 +- src/corelib/io/qurl.h | 10 +- src/corelib/io/qurlquery.cpp | 2 +- src/corelib/io/qurlquery.h | 8 +- src/corelib/io/qurlrecode.cpp | 2 +- src/corelib/itemmodels/qabstractitemmodel.h | 38 +- src/corelib/itemmodels/qitemselectionmodel.h | 8 +- src/corelib/kernel/qcore_unix_p.h | 2 +- src/corelib/kernel/qcoreapplication.cpp | 2 +- src/corelib/kernel/qcoreevent.cpp | 8 +- src/corelib/kernel/qcoreevent.h | 2 +- src/corelib/kernel/qdeadlinetimer.cpp | 24 +- src/corelib/kernel/qdeadlinetimer.h | 50 +- src/corelib/kernel/qelapsedtimer.cpp | 6 +- src/corelib/kernel/qelapsedtimer.h | 30 +- src/corelib/kernel/qelapsedtimer_generic.cpp | 22 +- src/corelib/kernel/qelapsedtimer_mac.cpp | 24 +- src/corelib/kernel/qelapsedtimer_unix.cpp | 24 +- src/corelib/kernel/qelapsedtimer_win.cpp | 22 +- src/corelib/kernel/qeventdispatcher_unix_p.h | 12 +- src/corelib/kernel/qfunctions_fake_env_p.h | 4 +- src/corelib/kernel/qmetaobject.cpp | 2 +- src/corelib/kernel/qmetatype.cpp | 2 +- src/corelib/kernel/qobject.cpp | 2 +- src/corelib/kernel/qobject.h | 32 +- src/corelib/kernel/qobjectdefs.h | 14 +- src/corelib/kernel/qobjectdefs_impl.h | 4 +- src/corelib/kernel/qtimer.h | 2 +- src/corelib/kernel/qvariant.h | 14 +- src/corelib/mimetypes/qmimeglobpattern_p.h | 2 +- src/corelib/mimetypes/qmimemagicrule_p.h | 2 +- .../mimetypes/qmimemagicrulematcher_p.h | 2 +- src/corelib/mimetypes/qmimetype.cpp | 2 +- src/corelib/mimetypes/qmimetype.h | 8 +- src/corelib/plugin/quuid.cpp | 16 +- src/corelib/plugin/quuid.h | 44 +- src/corelib/serialization/qjson_p.h | 12 +- src/corelib/serialization/qjsonarray.h | 6 +- src/corelib/serialization/qjsondocument.h | 6 +- src/corelib/serialization/qjsonobject.h | 6 +- src/corelib/serialization/qjsonvalue.h | 6 +- src/corelib/serialization/qtextstream.h | 4 +- src/corelib/serialization/qxmlstream.h | 24 +- src/corelib/statemachine/qstatemachine_p.h | 12 +- src/corelib/thread/qatomic.h | 18 +- src/corelib/thread/qatomic_bootstrap.h | 10 +- src/corelib/thread/qatomic_cxx11.h | 86 +-- src/corelib/thread/qatomic_msvc.h | 92 +-- src/corelib/thread/qbasicatomic.h | 194 +++--- src/corelib/thread/qfutex_p.h | 2 +- src/corelib/thread/qgenericatomic.h | 98 +-- src/corelib/thread/qmutex.cpp | 14 +- src/corelib/thread/qmutex.h | 54 +- src/corelib/thread/qmutex_linux.cpp | 8 +- src/corelib/thread/qmutex_mac.cpp | 2 +- src/corelib/thread/qmutex_p.h | 4 +- src/corelib/thread/qmutex_unix.cpp | 4 +- src/corelib/thread/qmutex_win.cpp | 2 +- src/corelib/thread/qorderedmutexlocker_p.h | 2 +- src/corelib/thread/qreadwritelock.h | 36 +- src/corelib/thread/qsemaphore.h | 14 +- src/corelib/thread/qthread.cpp | 4 +- src/corelib/thread/qthread.h | 4 +- src/corelib/thread/qthread_p.h | 4 +- src/corelib/thread/qthread_unix.cpp | 4 +- src/corelib/thread/qthread_win.cpp | 8 +- src/corelib/tools/qalgorithms.h | 62 +- src/corelib/tools/qarraydata.cpp | 6 +- src/corelib/tools/qarraydata.h | 10 +- src/corelib/tools/qarraydatapointer.h | 8 +- src/corelib/tools/qbitarray.h | 10 +- src/corelib/tools/qbytearray.cpp | 6 +- src/corelib/tools/qbytearray.h | 52 +- src/corelib/tools/qbytearraymatcher.cpp | 2 +- src/corelib/tools/qbytearraymatcher.h | 14 +- src/corelib/tools/qcache.h | 4 +- src/corelib/tools/qchar.cpp | 56 +- src/corelib/tools/qchar.h | 240 ++++---- src/corelib/tools/qcollator.h | 10 +- src/corelib/tools/qcommandlineoption.cpp | 4 +- src/corelib/tools/qcommandlineoption.h | 4 +- src/corelib/tools/qdatetime.cpp | 20 +- src/corelib/tools/qdatetime.h | 18 +- src/corelib/tools/qeasingcurve.h | 6 +- src/corelib/tools/qhash.cpp | 26 +- src/corelib/tools/qhash.h | 24 +- src/corelib/tools/qhashfunctions.h | 50 +- src/corelib/tools/qiterator.h | 4 +- src/corelib/tools/qlinkedlist.h | 44 +- src/corelib/tools/qlist.h | 98 +-- src/corelib/tools/qlocale.cpp | 8 +- src/corelib/tools/qlocale.h | 8 +- src/corelib/tools/qlocale_p.h | 6 +- src/corelib/tools/qmap.h | 18 +- src/corelib/tools/qmargins.h | 192 +++--- src/corelib/tools/qpoint.h | 6 +- src/corelib/tools/qqueue.h | 2 +- src/corelib/tools/qrect.cpp | 26 +- src/corelib/tools/qrect.h | 568 +++++++++--------- src/corelib/tools/qrefcount.h | 16 +- src/corelib/tools/qregexp.cpp | 4 +- src/corelib/tools/qregexp.h | 8 +- src/corelib/tools/qregularexpression.cpp | 2 +- src/corelib/tools/qregularexpression.h | 16 +- src/corelib/tools/qringbuffer_p.h | 14 +- src/corelib/tools/qscopedpointer.h | 36 +- src/corelib/tools/qscopeguard.h | 6 +- src/corelib/tools/qset.h | 28 +- src/corelib/tools/qshareddata.h | 24 +- src/corelib/tools/qsharedpointer_impl.h | 98 +-- src/corelib/tools/qsize.cpp | 8 +- src/corelib/tools/qsize.h | 230 +++---- src/corelib/tools/qstack.h | 2 +- src/corelib/tools/qstring.cpp | 100 +-- src/corelib/tools/qstring.h | 414 ++++++------- src/corelib/tools/qstringalgorithms.h | 44 +- src/corelib/tools/qstringbuilder.cpp | 2 +- src/corelib/tools/qstringbuilder.h | 6 +- src/corelib/tools/qstringlist.h | 6 +- src/corelib/tools/qstringliteral.h | 2 +- src/corelib/tools/qstringview.h | 82 +-- src/corelib/tools/qtimezone.cpp | 2 +- src/corelib/tools/qtimezone.h | 6 +- src/corelib/tools/qtimezoneprivate_p.h | 4 +- src/corelib/tools/qtimezoneprivate_tz.cpp | 2 +- src/corelib/tools/qtools_p.h | 14 +- src/corelib/tools/qunicodetables.cpp | 16 +- src/corelib/tools/qunicodetables_p.h | 20 +- src/corelib/tools/qvector.h | 40 +- src/corelib/tools/qversionnumber.cpp | 4 +- src/corelib/tools/qversionnumber.h | 42 +- 153 files changed, 2205 insertions(+), 2205 deletions(-) diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp index e2598b7858..cac631d770 100644 --- a/src/corelib/codecs/qtextcodec.cpp +++ b/src/corelib/codecs/qtextcodec.cpp @@ -1061,7 +1061,7 @@ QString QTextDecoder::toUnicode(const char *chars, int len) } // in qstring.cpp: -void qt_from_latin1(ushort *dst, const char *str, size_t size) Q_DECL_NOTHROW; +void qt_from_latin1(ushort *dst, const char *str, size_t size) noexcept; /*! \overload diff --git a/src/corelib/codecs/qutfcodec.cpp b/src/corelib/codecs/qutfcodec.cpp index 643c8ee475..85736fdf02 100644 --- a/src/corelib/codecs/qutfcodec.cpp +++ b/src/corelib/codecs/qutfcodec.cpp @@ -54,7 +54,7 @@ static const uchar utf8bom[] = { 0xef, 0xbb, 0xbf }; #if (defined(__SSE2__) && defined(QT_COMPILER_SUPPORTS_SSE2)) \ || (defined(__ARM_NEON__) && defined(Q_PROCESSOR_ARM_64)) -static Q_ALWAYS_INLINE uint qBitScanReverse(unsigned v) Q_DECL_NOTHROW +static Q_ALWAYS_INLINE uint qBitScanReverse(unsigned v) noexcept { uint result = qCountLeadingZeroBits(v); // Now Invert the result: clz will count *down* from the msb to the lsb, so the msb index is 31 @@ -504,7 +504,7 @@ QString QUtf8::convertToUnicode(const char *chars, int len) This function never throws. */ -QChar *QUtf8::convertToUnicode(QChar *buffer, const char *chars, int len) Q_DECL_NOTHROW +QChar *QUtf8::convertToUnicode(QChar *buffer, const char *chars, int len) noexcept { ushort *dst = reinterpret_cast(buffer); const uchar *src = reinterpret_cast(chars); diff --git a/src/corelib/codecs/qutfcodec_p.h b/src/corelib/codecs/qutfcodec_p.h index b24283ac5e..083e16317a 100644 --- a/src/corelib/codecs/qutfcodec_p.h +++ b/src/corelib/codecs/qutfcodec_p.h @@ -291,7 +291,7 @@ enum DataEndianness struct QUtf8 { - static QChar *convertToUnicode(QChar *, const char *, int) Q_DECL_NOTHROW; + static QChar *convertToUnicode(QChar *, const char *, int) noexcept; static QString convertToUnicode(const char *, int); static QString convertToUnicode(const char *, int, QTextCodec::ConverterState *); static QByteArray convertFromUnicode(const QChar *, int); diff --git a/src/corelib/global/qflags.h b/src/corelib/global/qflags.h index 6aa6850c69..65f4892472 100644 --- a/src/corelib/global/qflags.h +++ b/src/corelib/global/qflags.h @@ -54,21 +54,21 @@ class QFlag { int i; public: - Q_DECL_CONSTEXPR inline QFlag(int value) Q_DECL_NOTHROW : i(value) {} - Q_DECL_CONSTEXPR inline operator int() const Q_DECL_NOTHROW { return i; } + Q_DECL_CONSTEXPR inline QFlag(int value) noexcept : i(value) {} + Q_DECL_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) Q_DECL_NOTHROW : i(int(value)) {} - Q_DECL_CONSTEXPR inline QFlag(ulong value) Q_DECL_NOTHROW : i(int(long(value))) {} + Q_DECL_CONSTEXPR inline QFlag(long value) noexcept : i(int(value)) {} + Q_DECL_CONSTEXPR inline QFlag(ulong value) noexcept : i(int(long(value))) {} # endif - Q_DECL_CONSTEXPR inline QFlag(uint value) Q_DECL_NOTHROW : i(int(value)) {} - Q_DECL_CONSTEXPR inline QFlag(short value) Q_DECL_NOTHROW : i(int(value)) {} - Q_DECL_CONSTEXPR inline QFlag(ushort value) Q_DECL_NOTHROW : i(int(uint(value))) {} - Q_DECL_CONSTEXPR inline operator uint() const Q_DECL_NOTHROW { return uint(i); } + 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); } #endif }; Q_DECLARE_TYPEINFO(QFlag, Q_PRIMITIVE_TYPE); @@ -77,12 +77,12 @@ class QIncompatibleFlag { int i; public: - Q_DECL_CONSTEXPR inline explicit QIncompatibleFlag(int i) Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline operator int() const Q_DECL_NOTHROW { return i; } + Q_DECL_CONSTEXPR inline explicit QIncompatibleFlag(int i) noexcept; + Q_DECL_CONSTEXPR inline operator int() const noexcept { return i; } }; Q_DECLARE_TYPEINFO(QIncompatibleFlag, Q_PRIMITIVE_TYPE); -Q_DECL_CONSTEXPR inline QIncompatibleFlag::QIncompatibleFlag(int value) Q_DECL_NOTHROW : i(value) {} +Q_DECL_CONSTEXPR inline QIncompatibleFlag::QIncompatibleFlag(int value) noexcept : i(value) {} #ifndef Q_NO_TYPESAFE_FLAGS @@ -117,38 +117,38 @@ public: Q_DECL_CONSTEXPR inline QFlags(const QFlags &other); Q_DECL_CONSTEXPR inline QFlags &operator=(const QFlags &other); #endif - Q_DECL_CONSTEXPR inline QFlags(Enum flags) Q_DECL_NOTHROW : i(Int(flags)) {} - Q_DECL_CONSTEXPR inline QFlags(Zero = nullptr) Q_DECL_NOTHROW : i(0) {} - Q_DECL_CONSTEXPR inline QFlags(QFlag flag) Q_DECL_NOTHROW : i(flag) {} + Q_DECL_CONSTEXPR inline QFlags(Enum flags) noexcept : i(Int(flags)) {} + Q_DECL_CONSTEXPR inline QFlags(Zero = nullptr) noexcept : i(0) {} + Q_DECL_CONSTEXPR inline QFlags(QFlag flag) noexcept : i(flag) {} #ifdef Q_COMPILER_INITIALIZER_LISTS - Q_DECL_CONSTEXPR inline QFlags(std::initializer_list flags) Q_DECL_NOTHROW + Q_DECL_CONSTEXPR inline QFlags(std::initializer_list flags) noexcept : i(initializer_list_helper(flags.begin(), flags.end())) {} #endif - Q_DECL_RELAXED_CONSTEXPR inline QFlags &operator&=(int mask) Q_DECL_NOTHROW { i &= mask; return *this; } - Q_DECL_RELAXED_CONSTEXPR inline QFlags &operator&=(uint mask) Q_DECL_NOTHROW { i &= mask; return *this; } - Q_DECL_RELAXED_CONSTEXPR inline QFlags &operator&=(Enum mask) Q_DECL_NOTHROW { i &= Int(mask); return *this; } - Q_DECL_RELAXED_CONSTEXPR inline QFlags &operator|=(QFlags other) Q_DECL_NOTHROW { i |= other.i; return *this; } - Q_DECL_RELAXED_CONSTEXPR inline QFlags &operator|=(Enum other) Q_DECL_NOTHROW { i |= Int(other); return *this; } - Q_DECL_RELAXED_CONSTEXPR inline QFlags &operator^=(QFlags other) Q_DECL_NOTHROW { i ^= other.i; return *this; } - Q_DECL_RELAXED_CONSTEXPR inline QFlags &operator^=(Enum other) Q_DECL_NOTHROW { i ^= Int(other); return *this; } + 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 Q_DECL_NOTHROW { return i; } + Q_DECL_CONSTEXPR inline operator Int() const noexcept { return i; } - Q_DECL_CONSTEXPR inline QFlags operator|(QFlags other) const Q_DECL_NOTHROW { return QFlags(QFlag(i | other.i)); } - Q_DECL_CONSTEXPR inline QFlags operator|(Enum other) const Q_DECL_NOTHROW { return QFlags(QFlag(i | Int(other))); } - Q_DECL_CONSTEXPR inline QFlags operator^(QFlags other) const Q_DECL_NOTHROW { return QFlags(QFlag(i ^ other.i)); } - Q_DECL_CONSTEXPR inline QFlags operator^(Enum other) const Q_DECL_NOTHROW { return QFlags(QFlag(i ^ Int(other))); } - Q_DECL_CONSTEXPR inline QFlags operator&(int mask) const Q_DECL_NOTHROW { return QFlags(QFlag(i & mask)); } - Q_DECL_CONSTEXPR inline QFlags operator&(uint mask) const Q_DECL_NOTHROW { return QFlags(QFlag(i & mask)); } - Q_DECL_CONSTEXPR inline QFlags operator&(Enum other) const Q_DECL_NOTHROW { return QFlags(QFlag(i & Int(other))); } - Q_DECL_CONSTEXPR inline QFlags operator~() const Q_DECL_NOTHROW { return QFlags(QFlag(~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 Q_DECL_NOTHROW { return !i; } + Q_DECL_CONSTEXPR inline bool operator!() const noexcept { return !i; } - Q_DECL_CONSTEXPR inline bool testFlag(Enum flag) const Q_DECL_NOTHROW { return (i & Int(flag)) == Int(flag) && (Int(flag) != 0 || i == Int(flag) ); } - Q_DECL_RELAXED_CONSTEXPR inline QFlags &setFlag(Enum flag, bool on = true) Q_DECL_NOTHROW + 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 { return on ? (*this |= flag) : (*this &= ~Int(flag)); } @@ -157,7 +157,7 @@ private: #ifdef Q_COMPILER_INITIALIZER_LISTS Q_DECL_CONSTEXPR static inline Int initializer_list_helper(typename std::initializer_list::const_iterator it, typename std::initializer_list::const_iterator end) - Q_DECL_NOTHROW + noexcept { return (it == end ? Int(0) : (Int(*it) | initializer_list_helper(it + 1, end))); } @@ -172,13 +172,13 @@ typedef QFlags Flags; #endif #define Q_DECLARE_INCOMPATIBLE_FLAGS(Flags) \ -Q_DECL_CONSTEXPR inline QIncompatibleFlag operator|(Flags::enum_type f1, int f2) Q_DECL_NOTHROW \ +Q_DECL_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 operator|(Flags::enum_type f1, Flags::enum_type f2) Q_DECL_NOTHROW \ +Q_DECL_CONSTEXPR inline QFlags operator|(Flags::enum_type f1, Flags::enum_type f2) noexcept \ { return QFlags(f1) | f2; } \ -Q_DECL_CONSTEXPR inline QFlags operator|(Flags::enum_type f1, QFlags f2) Q_DECL_NOTHROW \ +Q_DECL_CONSTEXPR inline QFlags operator|(Flags::enum_type f1, QFlags f2) noexcept \ { return f2 | f1; } Q_DECLARE_INCOMPATIBLE_FLAGS(Flags) diff --git a/src/corelib/global/qfloat16.cpp b/src/corelib/global/qfloat16.cpp index 110d7c4d7c..680268c59b 100644 --- a/src/corelib/global/qfloat16.cpp +++ b/src/corelib/global/qfloat16.cpp @@ -132,8 +132,8 @@ extern "C" { # define f16cextern extern #endif -f16cextern void qFloatToFloat16_fast(quint16 *out, const float *in, qsizetype len) Q_DECL_NOTHROW; -f16cextern void qFloatFromFloat16_fast(float *out, const quint16 *in, qsizetype len) Q_DECL_NOTHROW; +f16cextern void qFloatToFloat16_fast(quint16 *out, const float *in, qsizetype len) noexcept; +f16cextern void qFloatFromFloat16_fast(float *out, const quint16 *in, qsizetype len) noexcept; #undef f16cextern } @@ -144,7 +144,7 @@ static inline bool hasFastF16() return true; } -static void qFloatToFloat16_fast(quint16 *out, const float *in, qsizetype len) Q_DECL_NOTHROW +static void qFloatToFloat16_fast(quint16 *out, const float *in, qsizetype len) noexcept { __fp16 *out_f16 = reinterpret_cast<__fp16 *>(out); qsizetype i = 0; @@ -154,7 +154,7 @@ static void qFloatToFloat16_fast(quint16 *out, const float *in, qsizetype len) Q out_f16[i] = __fp16(in[i]); } -static void qFloatFromFloat16_fast(float *out, const quint16 *in, qsizetype len) Q_DECL_NOTHROW +static void qFloatFromFloat16_fast(float *out, const quint16 *in, qsizetype len) noexcept { const __fp16 *in_f16 = reinterpret_cast(in); qsizetype i = 0; @@ -169,12 +169,12 @@ static inline bool hasFastF16() return false; } -static void qFloatToFloat16_fast(quint16 *, const float *, qsizetype) Q_DECL_NOTHROW +static void qFloatToFloat16_fast(quint16 *, const float *, qsizetype) noexcept { Q_UNREACHABLE(); } -static void qFloatFromFloat16_fast(float *, const quint16 *, qsizetype) Q_DECL_NOTHROW +static void qFloatFromFloat16_fast(float *, const quint16 *, qsizetype) noexcept { Q_UNREACHABLE(); } @@ -186,7 +186,7 @@ static void qFloatFromFloat16_fast(float *, const quint16 *, qsizetype) Q_DECL_N Converts \a len floats from \a in to qfloat16 and stores them in \a out. Both \a in and \a out must have \a len allocated entries. */ -Q_CORE_EXPORT void qFloatToFloat16(qfloat16 *out, const float *in, qsizetype len) Q_DECL_NOTHROW +Q_CORE_EXPORT void qFloatToFloat16(qfloat16 *out, const float *in, qsizetype len) noexcept { if (hasFastF16()) return qFloatToFloat16_fast(reinterpret_cast(out), in, len); @@ -202,7 +202,7 @@ Q_CORE_EXPORT void qFloatToFloat16(qfloat16 *out, const float *in, qsizetype len Converts \a len qfloat16 from \a in to floats and stores them in \a out. Both \a in and \a out must have \a len allocated entries. */ -Q_CORE_EXPORT void qFloatFromFloat16(float *out, const qfloat16 *in, qsizetype len) Q_DECL_NOTHROW +Q_CORE_EXPORT void qFloatFromFloat16(float *out, const qfloat16 *in, qsizetype len) noexcept { if (hasFastF16()) return qFloatFromFloat16_fast(out, reinterpret_cast(in), len); diff --git a/src/corelib/global/qfloat16.h b/src/corelib/global/qfloat16.h index e823d0298b..243aea98be 100644 --- a/src/corelib/global/qfloat16.h +++ b/src/corelib/global/qfloat16.h @@ -67,14 +67,14 @@ QT_BEGIN_NAMESPACE class qfloat16 { public: - constexpr inline qfloat16() Q_DECL_NOTHROW : b16(0) {} - inline qfloat16(float f) Q_DECL_NOTHROW; - inline operator float() const Q_DECL_NOTHROW; + constexpr inline qfloat16() noexcept : b16(0) {} + inline qfloat16(float f) noexcept; + inline operator float() const noexcept; // Support for qIs{Inf,NaN,Finite}: - bool isInf() const Q_DECL_NOTHROW { return ((b16 >> 8) & 0x7e) == 0x7c; } - bool isNaN() const Q_DECL_NOTHROW { return ((b16 >> 8) & 0x7e) == 0x7e; } - bool isFinite() const Q_DECL_NOTHROW { return ((b16 >> 8) & 0x7c) != 0x7c; } + bool isInf() const noexcept { return ((b16 >> 8) & 0x7e) == 0x7c; } + bool isNaN() const noexcept { return ((b16 >> 8) & 0x7e) == 0x7e; } + bool isFinite() const noexcept { return ((b16 >> 8) & 0x7c) != 0x7c; } private: quint16 b16; @@ -84,29 +84,29 @@ private: Q_CORE_EXPORT static const quint32 basetable[]; Q_CORE_EXPORT static const quint32 shifttable[]; - friend bool qIsNull(qfloat16 f) Q_DECL_NOTHROW; - friend qfloat16 operator-(qfloat16 a) Q_DECL_NOTHROW; + friend bool qIsNull(qfloat16 f) noexcept; + friend qfloat16 operator-(qfloat16 a) noexcept; }; Q_DECLARE_TYPEINFO(qfloat16, Q_PRIMITIVE_TYPE); -Q_CORE_EXPORT void qFloatToFloat16(qfloat16 *, const float *, qsizetype length) Q_DECL_NOTHROW; -Q_CORE_EXPORT void qFloatFromFloat16(float *, const qfloat16 *, qsizetype length) Q_DECL_NOTHROW; +Q_CORE_EXPORT void qFloatToFloat16(qfloat16 *, const float *, qsizetype length) noexcept; +Q_CORE_EXPORT void qFloatFromFloat16(float *, const qfloat16 *, qsizetype length) noexcept; // Complement qnumeric.h: -Q_REQUIRED_RESULT inline bool qIsInf(qfloat16 f) Q_DECL_NOTHROW { return f.isInf(); } -Q_REQUIRED_RESULT inline bool qIsNaN(qfloat16 f) Q_DECL_NOTHROW { return f.isNaN(); } -Q_REQUIRED_RESULT inline bool qIsFinite(qfloat16 f) Q_DECL_NOTHROW { return f.isFinite(); } +Q_REQUIRED_RESULT inline bool qIsInf(qfloat16 f) noexcept { return f.isInf(); } +Q_REQUIRED_RESULT inline bool qIsNaN(qfloat16 f) noexcept { return f.isNaN(); } +Q_REQUIRED_RESULT inline bool qIsFinite(qfloat16 f) noexcept { return f.isFinite(); } // Q_REQUIRED_RESULT quint32 qFloatDistance(qfloat16 a, qfloat16 b); // The remainder of these utility functions complement qglobal.h -Q_REQUIRED_RESULT inline int qRound(qfloat16 d) Q_DECL_NOTHROW +Q_REQUIRED_RESULT inline int qRound(qfloat16 d) noexcept { return qRound(static_cast(d)); } -Q_REQUIRED_RESULT inline qint64 qRound64(qfloat16 d) Q_DECL_NOTHROW +Q_REQUIRED_RESULT inline qint64 qRound64(qfloat16 d) noexcept { return qRound64(static_cast(d)); } -Q_REQUIRED_RESULT inline bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) Q_DECL_NOTHROW +Q_REQUIRED_RESULT inline bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) noexcept { float f1 = static_cast(p1); float f2 = static_cast(p2); @@ -119,19 +119,19 @@ Q_REQUIRED_RESULT inline bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) Q_DECL_NOT return (qAbs(f1 - f2) * 102.5f <= qMin(qAbs(f1), qAbs(f2))); } -Q_REQUIRED_RESULT inline bool qIsNull(qfloat16 f) Q_DECL_NOTHROW +Q_REQUIRED_RESULT inline bool qIsNull(qfloat16 f) noexcept { return (f.b16 & static_cast(0x7fff)) == 0; } -inline int qIntCast(qfloat16 f) Q_DECL_NOTHROW +inline int qIntCast(qfloat16 f) noexcept { return int(static_cast(f)); } #ifndef Q_QDOC QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wc99-extensions") QT_WARNING_DISABLE_GCC("-Wold-style-cast") -inline qfloat16::qfloat16(float f) Q_DECL_NOTHROW +inline qfloat16::qfloat16(float f) noexcept { #if defined(QT_COMPILER_SUPPORTS_F16C) && defined(__F16C__) __m128 packsingle = _mm_set_ss(f); @@ -149,7 +149,7 @@ inline qfloat16::qfloat16(float f) Q_DECL_NOTHROW } QT_WARNING_POP -inline qfloat16::operator float() const Q_DECL_NOTHROW +inline qfloat16::operator float() const noexcept { #if defined(QT_COMPILER_SUPPORTS_F16C) && defined(__F16C__) __m128i packhalf = _mm_cvtsi32_si128(b16); @@ -169,23 +169,23 @@ inline qfloat16::operator float() const Q_DECL_NOTHROW } #endif -inline qfloat16 operator-(qfloat16 a) Q_DECL_NOTHROW +inline qfloat16 operator-(qfloat16 a) noexcept { qfloat16 f; f.b16 = a.b16 ^ quint16(0x8000); return f; } -inline qfloat16 operator+(qfloat16 a, qfloat16 b) Q_DECL_NOTHROW { return qfloat16(static_cast(a) + static_cast(b)); } -inline qfloat16 operator-(qfloat16 a, qfloat16 b) Q_DECL_NOTHROW { return qfloat16(static_cast(a) - static_cast(b)); } -inline qfloat16 operator*(qfloat16 a, qfloat16 b) Q_DECL_NOTHROW { return qfloat16(static_cast(a) * static_cast(b)); } -inline qfloat16 operator/(qfloat16 a, qfloat16 b) Q_DECL_NOTHROW { return qfloat16(static_cast(a) / static_cast(b)); } +inline qfloat16 operator+(qfloat16 a, qfloat16 b) noexcept { return qfloat16(static_cast(a) + static_cast(b)); } +inline qfloat16 operator-(qfloat16 a, qfloat16 b) noexcept { return qfloat16(static_cast(a) - static_cast(b)); } +inline qfloat16 operator*(qfloat16 a, qfloat16 b) noexcept { return qfloat16(static_cast(a) * static_cast(b)); } +inline qfloat16 operator/(qfloat16 a, qfloat16 b) noexcept { return qfloat16(static_cast(a) / static_cast(b)); } #define QF16_MAKE_ARITH_OP_FP(FP, OP) \ - inline FP operator OP(qfloat16 lhs, FP rhs) Q_DECL_NOTHROW { return static_cast(lhs) OP rhs; } \ - inline FP operator OP(FP lhs, qfloat16 rhs) Q_DECL_NOTHROW { return lhs OP static_cast(rhs); } + inline FP operator OP(qfloat16 lhs, FP rhs) noexcept { return static_cast(lhs) OP rhs; } \ + inline FP operator OP(FP lhs, qfloat16 rhs) noexcept { return lhs OP static_cast(rhs); } #define QF16_MAKE_ARITH_OP_EQ_FP(FP, OP_EQ, OP) \ - inline qfloat16& operator OP_EQ(qfloat16& lhs, FP rhs) Q_DECL_NOTHROW \ + inline qfloat16& operator OP_EQ(qfloat16& lhs, FP rhs) noexcept \ { lhs = qfloat16(float(static_cast(lhs) OP rhs)); return lhs; } #define QF16_MAKE_ARITH_OP(FP) \ QF16_MAKE_ARITH_OP_FP(FP, +) \ @@ -203,8 +203,8 @@ QF16_MAKE_ARITH_OP(float) #undef QF16_MAKE_ARITH_OP_FP #define QF16_MAKE_ARITH_OP_INT(OP) \ - inline double operator OP(qfloat16 lhs, int rhs) Q_DECL_NOTHROW { return static_cast(lhs) OP rhs; } \ - inline double operator OP(int lhs, qfloat16 rhs) Q_DECL_NOTHROW { return lhs OP static_cast(rhs); } + inline double operator OP(qfloat16 lhs, int rhs) noexcept { return static_cast(lhs) OP rhs; } \ + inline double operator OP(int lhs, qfloat16 rhs) noexcept { return lhs OP static_cast(rhs); } QF16_MAKE_ARITH_OP_INT(+) QF16_MAKE_ARITH_OP_INT(-) QF16_MAKE_ARITH_OP_INT(*) @@ -215,16 +215,16 @@ QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wfloat-equal") QT_WARNING_DISABLE_GCC("-Wfloat-equal") -inline bool operator>(qfloat16 a, qfloat16 b) Q_DECL_NOTHROW { return static_cast(a) > static_cast(b); } -inline bool operator<(qfloat16 a, qfloat16 b) Q_DECL_NOTHROW { return static_cast(a) < static_cast(b); } -inline bool operator>=(qfloat16 a, qfloat16 b) Q_DECL_NOTHROW { return static_cast(a) >= static_cast(b); } -inline bool operator<=(qfloat16 a, qfloat16 b) Q_DECL_NOTHROW { return static_cast(a) <= static_cast(b); } -inline bool operator==(qfloat16 a, qfloat16 b) Q_DECL_NOTHROW { return static_cast(a) == static_cast(b); } -inline bool operator!=(qfloat16 a, qfloat16 b) Q_DECL_NOTHROW { return static_cast(a) != static_cast(b); } +inline bool operator>(qfloat16 a, qfloat16 b) noexcept { return static_cast(a) > static_cast(b); } +inline bool operator<(qfloat16 a, qfloat16 b) noexcept { return static_cast(a) < static_cast(b); } +inline bool operator>=(qfloat16 a, qfloat16 b) noexcept { return static_cast(a) >= static_cast(b); } +inline bool operator<=(qfloat16 a, qfloat16 b) noexcept { return static_cast(a) <= static_cast(b); } +inline bool operator==(qfloat16 a, qfloat16 b) noexcept { return static_cast(a) == static_cast(b); } +inline bool operator!=(qfloat16 a, qfloat16 b) noexcept { return static_cast(a) != static_cast(b); } #define QF16_MAKE_BOOL_OP_FP(FP, OP) \ - inline bool operator OP(qfloat16 lhs, FP rhs) Q_DECL_NOTHROW { return static_cast(lhs) OP rhs; } \ - inline bool operator OP(FP lhs, qfloat16 rhs) Q_DECL_NOTHROW { return lhs OP static_cast(rhs); } + inline bool operator OP(qfloat16 lhs, FP rhs) noexcept { return static_cast(lhs) OP rhs; } \ + inline bool operator OP(FP lhs, qfloat16 rhs) noexcept { return lhs OP static_cast(rhs); } #define QF16_MAKE_BOOL_OP(FP) \ QF16_MAKE_BOOL_OP_FP(FP, <) \ QF16_MAKE_BOOL_OP_FP(FP, >) \ @@ -239,8 +239,8 @@ QF16_MAKE_BOOL_OP(float) #undef QF16_MAKE_BOOL_OP_FP #define QF16_MAKE_BOOL_OP_INT(OP) \ - inline bool operator OP(qfloat16 a, int b) Q_DECL_NOTHROW { return static_cast(a) OP b; } \ - inline bool operator OP(int a, qfloat16 b) Q_DECL_NOTHROW { return a OP static_cast(b); } + inline bool operator OP(qfloat16 a, int b) noexcept { return static_cast(a) OP b; } \ + inline bool operator OP(int a, qfloat16 b) noexcept { return a OP static_cast(b); } QF16_MAKE_BOOL_OP_INT(>) QF16_MAKE_BOOL_OP_INT(<) QF16_MAKE_BOOL_OP_INT(>=) @@ -254,7 +254,7 @@ QT_WARNING_POP /*! \internal */ -Q_REQUIRED_RESULT inline bool qFuzzyIsNull(qfloat16 f) Q_DECL_NOTHROW +Q_REQUIRED_RESULT inline bool qFuzzyIsNull(qfloat16 f) noexcept { return qAbs(static_cast(f)) <= 0.001f; } diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 7879109930..d95064af27 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -1147,12 +1147,12 @@ Q_STATIC_ASSERT((std::is_same::value)); \sa QT_VERSION_STR, QLibraryInfo::version() */ -const char *qVersion() Q_DECL_NOTHROW +const char *qVersion() noexcept { return QT_VERSION_STR; } -bool qSharedBuild() Q_DECL_NOTHROW +bool qSharedBuild() noexcept { #ifdef QT_SHARED return true; @@ -3206,7 +3206,7 @@ QByteArray QSysInfo::bootUniqueId() The Q_CHECK_PTR macro calls this function if an allocation check fails. */ -void qt_check_pointer(const char *n, int l) Q_DECL_NOTHROW +void qt_check_pointer(const char *n, int l) noexcept { // make separate printing calls so that the first one may flush; // the second one could want to allocate memory (fputs prints a @@ -3233,7 +3233,7 @@ void qBadAlloc() Allows you to call std::terminate() without including . Called internally from QT_TERMINATE_ON_EXCEPTION */ -Q_NORETURN void qTerminate() Q_DECL_NOTHROW +Q_NORETURN void qTerminate() noexcept { std::terminate(); } @@ -3242,7 +3242,7 @@ Q_NORETURN void qTerminate() Q_DECL_NOTHROW /* The Q_ASSERT macro calls this function when the test fails. */ -void qt_assert(const char *assertion, const char *file, int line) Q_DECL_NOTHROW +void qt_assert(const char *assertion, const char *file, int line) noexcept { QMessageLogger(file, line, nullptr).fatal("ASSERT: \"%s\" in file %s, line %d", assertion, file, line); } @@ -3250,7 +3250,7 @@ void qt_assert(const char *assertion, const char *file, int line) Q_DECL_NOTHROW /* The Q_ASSERT_X macro calls this function when the test fails. */ -void qt_assert_x(const char *where, const char *what, const char *file, int line) Q_DECL_NOTHROW +void qt_assert_x(const char *where, const char *what, const char *file, int line) noexcept { QMessageLogger(file, line, nullptr).fatal("ASSERT failure in %s: \"%s\", file %s, line %d", where, what, file, line); } @@ -3457,7 +3457,7 @@ QString qEnvironmentVariable(const char *varName) \sa qgetenv(), qEnvironmentVariable(), qEnvironmentVariableIsSet() */ -bool qEnvironmentVariableIsEmpty(const char *varName) Q_DECL_NOEXCEPT +bool qEnvironmentVariableIsEmpty(const char *varName) noexcept { QMutexLocker locker(&environmentMutex); #ifdef Q_CC_MSVC @@ -3492,7 +3492,7 @@ bool qEnvironmentVariableIsEmpty(const char *varName) Q_DECL_NOEXCEPT \sa qgetenv(), qEnvironmentVariable(), qEnvironmentVariableIsSet() */ -int qEnvironmentVariableIntValue(const char *varName, bool *ok) Q_DECL_NOEXCEPT +int qEnvironmentVariableIntValue(const char *varName, bool *ok) noexcept { static const int NumBinaryDigitsPerOctalDigit = 3; static const int MaxDigitsForOctalInt = @@ -3561,7 +3561,7 @@ int qEnvironmentVariableIntValue(const char *varName, bool *ok) Q_DECL_NOEXCEPT \sa qgetenv(), qEnvironmentVariable(), qEnvironmentVariableIsEmpty() */ -bool qEnvironmentVariableIsSet(const char *varName) Q_DECL_NOEXCEPT +bool qEnvironmentVariableIsSet(const char *varName) noexcept { QMutexLocker locker(&environmentMutex); #ifdef Q_CC_MSVC diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 223ebbcabe..f62d078035 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -411,7 +411,7 @@ typedef double qreal; #if !defined(QT_NAMESPACE) && defined(__cplusplus) && !defined(Q_QDOC) extern "C" #endif -Q_CORE_EXPORT Q_DECL_CONST_FUNCTION const char *qVersion(void) Q_DECL_NOTHROW; +Q_CORE_EXPORT Q_DECL_CONST_FUNCTION const char *qVersion(void) Q_DECL_NOEXCEPT; #if defined(__cplusplus) @@ -730,7 +730,7 @@ inline void qt_noop(void) {} # define QT_CATCH(A) catch (A) # define QT_THROW(A) throw A # define QT_RETHROW throw -Q_NORETURN Q_DECL_COLD_FUNCTION Q_CORE_EXPORT void qTerminate() Q_DECL_NOTHROW; +Q_NORETURN Q_DECL_COLD_FUNCTION Q_CORE_EXPORT void qTerminate() noexcept; # ifdef Q_COMPILER_NOEXCEPT # define QT_TERMINATE_ON_EXCEPTION(expr) do { expr; } while (false) # else @@ -738,7 +738,7 @@ Q_NORETURN Q_DECL_COLD_FUNCTION Q_CORE_EXPORT void qTerminate() Q_DECL_NOTHROW; # endif #endif -Q_CORE_EXPORT Q_DECL_CONST_FUNCTION bool qSharedBuild() Q_DECL_NOTHROW; +Q_CORE_EXPORT Q_DECL_CONST_FUNCTION bool qSharedBuild() noexcept; #ifndef Q_OUTOFLINE_TEMPLATE # define Q_OUTOFLINE_TEMPLATE @@ -781,7 +781,7 @@ Q_CORE_EXPORT QString qt_error_string(int errorCode = -1); Q_NORETURN #endif Q_DECL_COLD_FUNCTION -Q_CORE_EXPORT void qt_assert(const char *assertion, const char *file, int line) Q_DECL_NOTHROW; +Q_CORE_EXPORT void qt_assert(const char *assertion, const char *file, int line) noexcept; #if !defined(Q_ASSERT) # if defined(QT_NO_DEBUG) && !defined(QT_FORCE_ASSERTS) @@ -799,7 +799,7 @@ Q_CORE_EXPORT void qt_assert(const char *assertion, const char *file, int line) Q_NORETURN #endif Q_DECL_COLD_FUNCTION -Q_CORE_EXPORT void qt_assert_x(const char *where, const char *what, const char *file, int line) Q_DECL_NOTHROW; +Q_CORE_EXPORT void qt_assert_x(const char *where, const char *what, const char *file, int line) noexcept; #if !defined(Q_ASSERT_X) # if defined(QT_NO_DEBUG) && !defined(QT_FORCE_ASSERTS) @@ -809,7 +809,7 @@ Q_CORE_EXPORT void qt_assert_x(const char *where, const char *what, const char * # endif #endif -Q_NORETURN Q_CORE_EXPORT void qt_check_pointer(const char *, int) Q_DECL_NOTHROW; +Q_NORETURN Q_CORE_EXPORT void qt_check_pointer(const char *, int) noexcept; Q_DECL_COLD_FUNCTION Q_CORE_EXPORT void qBadAlloc(); @@ -968,7 +968,7 @@ QT_WARNING_DISABLE_MSVC(4530) /* C++ exception handler used, but unwind semantic // this adds const to non-const objects (like std::as_const) template -Q_DECL_CONSTEXPR typename std::add_const::type &qAsConst(T &t) Q_DECL_NOTHROW { return t; } +Q_DECL_CONSTEXPR typename std::add_const::type &qAsConst(T &t) noexcept { return t; } // prevent rvalue arguments: template void qAsConst(const T &&) Q_DECL_EQ_DELETE; @@ -1130,11 +1130,11 @@ template struct QNonConstOverload { template - Q_DECL_CONSTEXPR auto operator()(R (T::*ptr)(Args...)) const Q_DECL_NOTHROW -> decltype(ptr) + Q_DECL_CONSTEXPR auto operator()(R (T::*ptr)(Args...)) const noexcept -> decltype(ptr) { return ptr; } template - static Q_DECL_CONSTEXPR auto of(R (T::*ptr)(Args...)) Q_DECL_NOTHROW -> decltype(ptr) + static Q_DECL_CONSTEXPR auto of(R (T::*ptr)(Args...)) noexcept -> decltype(ptr) { return ptr; } }; @@ -1142,11 +1142,11 @@ template struct QConstOverload { template - Q_DECL_CONSTEXPR auto operator()(R (T::*ptr)(Args...) const) const Q_DECL_NOTHROW -> decltype(ptr) + Q_DECL_CONSTEXPR auto operator()(R (T::*ptr)(Args...) const) const noexcept -> decltype(ptr) { return ptr; } template - static Q_DECL_CONSTEXPR auto of(R (T::*ptr)(Args...) const) Q_DECL_NOTHROW -> decltype(ptr) + static Q_DECL_CONSTEXPR auto of(R (T::*ptr)(Args...) const) noexcept -> decltype(ptr) { return ptr; } }; @@ -1159,11 +1159,11 @@ struct QOverload : QConstOverload, QNonConstOverload using QNonConstOverload::operator(); template - Q_DECL_CONSTEXPR auto operator()(R (*ptr)(Args...)) const Q_DECL_NOTHROW -> decltype(ptr) + Q_DECL_CONSTEXPR auto operator()(R (*ptr)(Args...)) const noexcept -> decltype(ptr) { return ptr; } template - static Q_DECL_CONSTEXPR auto of(R (*ptr)(Args...)) Q_DECL_NOTHROW -> decltype(ptr) + static Q_DECL_CONSTEXPR auto of(R (*ptr)(Args...)) noexcept -> decltype(ptr) { return ptr; } }; @@ -1184,9 +1184,9 @@ Q_CORE_EXPORT QString qEnvironmentVariable(const char *varName, const QString &d Q_CORE_EXPORT bool qputenv(const char *varName, const QByteArray& value); Q_CORE_EXPORT bool qunsetenv(const char *varName); -Q_CORE_EXPORT bool qEnvironmentVariableIsEmpty(const char *varName) Q_DECL_NOEXCEPT; -Q_CORE_EXPORT bool qEnvironmentVariableIsSet(const char *varName) Q_DECL_NOEXCEPT; -Q_CORE_EXPORT int qEnvironmentVariableIntValue(const char *varName, bool *ok=nullptr) Q_DECL_NOEXCEPT; +Q_CORE_EXPORT bool qEnvironmentVariableIsEmpty(const char *varName) noexcept; +Q_CORE_EXPORT bool qEnvironmentVariableIsSet(const char *varName) noexcept; +Q_CORE_EXPORT int qEnvironmentVariableIntValue(const char *varName, bool *ok=nullptr) noexcept; inline int qIntCast(double f) { return int(f); } inline int qIntCast(float f) { return int(f); } diff --git a/src/corelib/global/qglobalstatic.h b/src/corelib/global/qglobalstatic.h index 93d71cee57..6d27e3a984 100644 --- a/src/corelib/global/qglobalstatic.h +++ b/src/corelib/global/qglobalstatic.h @@ -79,7 +79,7 @@ enum GuardValues { Q_GLOBAL_STATIC_INTERNAL_DECORATION Type *innerFunction() \ { \ struct HolderBase { \ - ~HolderBase() Q_DECL_NOTHROW \ + ~HolderBase() noexcept \ { if (guard.load() == QtGlobalStatic::Initialized) \ guard.store(QtGlobalStatic::Destroyed); } \ }; \ diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index 88cc5b0b01..c3eb469767 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -350,7 +350,7 @@ QLibraryInfo::buildDate() \since 5.3 */ -const char *QLibraryInfo::build() Q_DECL_NOTHROW +const char *QLibraryInfo::build() noexcept { return QT_BUILD_STR; } @@ -377,7 +377,7 @@ QLibraryInfo::isDebugBuild() \sa qVersion() */ -QVersionNumber QLibraryInfo::version() Q_DECL_NOTHROW +QVersionNumber QLibraryInfo::version() noexcept { return QVersionNumber(QT_VERSION_MAJOR, QT_VERSION_MINOR, QT_VERSION_PATCH); } diff --git a/src/corelib/global/qlibraryinfo.h b/src/corelib/global/qlibraryinfo.h index 80fc5bd4fc..20fd3897f7 100644 --- a/src/corelib/global/qlibraryinfo.h +++ b/src/corelib/global/qlibraryinfo.h @@ -62,12 +62,12 @@ public: #endif // QT_DEPRECATED_SINCE(5, 5) #endif // datestring - static const char * build() Q_DECL_NOTHROW; + static const char * build() noexcept; static bool isDebugBuild(); #ifndef QT_BOOTSTRAPPED - static QVersionNumber version() Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION; + static QVersionNumber version() noexcept Q_DECL_CONST_FUNCTION; #endif enum LibraryLocation diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index b2093101fa..a4d86e393b 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -346,7 +346,7 @@ using namespace QtPrivate; */ #if defined(Q_CC_MSVC) && defined(QT_DEBUG) && defined(_DEBUG) && defined(_CRT_ERROR) -static inline void convert_to_wchar_t_elided(wchar_t *d, size_t space, const char *s) Q_DECL_NOEXCEPT +static inline void convert_to_wchar_t_elided(wchar_t *d, size_t space, const char *s) noexcept { size_t len = qstrlen(s); if (len + 1 > space) { @@ -529,7 +529,7 @@ QDebug QMessageLogger::debug(QMessageLogger::CategoryFunction catFunc) const \sa QNoDebug, qDebug() */ -QNoDebug QMessageLogger::noDebug() const Q_DECL_NOTHROW +QNoDebug QMessageLogger::noDebug() const noexcept { return QNoDebug(); } @@ -875,7 +875,7 @@ QDebug QMessageLogger::critical(QMessageLogger::CategoryFunction catFunc) const \sa qFatal() */ -void QMessageLogger::fatal(const char *msg, ...) const Q_DECL_NOTHROW +void QMessageLogger::fatal(const char *msg, ...) const noexcept { QString message; diff --git a/src/corelib/global/qlogging.h b/src/corelib/global/qlogging.h index dded09999b..8f39780112 100644 --- a/src/corelib/global/qlogging.h +++ b/src/corelib/global/qlogging.h @@ -121,7 +121,7 @@ public: Q_NORETURN #endif Q_DECL_COLD_FUNCTION - void fatal(const char *msg, ...) const Q_DECL_NOTHROW Q_ATTRIBUTE_FORMAT_PRINTF(2, 3); + void fatal(const char *msg, ...) const noexcept Q_ATTRIBUTE_FORMAT_PRINTF(2, 3); #ifndef QT_NO_DEBUG_STREAM QDebug debug() const; @@ -137,7 +137,7 @@ public: QDebug critical(const QLoggingCategory &cat) const; QDebug critical(CategoryFunction catFunc) const; - QNoDebug noDebug() const Q_DECL_NOTHROW; + QNoDebug noDebug() const noexcept; #endif // QT_NO_DEBUG_STREAM private: diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index 6488426e64..610d7e4db7 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -50,10 +50,10 @@ QT_BEGIN_NAMESPACE #if !defined(Q_QDOC) && !defined(Q_MOC_RUN) struct QMetaObject; -const QMetaObject *qt_getQtMetaObject() Q_DECL_NOEXCEPT; // defined in qobject.h (which can't be included here) +const QMetaObject *qt_getQtMetaObject() noexcept; // defined in qobject.h (which can't be included here) #define QT_Q_ENUM(ENUM) \ - inline const QMetaObject *qt_getEnumMetaObject(ENUM) Q_DECL_NOEXCEPT { return qt_getQtMetaObject(); } \ - inline Q_DECL_CONSTEXPR const char *qt_getEnumName(ENUM) Q_DECL_NOEXCEPT { return #ENUM; } + inline const QMetaObject *qt_getEnumMetaObject(ENUM) noexcept { return qt_getQtMetaObject(); } \ + inline Q_DECL_CONSTEXPR const char *qt_getEnumName(ENUM) noexcept { return #ENUM; } #define QT_Q_FLAG(ENUM) QT_Q_ENUM(ENUM) #else #define QT_Q_ENUM Q_ENUM diff --git a/src/corelib/global/qnumeric_p.h b/src/corelib/global/qnumeric_p.h index 56e670c477..21f9cfbef0 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() Q_DECL_NOEXCEPT +Q_DECL_CONSTEXPR Q_DECL_CONST_FUNCTION static inline double qt_inf() noexcept { Q_STATIC_ASSERT_X(std::numeric_limits::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() Q_DECL_NOEX } // Signaling NaN -Q_DECL_CONSTEXPR Q_DECL_CONST_FUNCTION static inline double qt_snan() Q_DECL_NOEXCEPT +Q_DECL_CONSTEXPR Q_DECL_CONST_FUNCTION static inline double qt_snan() noexcept { Q_STATIC_ASSERT_X(std::numeric_limits::has_signaling_NaN, "platform has no definition for signaling NaN for type double"); @@ -142,7 +142,7 @@ Q_DECL_CONSTEXPR Q_DECL_CONST_FUNCTION static inline double qt_snan() Q_DECL_NOE } // Quiet NaN -Q_DECL_CONSTEXPR Q_DECL_CONST_FUNCTION static inline double qt_qnan() Q_DECL_NOEXCEPT +Q_DECL_CONSTEXPR Q_DECL_CONST_FUNCTION static inline double qt_qnan() noexcept { Q_STATIC_ASSERT_X(std::numeric_limits::has_quiet_NaN, "platform has no definition for quiet NaN for type double"); diff --git a/src/corelib/global/qrandom.cpp b/src/corelib/global/qrandom.cpp index 90df8653a7..fbc4222763 100644 --- a/src/corelib/global/qrandom.cpp +++ b/src/corelib/global/qrandom.cpp @@ -91,7 +91,7 @@ DECLSPEC_IMPORT BOOLEAN WINAPI SystemFunction036(PVOID RandomBuffer, ULONG Rando QT_BEGIN_NAMESPACE #if defined(Q_PROCESSOR_X86) && QT_COMPILER_SUPPORTS_HERE(RDRND) -static qsizetype qt_random_cpu(void *buffer, qsizetype count) Q_DECL_NOTHROW; +static qsizetype qt_random_cpu(void *buffer, qsizetype count) noexcept; # ifdef Q_PROCESSOR_X86_64 # define _rdrandXX_step _rdrand64_step @@ -99,7 +99,7 @@ static qsizetype qt_random_cpu(void *buffer, qsizetype count) Q_DECL_NOTHROW; # define _rdrandXX_step _rdrand32_step # endif -static QT_FUNCTION_TARGET(RDRND) qsizetype qt_random_cpu(void *buffer, qsizetype count) Q_DECL_NOTHROW +static QT_FUNCTION_TARGET(RDRND) qsizetype qt_random_cpu(void *buffer, qsizetype count) noexcept { unsigned *ptr = reinterpret_cast(buffer); unsigned *end = ptr + count; @@ -134,7 +134,7 @@ enum { struct QRandomGenerator::SystemGenerator { #if QT_CONFIG(getentropy) - static qsizetype fillBuffer(void *buffer, qsizetype count) Q_DECL_NOTHROW + static qsizetype fillBuffer(void *buffer, qsizetype count) noexcept { // getentropy can read at most 256 bytes, so break the reading qsizetype read = 0; @@ -204,13 +204,13 @@ struct QRandomGenerator::SystemGenerator } #elif defined(Q_OS_WIN) && !defined(Q_OS_WINRT) - qsizetype fillBuffer(void *buffer, qsizetype count) Q_DECL_NOTHROW + qsizetype fillBuffer(void *buffer, qsizetype count) noexcept { auto RtlGenRandom = SystemFunction036; return RtlGenRandom(buffer, ULONG(count)) ? count: 0; } #elif defined(Q_OS_WINRT) - qsizetype fillBuffer(void *, qsizetype) Q_DECL_NOTHROW + qsizetype fillBuffer(void *, qsizetype) noexcept { // always use the fallback return 0; @@ -242,7 +242,7 @@ struct QRandomGenerator::SystemGenerator #if defined(Q_OS_WIN) static void fallback_update_seed(unsigned) {} -static void fallback_fill(quint32 *ptr, qsizetype left) Q_DECL_NOTHROW +static void fallback_fill(quint32 *ptr, qsizetype left) noexcept { // on Windows, rand_s is a high-quality random number generator // and it requires no seeding @@ -254,14 +254,14 @@ static void fallback_fill(quint32 *ptr, qsizetype left) Q_DECL_NOTHROW } #elif QT_CONFIG(getentropy) static void fallback_update_seed(unsigned) {} -static void fallback_fill(quint32 *, qsizetype) Q_DECL_NOTHROW +static void fallback_fill(quint32 *, qsizetype) noexcept { // no fallback necessary, getentropy cannot fail under normal circumstances Q_UNREACHABLE(); } #elif defined(Q_OS_BSD4) && !defined(__GLIBC__) static void fallback_update_seed(unsigned) {} -static void fallback_fill(quint32 *ptr, qsizetype left) Q_DECL_NOTHROW +static void fallback_fill(quint32 *ptr, qsizetype left) noexcept { // BSDs have arc4random(4) and these work even in chroot(2) arc4random_buf(ptr, left * sizeof(*ptr)); @@ -280,7 +280,7 @@ Q_NEVER_INLINE #ifdef Q_CC_GNU __attribute__((cold)) // this function is pretty big, so optimize for size #endif -static void fallback_fill(quint32 *ptr, qsizetype left) Q_DECL_NOTHROW +static void fallback_fill(quint32 *ptr, qsizetype left) noexcept { quint32 scratch[12]; // see element count below quint32 *end = scratch; @@ -1167,7 +1167,7 @@ QRandomGenerator &QRandomGenerator::operator=(const QRandomGenerator &other) return *this; } -QRandomGenerator::QRandomGenerator(std::seed_seq &sseq) Q_DECL_NOTHROW +QRandomGenerator::QRandomGenerator(std::seed_seq &sseq) noexcept : type(MersenneTwister) { Q_ASSERT(this != system()); diff --git a/src/corelib/global/qrandom.h b/src/corelib/global/qrandom.h index 46d3e0e152..2f72528266 100644 --- a/src/corelib/global/qrandom.h +++ b/src/corelib/global/qrandom.h @@ -68,7 +68,7 @@ public: QRandomGenerator(const quint32 *seedBuffer, qsizetype len) : QRandomGenerator(seedBuffer, seedBuffer + len) {} - Q_CORE_EXPORT QRandomGenerator(std::seed_seq &sseq) Q_DECL_NOTHROW; + Q_CORE_EXPORT QRandomGenerator(std::seed_seq &sseq) noexcept; Q_CORE_EXPORT QRandomGenerator(const quint32 *begin, const quint32 *end); // copy constructor & assignment operator (move unnecessary) @@ -165,7 +165,7 @@ public: typedef quint32 result_type; result_type operator()() { return generate(); } void seed(quint32 s = 1) { *this = { s }; } - void seed(std::seed_seq &sseq) Q_DECL_NOTHROW { *this = { sseq }; } + 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::min(); } static Q_DECL_CONSTEXPR result_type max() { return std::numeric_limits::max(); } @@ -228,7 +228,7 @@ public: QRandomGenerator64(const quint32 *seedBuffer, qsizetype len) : QRandomGenerator(seedBuffer, len) {} - QRandomGenerator64(std::seed_seq &sseq) Q_DECL_NOTHROW + QRandomGenerator64(std::seed_seq &sseq) noexcept : QRandomGenerator(sseq) {} QRandomGenerator64(const quint32 *begin, const quint32 *end) diff --git a/src/corelib/io/qdebug.h b/src/corelib/io/qdebug.h index 91fde75fa5..ea2d57370d 100644 --- a/src/corelib/io/qdebug.h +++ b/src/corelib/io/qdebug.h @@ -116,7 +116,7 @@ public: inline QDebug(const QDebug &o):stream(o.stream) { ++stream->ref; } inline QDebug &operator=(const QDebug &other); ~QDebug(); - inline void swap(QDebug &other) Q_DECL_NOTHROW { qSwap(stream, other.stream); } + inline void swap(QDebug &other) noexcept { qSwap(stream, other.stream); } QDebug &resetFormat(); diff --git a/src/corelib/io/qdir.h b/src/corelib/io/qdir.h index 9abb833ab1..547ac163c7 100644 --- a/src/corelib/io/qdir.h +++ b/src/corelib/io/qdir.h @@ -110,10 +110,10 @@ public: QDir &operator=(const QString &path); #endif #ifdef Q_COMPILER_RVALUE_REFS - QDir &operator=(QDir &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QDir &operator=(QDir &&other) noexcept { swap(other); return *this; } #endif - void swap(QDir &other) Q_DECL_NOTHROW + void swap(QDir &other) noexcept { qSwap(d_ptr, other.d_ptr); } void setPath(const QString &path); @@ -190,7 +190,7 @@ public: static QFileInfoList drives(); - Q_DECL_CONSTEXPR static inline QChar listSeparator() Q_DECL_NOTHROW + Q_DECL_CONSTEXPR static inline QChar listSeparator() noexcept { #if defined(Q_OS_WIN) return QLatin1Char(';'); diff --git a/src/corelib/io/qfileinfo.h b/src/corelib/io/qfileinfo.h index baea18fab1..bd9e1d216f 100644 --- a/src/corelib/io/qfileinfo.h +++ b/src/corelib/io/qfileinfo.h @@ -68,10 +68,10 @@ public: QFileInfo &operator=(const QFileInfo &fileinfo); #ifdef Q_COMPILER_RVALUE_REFS - QFileInfo &operator=(QFileInfo &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QFileInfo &operator=(QFileInfo &&other) noexcept { swap(other); return *this; } #endif - void swap(QFileInfo &other) Q_DECL_NOTHROW + void swap(QFileInfo &other) noexcept { qSwap(d_ptr, other.d_ptr); } bool operator==(const QFileInfo &fileinfo) const; diff --git a/src/corelib/io/qprocess.h b/src/corelib/io/qprocess.h index a2e3c01f7c..83b7138ff9 100644 --- a/src/corelib/io/qprocess.h +++ b/src/corelib/io/qprocess.h @@ -73,11 +73,11 @@ public: QProcessEnvironment(const QProcessEnvironment &other); ~QProcessEnvironment(); #ifdef Q_COMPILER_RVALUE_REFS - QProcessEnvironment &operator=(QProcessEnvironment && other) Q_DECL_NOTHROW { swap(other); return *this; } + QProcessEnvironment &operator=(QProcessEnvironment && other) noexcept { swap(other); return *this; } #endif QProcessEnvironment &operator=(const QProcessEnvironment &other); - void swap(QProcessEnvironment &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + void swap(QProcessEnvironment &other) noexcept { qSwap(d, other.d); } bool operator==(const QProcessEnvironment &other) const; inline bool operator!=(const QProcessEnvironment &other) const diff --git a/src/corelib/io/qstorageinfo.h b/src/corelib/io/qstorageinfo.h index 4ab7a353ef..addcbb2990 100644 --- a/src/corelib/io/qstorageinfo.h +++ b/src/corelib/io/qstorageinfo.h @@ -63,10 +63,10 @@ public: QStorageInfo &operator=(const QStorageInfo &other); #ifdef Q_COMPILER_RVALUE_REFS - QStorageInfo &operator=(QStorageInfo &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QStorageInfo &operator=(QStorageInfo &&other) noexcept { swap(other); return *this; } #endif - inline void swap(QStorageInfo &other) Q_DECL_NOTHROW + inline void swap(QStorageInfo &other) noexcept { qSwap(d, other.d); } void setPath(const QString &path); diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index 6d82981fd6..b4090f710e 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -4159,7 +4159,7 @@ QList QUrl::fromStringList(const QStringList &urls, ParsingMode mode) \relates QHash \since 5.0 */ -uint qHash(const QUrl &url, uint seed) Q_DECL_NOTHROW +uint qHash(const QUrl &url, uint seed) noexcept { if (!url.d) return qHash(-1, seed); // the hash of an unset port (-1) diff --git a/src/corelib/io/qurl.h b/src/corelib/io/qurl.h index 5062ef7905..70e549c1a9 100644 --- a/src/corelib/io/qurl.h +++ b/src/corelib/io/qurl.h @@ -119,7 +119,7 @@ class QTypeInfo > : public QTypeInfoMerger fromStringList(const QStringList &uris, ParsingMode mode = TolerantMode); static void setIdnWhitelist(const QStringList &); - friend Q_CORE_EXPORT uint qHash(const QUrl &url, uint seed) Q_DECL_NOTHROW; + friend Q_CORE_EXPORT uint qHash(const QUrl &url, uint seed) noexcept; private: QUrlPrivate *d; diff --git a/src/corelib/io/qurlquery.cpp b/src/corelib/io/qurlquery.cpp index 10c3f836c8..d76107abfd 100644 --- a/src/corelib/io/qurlquery.cpp +++ b/src/corelib/io/qurlquery.cpp @@ -434,7 +434,7 @@ bool QUrlQuery::operator ==(const QUrlQuery &other) const Returns the hash value for \a key, using \a seed to seed the calculation. */ -uint qHash(const QUrlQuery &key, uint seed) Q_DECL_NOTHROW +uint qHash(const QUrlQuery &key, uint seed) noexcept { if (const QUrlQueryPrivate *d = key.d) { QtPrivate::QHashCombine hash; diff --git a/src/corelib/io/qurlquery.h b/src/corelib/io/qurlquery.h index e3688aae2c..2a497dc8da 100644 --- a/src/corelib/io/qurlquery.h +++ b/src/corelib/io/qurlquery.h @@ -52,7 +52,7 @@ QT_BEGIN_NAMESPACE -Q_CORE_EXPORT uint qHash(const QUrlQuery &key, uint seed = 0) Q_DECL_NOTHROW; +Q_CORE_EXPORT uint qHash(const QUrlQuery &key, uint seed = 0) noexcept; class QUrlQueryPrivate; class Q_CORE_EXPORT QUrlQuery @@ -71,7 +71,7 @@ public: QUrlQuery(const QUrlQuery &other); QUrlQuery &operator=(const QUrlQuery &other); #ifdef Q_COMPILER_RVALUE_REFS - QUrlQuery &operator=(QUrlQuery &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QUrlQuery &operator=(QUrlQuery &&other) noexcept { swap(other); return *this; } #endif ~QUrlQuery(); @@ -79,7 +79,7 @@ public: bool operator!=(const QUrlQuery &other) const { return !(*this == other); } - void swap(QUrlQuery &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + void swap(QUrlQuery &other) noexcept { qSwap(d, other.d); } bool isEmpty() const; bool isDetached() const; @@ -111,7 +111,7 @@ public: private: friend class QUrl; - friend Q_CORE_EXPORT uint qHash(const QUrlQuery &key, uint seed) Q_DECL_NOTHROW; + friend Q_CORE_EXPORT uint qHash(const QUrlQuery &key, uint seed) noexcept; QSharedDataPointer d; public: typedef QSharedDataPointer DataPtr; diff --git a/src/corelib/io/qurlrecode.cpp b/src/corelib/io/qurlrecode.cpp index 443ae18b21..f23480c755 100644 --- a/src/corelib/io/qurlrecode.cpp +++ b/src/corelib/io/qurlrecode.cpp @@ -692,7 +692,7 @@ qt_urlRecode(QString &appendTo, const QChar *begin, const QChar *end, } // qstring.cpp -bool qt_is_ascii(const char *&ptr, const char *end) Q_DECL_NOTHROW; +bool qt_is_ascii(const char *&ptr, const char *end) noexcept; /*! \internal diff --git a/src/corelib/itemmodels/qabstractitemmodel.h b/src/corelib/itemmodels/qabstractitemmodel.h index c34876d1d6..496f583c22 100644 --- a/src/corelib/itemmodels/qabstractitemmodel.h +++ b/src/corelib/itemmodels/qabstractitemmodel.h @@ -57,12 +57,12 @@ class Q_CORE_EXPORT QModelIndex { friend class QAbstractItemModel; public: - Q_DECL_CONSTEXPR inline QModelIndex() Q_DECL_NOTHROW : r(-1), c(-1), i(0), m(nullptr) {} + Q_DECL_CONSTEXPR inline QModelIndex() noexcept : r(-1), c(-1), i(0), m(nullptr) {} // compiler-generated copy/move ctors/assignment operators are fine! - Q_DECL_CONSTEXPR inline int row() const Q_DECL_NOTHROW { return r; } - Q_DECL_CONSTEXPR inline int column() const Q_DECL_NOTHROW { return c; } - Q_DECL_CONSTEXPR inline quintptr internalId() const Q_DECL_NOTHROW { return i; } - inline void *internalPointer() const Q_DECL_NOTHROW { return reinterpret_cast(i); } + Q_DECL_CONSTEXPR inline int row() const noexcept { return r; } + Q_DECL_CONSTEXPR inline int column() const noexcept { return c; } + Q_DECL_CONSTEXPR inline quintptr internalId() const noexcept { return i; } + inline void *internalPointer() const noexcept { return reinterpret_cast(i); } inline QModelIndex parent() const; inline QModelIndex sibling(int row, int column) const; inline QModelIndex siblingAtColumn(int column) const; @@ -72,13 +72,13 @@ public: #endif inline QVariant data(int role = Qt::DisplayRole) const; inline Qt::ItemFlags flags() const; - Q_DECL_CONSTEXPR inline const QAbstractItemModel *model() const Q_DECL_NOTHROW { return m; } - Q_DECL_CONSTEXPR inline bool isValid() const Q_DECL_NOTHROW { return (r >= 0) && (c >= 0) && (m != nullptr); } - Q_DECL_CONSTEXPR inline bool operator==(const QModelIndex &other) const Q_DECL_NOTHROW + Q_DECL_CONSTEXPR inline const QAbstractItemModel *model() const noexcept { return m; } + Q_DECL_CONSTEXPR inline bool isValid() const noexcept { return (r >= 0) && (c >= 0) && (m != nullptr); } + Q_DECL_CONSTEXPR inline bool operator==(const QModelIndex &other) const noexcept { return (other.r == r) && (other.i == i) && (other.c == c) && (other.m == m); } - Q_DECL_CONSTEXPR inline bool operator!=(const QModelIndex &other) const Q_DECL_NOTHROW + Q_DECL_CONSTEXPR inline bool operator!=(const QModelIndex &other) const noexcept { return !(*this == other); } - Q_DECL_CONSTEXPR inline bool operator<(const QModelIndex &other) const Q_DECL_NOTHROW + Q_DECL_CONSTEXPR inline bool operator<(const QModelIndex &other) const noexcept { return r < other.r || (r == other.r && (c < other.c @@ -86,9 +86,9 @@ public: || (i == other.i && std::less()(m, other.m)))))); } private: - inline QModelIndex(int arow, int acolumn, void *ptr, const QAbstractItemModel *amodel) Q_DECL_NOTHROW + inline QModelIndex(int arow, int acolumn, void *ptr, const QAbstractItemModel *amodel) noexcept : r(arow), c(acolumn), i(reinterpret_cast(ptr)), m(amodel) {} - Q_DECL_CONSTEXPR inline QModelIndex(int arow, int acolumn, quintptr id, const QAbstractItemModel *amodel) Q_DECL_NOTHROW + Q_DECL_CONSTEXPR inline QModelIndex(int arow, int acolumn, quintptr id, const QAbstractItemModel *amodel) noexcept : r(arow), c(acolumn), i(id), m(amodel) {} int r, c; quintptr i; @@ -103,7 +103,7 @@ Q_CORE_EXPORT QDebug operator<<(QDebug, const QModelIndex &); class QPersistentModelIndexData; // qHash is a friend, but we can't use default arguments for friends (ยง8.3.6.4) -uint qHash(const QPersistentModelIndex &index, uint seed = 0) Q_DECL_NOTHROW; +uint qHash(const QPersistentModelIndex &index, uint seed = 0) noexcept; class Q_CORE_EXPORT QPersistentModelIndex { @@ -118,12 +118,12 @@ public: { return !operator==(other); } QPersistentModelIndex &operator=(const QPersistentModelIndex &other); #ifdef Q_COMPILER_RVALUE_REFS - inline QPersistentModelIndex(QPersistentModelIndex &&other) Q_DECL_NOTHROW + inline QPersistentModelIndex(QPersistentModelIndex &&other) noexcept : d(other.d) { other.d = nullptr; } - inline QPersistentModelIndex &operator=(QPersistentModelIndex &&other) Q_DECL_NOTHROW + inline QPersistentModelIndex &operator=(QPersistentModelIndex &&other) noexcept { qSwap(d, other.d); return *this; } #endif - inline void swap(QPersistentModelIndex &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + inline void swap(QPersistentModelIndex &other) noexcept { qSwap(d, other.d); } bool operator==(const QModelIndex &other) const; bool operator!=(const QModelIndex &other) const; QPersistentModelIndex &operator=(const QModelIndex &other); @@ -143,14 +143,14 @@ public: bool isValid() const; private: QPersistentModelIndexData *d; - friend uint qHash(const QPersistentModelIndex &, uint seed) Q_DECL_NOTHROW; + friend uint qHash(const QPersistentModelIndex &, uint seed) noexcept; #ifndef QT_NO_DEBUG_STREAM friend Q_CORE_EXPORT QDebug operator<<(QDebug, const QPersistentModelIndex &); #endif }; Q_DECLARE_SHARED(QPersistentModelIndex) -inline uint qHash(const QPersistentModelIndex &index, uint seed) Q_DECL_NOTHROW +inline uint qHash(const QPersistentModelIndex &index, uint seed) noexcept { return qHash(index.d, seed); } @@ -464,7 +464,7 @@ inline QVariant QModelIndex::data(int arole) const inline Qt::ItemFlags QModelIndex::flags() const { return m ? m->flags(*this) : Qt::ItemFlags(); } -inline uint qHash(const QModelIndex &index) Q_DECL_NOTHROW +inline uint qHash(const QModelIndex &index) noexcept { return uint((uint(index.row()) << 4) + index.column() + index.internalId()); } QT_END_NAMESPACE diff --git a/src/corelib/itemmodels/qitemselectionmodel.h b/src/corelib/itemmodels/qitemselectionmodel.h index 1c924053a5..e5cd24817b 100644 --- a/src/corelib/itemmodels/qitemselectionmodel.h +++ b/src/corelib/itemmodels/qitemselectionmodel.h @@ -61,9 +61,9 @@ public: inline QItemSelectionRange(const QItemSelectionRange &other) : tl(other.tl), br(other.br) {} # ifdef Q_COMPILER_RVALUE_REFS - QItemSelectionRange(QItemSelectionRange &&other) Q_DECL_NOTHROW + QItemSelectionRange(QItemSelectionRange &&other) noexcept : tl(std::move(other.tl)), br(std::move(other.br)) {} - QItemSelectionRange &operator=(QItemSelectionRange &&other) Q_DECL_NOTHROW + QItemSelectionRange &operator=(QItemSelectionRange &&other) noexcept { tl = std::move(other.tl); br = std::move(other.br); return *this; } # endif QItemSelectionRange &operator=(const QItemSelectionRange &other) @@ -72,7 +72,7 @@ public: QItemSelectionRange(const QModelIndex &topL, const QModelIndex &bottomR) : tl(topL), br(bottomR) {} explicit QItemSelectionRange(const QModelIndex &index) : tl(index), br(tl) {} - void swap(QItemSelectionRange &other) Q_DECL_NOTHROW + void swap(QItemSelectionRange &other) noexcept { qSwap(tl, other.tl); qSwap(br, other.br); @@ -249,7 +249,7 @@ Q_TEMPLATE_EXTERN template class Q_CORE_EXPORT QList; class Q_CORE_EXPORT QItemSelection : public QList { public: - QItemSelection() Q_DECL_NOTHROW : QList() {} + QItemSelection() noexcept : QList() {} QItemSelection(const QModelIndex &topLeft, const QModelIndex &bottomRight); // reusing QList::swap() here is OK! diff --git a/src/corelib/kernel/qcore_unix_p.h b/src/corelib/kernel/qcore_unix_p.h index 32ef6408c2..7f58813535 100644 --- a/src/corelib/kernel/qcore_unix_p.h +++ b/src/corelib/kernel/qcore_unix_p.h @@ -347,7 +347,7 @@ static inline pid_t qt_safe_waitpid(pid_t pid, int *status, int options) #endif // in qelapsedtimer_mac.cpp or qtimestamp_unix.cpp -timespec qt_gettime() Q_DECL_NOTHROW; +timespec qt_gettime() noexcept; void qt_nanosleep(timespec amount); QByteArray qt_readlink(const char *path); diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 5da33a5aae..038de264cb 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -369,7 +369,7 @@ uint QCoreApplicationPrivate::attribs = (1 << Qt::AA_SynthesizeMouseForUnhandledTabletEvents); struct QCoreApplicationData { - QCoreApplicationData() Q_DECL_NOTHROW { + QCoreApplicationData() noexcept { applicationNameSet = false; applicationVersionSet = false; } diff --git a/src/corelib/kernel/qcoreevent.cpp b/src/corelib/kernel/qcoreevent.cpp index cacbb1e495..aabd32b4a8 100644 --- a/src/corelib/kernel/qcoreevent.cpp +++ b/src/corelib/kernel/qcoreevent.cpp @@ -421,7 +421,7 @@ struct QBasicAtomicBitField { QBasicAtomicInteger next; QBasicAtomicInteger data[NumInts]; - bool allocateSpecific(int which) Q_DECL_NOTHROW + bool allocateSpecific(int which) noexcept { QBasicAtomicInteger &entry = data[which / BitsPerInt]; const uint old = entry.load(); @@ -437,7 +437,7 @@ struct QBasicAtomicBitField { // loop. } - int allocateNext() Q_DECL_NOTHROW + int allocateNext() noexcept { // Unroll loop to iterate over ints, then bits? Would save // potentially a lot of cmpxchgs, because we can scan the @@ -463,7 +463,7 @@ typedef QBasicAtomicBitField UserEventTypeRe static UserEventTypeRegistry userEventTypeRegistry; -static inline int registerEventTypeZeroBased(int id) Q_DECL_NOTHROW +static inline int registerEventTypeZeroBased(int id) noexcept { // if the type hint hasn't been registered yet, take it: if (id < UserEventTypeRegistry::NumBits && id >= 0 && userEventTypeRegistry.allocateSpecific(id)) @@ -486,7 +486,7 @@ static inline int registerEventTypeZeroBased(int id) Q_DECL_NOTHROW Returns -1 if all available values are already taken or the program is shutting down. */ -int QEvent::registerEventType(int hint) Q_DECL_NOTHROW +int QEvent::registerEventType(int hint) noexcept { const int result = registerEventTypeZeroBased(QEvent::MaxUser - hint); return result < 0 ? -1 : QEvent::MaxUser - result ; diff --git a/src/corelib/kernel/qcoreevent.h b/src/corelib/kernel/qcoreevent.h index ac974ba411..05af1a6132 100644 --- a/src/corelib/kernel/qcoreevent.h +++ b/src/corelib/kernel/qcoreevent.h @@ -307,7 +307,7 @@ public: inline void accept() { m_accept = true; } inline void ignore() { m_accept = false; } - static int registerEventType(int hint = -1) Q_DECL_NOTHROW; + static int registerEventType(int hint = -1) noexcept; protected: QEventPrivate *d; diff --git a/src/corelib/kernel/qdeadlinetimer.cpp b/src/corelib/kernel/qdeadlinetimer.cpp index 6aa886cfe1..e0d9d9de73 100644 --- a/src/corelib/kernel/qdeadlinetimer.cpp +++ b/src/corelib/kernel/qdeadlinetimer.cpp @@ -188,7 +188,7 @@ Q_DECL_CONST_FUNCTION static inline QPair toSecsAndNSecs(qint64 \sa hasExpired(), isForever(), remainingTime(), setRemainingTime() */ -QDeadlineTimer::QDeadlineTimer(qint64 msecs, Qt::TimerType type) Q_DECL_NOTHROW +QDeadlineTimer::QDeadlineTimer(qint64 msecs, Qt::TimerType type) noexcept : t2(0) { setRemainingTime(msecs, type); @@ -260,7 +260,7 @@ QDeadlineTimer::QDeadlineTimer(qint64 msecs, Qt::TimerType type) Q_DECL_NOTHROW \sa setPreciseRemainingTime(), hasExpired(), isForever(), remainingTime() */ -void QDeadlineTimer::setRemainingTime(qint64 msecs, Qt::TimerType timerType) Q_DECL_NOTHROW +void QDeadlineTimer::setRemainingTime(qint64 msecs, Qt::TimerType timerType) noexcept { if (msecs == -1) *this = QDeadlineTimer(Forever, timerType); @@ -279,7 +279,7 @@ void QDeadlineTimer::setRemainingTime(qint64 msecs, Qt::TimerType timerType) Q_D \sa setRemainingTime(), hasExpired(), isForever(), remainingTime() */ -void QDeadlineTimer::setPreciseRemainingTime(qint64 secs, qint64 nsecs, Qt::TimerType timerType) Q_DECL_NOTHROW +void QDeadlineTimer::setPreciseRemainingTime(qint64 secs, qint64 nsecs, Qt::TimerType timerType) noexcept { if (secs == -1) { *this = QDeadlineTimer(Forever, timerType); @@ -342,7 +342,7 @@ void QDeadlineTimer::setPreciseRemainingTime(qint64 secs, qint64 nsecs, Qt::Time \sa isForever(), remainingTime() */ -bool QDeadlineTimer::hasExpired() const Q_DECL_NOTHROW +bool QDeadlineTimer::hasExpired() const noexcept { if (isForever()) return false; @@ -389,7 +389,7 @@ void QDeadlineTimer::setTimerType(Qt::TimerType timerType) \sa remainingTimeNSecs(), isForever(), hasExpired() */ -qint64 QDeadlineTimer::remainingTime() const Q_DECL_NOTHROW +qint64 QDeadlineTimer::remainingTime() const noexcept { qint64 ns = remainingTimeNSecs(); return ns <= 0 ? ns : (ns + 999999) / (1000 * 1000); @@ -403,7 +403,7 @@ qint64 QDeadlineTimer::remainingTime() const Q_DECL_NOTHROW \sa remainingTime(), isForever(), hasExpired() */ -qint64 QDeadlineTimer::remainingTimeNSecs() const Q_DECL_NOTHROW +qint64 QDeadlineTimer::remainingTimeNSecs() const noexcept { if (isForever()) return -1; @@ -416,7 +416,7 @@ qint64 QDeadlineTimer::remainingTimeNSecs() const Q_DECL_NOTHROW Same as remainingTimeNSecs, but may return negative remaining times. Does not deal with Forever. */ -qint64 QDeadlineTimer::rawRemainingTimeNSecs() const Q_DECL_NOTHROW +qint64 QDeadlineTimer::rawRemainingTimeNSecs() const noexcept { QDeadlineTimer now = current(timerType()); if (QDeadlineTimerNanosecondsInT2) @@ -444,7 +444,7 @@ qint64 QDeadlineTimer::rawRemainingTimeNSecs() const Q_DECL_NOTHROW \sa remainingTime(), deadlineNSecs(), setDeadline() */ -qint64 QDeadlineTimer::deadline() const Q_DECL_NOTHROW +qint64 QDeadlineTimer::deadline() const noexcept { if (isForever()) return t1; @@ -471,7 +471,7 @@ qint64 QDeadlineTimer::deadline() const Q_DECL_NOTHROW \sa remainingTime(), deadlineNSecs() */ -qint64 QDeadlineTimer::deadlineNSecs() const Q_DECL_NOTHROW +qint64 QDeadlineTimer::deadlineNSecs() const noexcept { if (isForever()) return t1; @@ -492,7 +492,7 @@ qint64 QDeadlineTimer::deadlineNSecs() const Q_DECL_NOTHROW \sa setPreciseDeadline(), deadline(), deadlineNSecs(), setRemainingTime() */ -void QDeadlineTimer::setDeadline(qint64 msecs, Qt::TimerType timerType) Q_DECL_NOTHROW +void QDeadlineTimer::setDeadline(qint64 msecs, Qt::TimerType timerType) noexcept { if (msecs == (std::numeric_limits::max)()) { setPreciseDeadline(msecs, 0, timerType); // msecs == MAX implies Forever @@ -513,7 +513,7 @@ void QDeadlineTimer::setDeadline(qint64 msecs, Qt::TimerType timerType) Q_DECL_N \sa setDeadline(), deadline(), deadlineNSecs(), setRemainingTime() */ -void QDeadlineTimer::setPreciseDeadline(qint64 secs, qint64 nsecs, Qt::TimerType timerType) Q_DECL_NOTHROW +void QDeadlineTimer::setPreciseDeadline(qint64 secs, qint64 nsecs, Qt::TimerType timerType) noexcept { type = timerType; if (secs == (std::numeric_limits::max)() || nsecs == (std::numeric_limits::max)()) { @@ -534,7 +534,7 @@ void QDeadlineTimer::setPreciseDeadline(qint64 secs, qint64 nsecs, Qt::TimerType \note if \a dt was created as expired, its deadline is indeterminate and adding an amount of time may or may not cause it to become unexpired. */ -QDeadlineTimer QDeadlineTimer::addNSecs(QDeadlineTimer dt, qint64 nsecs) Q_DECL_NOTHROW +QDeadlineTimer QDeadlineTimer::addNSecs(QDeadlineTimer dt, qint64 nsecs) noexcept { if (dt.isForever() || nsecs == (std::numeric_limits::max)()) { dt = QDeadlineTimer(Forever, dt.timerType()); diff --git a/src/corelib/kernel/qdeadlinetimer.h b/src/corelib/kernel/qdeadlinetimer.h index 1a4ee04a96..8032ee9018 100644 --- a/src/corelib/kernel/qdeadlinetimer.h +++ b/src/corelib/kernel/qdeadlinetimer.h @@ -63,49 +63,49 @@ class Q_CORE_EXPORT QDeadlineTimer public: enum ForeverConstant { Forever }; - Q_DECL_CONSTEXPR QDeadlineTimer(Qt::TimerType type_ = Qt::CoarseTimer) Q_DECL_NOTHROW + Q_DECL_CONSTEXPR QDeadlineTimer(Qt::TimerType type_ = Qt::CoarseTimer) noexcept : t1(0), t2(0), type(type_) {} - Q_DECL_CONSTEXPR QDeadlineTimer(ForeverConstant, Qt::TimerType type_ = Qt::CoarseTimer) Q_DECL_NOTHROW + Q_DECL_CONSTEXPR QDeadlineTimer(ForeverConstant, Qt::TimerType type_ = Qt::CoarseTimer) noexcept : t1(std::numeric_limits::max()), t2(0), type(type_) {} - explicit QDeadlineTimer(qint64 msecs, Qt::TimerType type = Qt::CoarseTimer) Q_DECL_NOTHROW; + explicit QDeadlineTimer(qint64 msecs, Qt::TimerType type = Qt::CoarseTimer) noexcept; - void swap(QDeadlineTimer &other) Q_DECL_NOTHROW + void swap(QDeadlineTimer &other) noexcept { qSwap(t1, other.t1); qSwap(t2, other.t2); qSwap(type, other.type); } - Q_DECL_CONSTEXPR bool isForever() const Q_DECL_NOTHROW + Q_DECL_CONSTEXPR bool isForever() const noexcept { return t1 == (std::numeric_limits::max)(); } - bool hasExpired() const Q_DECL_NOTHROW; + bool hasExpired() const noexcept; - Qt::TimerType timerType() const Q_DECL_NOTHROW + Qt::TimerType timerType() const noexcept { return Qt::TimerType(type & 0xff); } void setTimerType(Qt::TimerType type); - qint64 remainingTime() const Q_DECL_NOTHROW; - qint64 remainingTimeNSecs() const Q_DECL_NOTHROW; - void setRemainingTime(qint64 msecs, Qt::TimerType type = Qt::CoarseTimer) Q_DECL_NOTHROW; + qint64 remainingTime() const noexcept; + qint64 remainingTimeNSecs() const noexcept; + void setRemainingTime(qint64 msecs, Qt::TimerType type = Qt::CoarseTimer) noexcept; void setPreciseRemainingTime(qint64 secs, qint64 nsecs = 0, - Qt::TimerType type = Qt::CoarseTimer) Q_DECL_NOTHROW; + Qt::TimerType type = Qt::CoarseTimer) noexcept; - qint64 deadline() const Q_DECL_NOTHROW Q_DECL_PURE_FUNCTION; - qint64 deadlineNSecs() const Q_DECL_NOTHROW Q_DECL_PURE_FUNCTION; - void setDeadline(qint64 msecs, Qt::TimerType timerType = Qt::CoarseTimer) Q_DECL_NOTHROW; + qint64 deadline() const noexcept Q_DECL_PURE_FUNCTION; + qint64 deadlineNSecs() const noexcept Q_DECL_PURE_FUNCTION; + void setDeadline(qint64 msecs, Qt::TimerType timerType = Qt::CoarseTimer) noexcept; void setPreciseDeadline(qint64 secs, qint64 nsecs = 0, - Qt::TimerType type = Qt::CoarseTimer) Q_DECL_NOTHROW; + Qt::TimerType type = Qt::CoarseTimer) noexcept; - static QDeadlineTimer addNSecs(QDeadlineTimer dt, qint64 nsecs) Q_DECL_NOTHROW Q_DECL_PURE_FUNCTION; - static QDeadlineTimer current(Qt::TimerType timerType = Qt::CoarseTimer) Q_DECL_NOTHROW; + static QDeadlineTimer addNSecs(QDeadlineTimer dt, qint64 nsecs) noexcept Q_DECL_PURE_FUNCTION; + static QDeadlineTimer current(Qt::TimerType timerType = Qt::CoarseTimer) noexcept; - friend bool operator==(QDeadlineTimer d1, QDeadlineTimer d2) Q_DECL_NOTHROW + friend bool operator==(QDeadlineTimer d1, QDeadlineTimer d2) noexcept { return d1.t1 == d2.t1 && d1.t2 == d2.t2; } - friend bool operator!=(QDeadlineTimer d1, QDeadlineTimer d2) Q_DECL_NOTHROW + friend bool operator!=(QDeadlineTimer d1, QDeadlineTimer d2) noexcept { return !(d1 == d2); } - friend bool operator<(QDeadlineTimer d1, QDeadlineTimer d2) Q_DECL_NOTHROW + friend bool operator<(QDeadlineTimer d1, QDeadlineTimer d2) noexcept { return d1.t1 < d2.t1 || (d1.t1 == d2.t1 && d1.t2 < d2.t2); } - friend bool operator<=(QDeadlineTimer d1, QDeadlineTimer d2) Q_DECL_NOTHROW + friend bool operator<=(QDeadlineTimer d1, QDeadlineTimer d2) noexcept { return d1 == d2 || d1 < d2; } - friend bool operator>(QDeadlineTimer d1, QDeadlineTimer d2) Q_DECL_NOTHROW + friend bool operator>(QDeadlineTimer d1, QDeadlineTimer d2) noexcept { return d2 < d1; } - friend bool operator>=(QDeadlineTimer d1, QDeadlineTimer d2) Q_DECL_NOTHROW + friend bool operator>=(QDeadlineTimer d1, QDeadlineTimer d2) noexcept { return !(d1 < d2); } friend QDeadlineTimer operator+(QDeadlineTimer dt, qint64 msecs) @@ -160,7 +160,7 @@ public: setPreciseRemainingTime(0, std::chrono::nanoseconds(remaining).count(), type_); } - std::chrono::nanoseconds remainingTimeAsDuration() const Q_DECL_NOTHROW + std::chrono::nanoseconds remainingTimeAsDuration() const noexcept { if (isForever()) return std::chrono::nanoseconds::max(); @@ -186,7 +186,7 @@ private: unsigned t2; unsigned type; - qint64 rawRemainingTimeNSecs() const Q_DECL_NOTHROW; + qint64 rawRemainingTimeNSecs() const noexcept; public: // This is not a public function, it's here only for Qt's internal convenience... diff --git a/src/corelib/kernel/qelapsedtimer.cpp b/src/corelib/kernel/qelapsedtimer.cpp index e578b5b8b3..adb554b624 100644 --- a/src/corelib/kernel/qelapsedtimer.cpp +++ b/src/corelib/kernel/qelapsedtimer.cpp @@ -236,7 +236,7 @@ static const qint64 invalidData = Q_INT64_C(0x8000000000000000); \sa isValid(), start(), restart() */ -void QElapsedTimer::invalidate() Q_DECL_NOTHROW +void QElapsedTimer::invalidate() noexcept { t1 = t2 = invalidData; } @@ -247,7 +247,7 @@ void QElapsedTimer::invalidate() Q_DECL_NOTHROW \sa invalidate(), start(), restart() */ -bool QElapsedTimer::isValid() const Q_DECL_NOTHROW +bool QElapsedTimer::isValid() const noexcept { return t1 != invalidData && t2 != invalidData; } @@ -260,7 +260,7 @@ bool QElapsedTimer::isValid() const Q_DECL_NOTHROW \sa elapsed(), QDeadlineTimer */ -bool QElapsedTimer::hasExpired(qint64 timeout) const Q_DECL_NOTHROW +bool QElapsedTimer::hasExpired(qint64 timeout) const noexcept { // if timeout is -1, quint64(timeout) is LLINT_MAX, so this will be // considered as never expired diff --git a/src/corelib/kernel/qelapsedtimer.h b/src/corelib/kernel/qelapsedtimer.h index 7954b41bf4..873847f6b6 100644 --- a/src/corelib/kernel/qelapsedtimer.h +++ b/src/corelib/kernel/qelapsedtimer.h @@ -62,28 +62,28 @@ public: { } - static ClockType clockType() Q_DECL_NOTHROW; - static bool isMonotonic() Q_DECL_NOTHROW; + static ClockType clockType() noexcept; + static bool isMonotonic() noexcept; - void start() Q_DECL_NOTHROW; - qint64 restart() Q_DECL_NOTHROW; - void invalidate() Q_DECL_NOTHROW; - bool isValid() const Q_DECL_NOTHROW; + void start() noexcept; + qint64 restart() noexcept; + void invalidate() noexcept; + bool isValid() const noexcept; - qint64 nsecsElapsed() const Q_DECL_NOTHROW; - qint64 elapsed() const Q_DECL_NOTHROW; - bool hasExpired(qint64 timeout) const Q_DECL_NOTHROW; + qint64 nsecsElapsed() const noexcept; + qint64 elapsed() const noexcept; + bool hasExpired(qint64 timeout) const noexcept; - qint64 msecsSinceReference() const Q_DECL_NOTHROW; - qint64 msecsTo(const QElapsedTimer &other) const Q_DECL_NOTHROW; - qint64 secsTo(const QElapsedTimer &other) const Q_DECL_NOTHROW; + qint64 msecsSinceReference() const noexcept; + qint64 msecsTo(const QElapsedTimer &other) const noexcept; + qint64 secsTo(const QElapsedTimer &other) const noexcept; - bool operator==(const QElapsedTimer &other) const Q_DECL_NOTHROW + bool operator==(const QElapsedTimer &other) const noexcept { return t1 == other.t1 && t2 == other.t2; } - bool operator!=(const QElapsedTimer &other) const Q_DECL_NOTHROW + bool operator!=(const QElapsedTimer &other) const noexcept { return !(*this == other); } - friend bool Q_CORE_EXPORT operator<(const QElapsedTimer &v1, const QElapsedTimer &v2) Q_DECL_NOTHROW; + friend bool Q_CORE_EXPORT operator<(const QElapsedTimer &v1, const QElapsedTimer &v2) noexcept; private: qint64 t1; diff --git a/src/corelib/kernel/qelapsedtimer_generic.cpp b/src/corelib/kernel/qelapsedtimer_generic.cpp index fdeb385188..fe959e3c94 100644 --- a/src/corelib/kernel/qelapsedtimer_generic.cpp +++ b/src/corelib/kernel/qelapsedtimer_generic.cpp @@ -48,7 +48,7 @@ QT_BEGIN_NAMESPACE \sa isMonotonic() */ -QElapsedTimer::ClockType QElapsedTimer::clockType() Q_DECL_NOTHROW +QElapsedTimer::ClockType QElapsedTimer::clockType() noexcept { return SystemTime; } @@ -60,7 +60,7 @@ QElapsedTimer::ClockType QElapsedTimer::clockType() Q_DECL_NOTHROW \sa clockType(), QElapsedTimer::ClockType */ -bool QElapsedTimer::isMonotonic() Q_DECL_NOTHROW +bool QElapsedTimer::isMonotonic() noexcept { return false; } @@ -75,7 +75,7 @@ bool QElapsedTimer::isMonotonic() Q_DECL_NOTHROW \sa restart(), invalidate(), elapsed() */ -void QElapsedTimer::start() Q_DECL_NOTHROW +void QElapsedTimer::start() noexcept { restart(); } @@ -97,7 +97,7 @@ void QElapsedTimer::start() Q_DECL_NOTHROW \sa start(), invalidate(), elapsed(), isValid() */ -qint64 QElapsedTimer::restart() Q_DECL_NOTHROW +qint64 QElapsedTimer::restart() noexcept { qint64 old = t1; t1 = QDateTime::currentMSecsSinceEpoch(); @@ -118,7 +118,7 @@ qint64 QElapsedTimer::restart() Q_DECL_NOTHROW \sa start(), restart(), hasExpired(), invalidate() */ -qint64 QElapsedTimer::nsecsElapsed() const Q_DECL_NOTHROW +qint64 QElapsedTimer::nsecsElapsed() const noexcept { return elapsed() * 1000000; } @@ -132,7 +132,7 @@ qint64 QElapsedTimer::nsecsElapsed() const Q_DECL_NOTHROW \sa start(), restart(), hasExpired(), isValid(), invalidate() */ -qint64 QElapsedTimer::elapsed() const Q_DECL_NOTHROW +qint64 QElapsedTimer::elapsed() const noexcept { return QDateTime::currentMSecsSinceEpoch() - t1; } @@ -152,7 +152,7 @@ qint64 QElapsedTimer::elapsed() const Q_DECL_NOTHROW \sa clockType(), elapsed() */ -qint64 QElapsedTimer::msecsSinceReference() const Q_DECL_NOTHROW +qint64 QElapsedTimer::msecsSinceReference() const noexcept { return t1; } @@ -167,7 +167,7 @@ qint64 QElapsedTimer::msecsSinceReference() const Q_DECL_NOTHROW \sa secsTo(), elapsed() */ -qint64 QElapsedTimer::msecsTo(const QElapsedTimer &other) const Q_DECL_NOTHROW +qint64 QElapsedTimer::msecsTo(const QElapsedTimer &other) const noexcept { qint64 diff = other.t1 - t1; return diff; @@ -183,7 +183,7 @@ qint64 QElapsedTimer::msecsTo(const QElapsedTimer &other) const Q_DECL_NOTHROW \sa msecsTo(), elapsed() */ -qint64 QElapsedTimer::secsTo(const QElapsedTimer &other) const Q_DECL_NOTHROW +qint64 QElapsedTimer::secsTo(const QElapsedTimer &other) const noexcept { return msecsTo(other) / 1000; } @@ -197,12 +197,12 @@ qint64 QElapsedTimer::secsTo(const QElapsedTimer &other) const Q_DECL_NOTHROW 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) Q_DECL_NOTHROW +bool operator<(const QElapsedTimer &v1, const QElapsedTimer &v2) noexcept { return v1.t1 < v2.t1; } -QDeadlineTimer QDeadlineTimer::current(Qt::TimerType timerType) Q_DECL_NOTHROW +QDeadlineTimer QDeadlineTimer::current(Qt::TimerType timerType) noexcept { QDeadlineTimer result; result.t1 = QDateTime::currentMSecsSinceEpoch() * 1000 * 1000; diff --git a/src/corelib/kernel/qelapsedtimer_mac.cpp b/src/corelib/kernel/qelapsedtimer_mac.cpp index 7490693991..5370cf7b3d 100644 --- a/src/corelib/kernel/qelapsedtimer_mac.cpp +++ b/src/corelib/kernel/qelapsedtimer_mac.cpp @@ -58,12 +58,12 @@ typedef __int128_t LargeInt; typedef qint64 LargeInt; #endif -QElapsedTimer::ClockType QElapsedTimer::clockType() Q_DECL_NOTHROW +QElapsedTimer::ClockType QElapsedTimer::clockType() noexcept { return MachAbsoluteTime; } -bool QElapsedTimer::isMonotonic() Q_DECL_NOTHROW +bool QElapsedTimer::isMonotonic() noexcept { return true; } @@ -87,7 +87,7 @@ static qint64 absoluteToMSecs(qint64 cpuTime) return absoluteToNSecs(cpuTime) / 1000000; } -timespec qt_gettime() Q_DECL_NOTHROW +timespec qt_gettime() noexcept { timespec tv; @@ -107,13 +107,13 @@ void qt_nanosleep(timespec amount) EINTR_LOOP(r, nanosleep(&amount, &amount)); } -void QElapsedTimer::start() Q_DECL_NOTHROW +void QElapsedTimer::start() noexcept { t1 = mach_absolute_time(); t2 = 0; } -qint64 QElapsedTimer::restart() Q_DECL_NOTHROW +qint64 QElapsedTimer::restart() noexcept { qint64 old = t1; t1 = mach_absolute_time(); @@ -122,39 +122,39 @@ qint64 QElapsedTimer::restart() Q_DECL_NOTHROW return absoluteToMSecs(t1 - old); } -qint64 QElapsedTimer::nsecsElapsed() const Q_DECL_NOTHROW +qint64 QElapsedTimer::nsecsElapsed() const noexcept { uint64_t cpu_time = mach_absolute_time(); return absoluteToNSecs(cpu_time - t1); } -qint64 QElapsedTimer::elapsed() const Q_DECL_NOTHROW +qint64 QElapsedTimer::elapsed() const noexcept { uint64_t cpu_time = mach_absolute_time(); return absoluteToMSecs(cpu_time - t1); } -qint64 QElapsedTimer::msecsSinceReference() const Q_DECL_NOTHROW +qint64 QElapsedTimer::msecsSinceReference() const noexcept { return absoluteToMSecs(t1); } -qint64 QElapsedTimer::msecsTo(const QElapsedTimer &other) const Q_DECL_NOTHROW +qint64 QElapsedTimer::msecsTo(const QElapsedTimer &other) const noexcept { return absoluteToMSecs(other.t1 - t1); } -qint64 QElapsedTimer::secsTo(const QElapsedTimer &other) const Q_DECL_NOTHROW +qint64 QElapsedTimer::secsTo(const QElapsedTimer &other) const noexcept { return msecsTo(other) / 1000; } -bool operator<(const QElapsedTimer &v1, const QElapsedTimer &v2) Q_DECL_NOTHROW +bool operator<(const QElapsedTimer &v1, const QElapsedTimer &v2) noexcept { return v1.t1 < v2.t1; } -QDeadlineTimer QDeadlineTimer::current(Qt::TimerType timerType) Q_DECL_NOTHROW +QDeadlineTimer QDeadlineTimer::current(Qt::TimerType timerType) noexcept { Q_STATIC_ASSERT(!QDeadlineTimerNanosecondsInT2); QDeadlineTimer result; diff --git a/src/corelib/kernel/qelapsedtimer_unix.cpp b/src/corelib/kernel/qelapsedtimer_unix.cpp index e166d4e3d2..ccc2eeafa3 100644 --- a/src/corelib/kernel/qelapsedtimer_unix.cpp +++ b/src/corelib/kernel/qelapsedtimer_unix.cpp @@ -150,12 +150,12 @@ static int unixCheckClockType() #endif } -bool QElapsedTimer::isMonotonic() Q_DECL_NOTHROW +bool QElapsedTimer::isMonotonic() noexcept { return clockType() == MonotonicClock; } -QElapsedTimer::ClockType QElapsedTimer::clockType() Q_DECL_NOTHROW +QElapsedTimer::ClockType QElapsedTimer::clockType() noexcept { return unixCheckClockType() == CLOCK_REALTIME ? SystemTime : MonotonicClock; } @@ -169,7 +169,7 @@ static inline void do_gettime(qint64 *sec, qint64 *frac) } // used in qcore_unix.cpp and qeventdispatcher_unix.cpp -struct timespec qt_gettime() Q_DECL_NOTHROW +struct timespec qt_gettime() noexcept { qint64 sec, frac; do_gettime(&sec, &frac); @@ -204,17 +204,17 @@ static qint64 elapsedAndRestart(qint64 sec, qint64 frac, return (sec * Q_INT64_C(1000000000) + frac) / Q_INT64_C(1000000); } -void QElapsedTimer::start() Q_DECL_NOTHROW +void QElapsedTimer::start() noexcept { do_gettime(&t1, &t2); } -qint64 QElapsedTimer::restart() Q_DECL_NOTHROW +qint64 QElapsedTimer::restart() noexcept { return elapsedAndRestart(t1, t2, &t1, &t2); } -qint64 QElapsedTimer::nsecsElapsed() const Q_DECL_NOTHROW +qint64 QElapsedTimer::nsecsElapsed() const noexcept { qint64 sec, frac; do_gettime(&sec, &frac); @@ -223,34 +223,34 @@ qint64 QElapsedTimer::nsecsElapsed() const Q_DECL_NOTHROW return sec * Q_INT64_C(1000000000) + frac; } -qint64 QElapsedTimer::elapsed() const Q_DECL_NOTHROW +qint64 QElapsedTimer::elapsed() const noexcept { return nsecsElapsed() / Q_INT64_C(1000000); } -qint64 QElapsedTimer::msecsSinceReference() const Q_DECL_NOTHROW +qint64 QElapsedTimer::msecsSinceReference() const noexcept { return t1 * Q_INT64_C(1000) + t2 / Q_INT64_C(1000000); } -qint64 QElapsedTimer::msecsTo(const QElapsedTimer &other) const Q_DECL_NOTHROW +qint64 QElapsedTimer::msecsTo(const QElapsedTimer &other) const noexcept { qint64 secs = other.t1 - t1; qint64 fraction = other.t2 - t2; return (secs * Q_INT64_C(1000000000) + fraction) / Q_INT64_C(1000000); } -qint64 QElapsedTimer::secsTo(const QElapsedTimer &other) const Q_DECL_NOTHROW +qint64 QElapsedTimer::secsTo(const QElapsedTimer &other) const noexcept { return other.t1 - t1; } -bool operator<(const QElapsedTimer &v1, const QElapsedTimer &v2) Q_DECL_NOTHROW +bool operator<(const QElapsedTimer &v1, const QElapsedTimer &v2) noexcept { return v1.t1 < v2.t1 || (v1.t1 == v2.t1 && v1.t2 < v2.t2); } -QDeadlineTimer QDeadlineTimer::current(Qt::TimerType timerType) Q_DECL_NOTHROW +QDeadlineTimer QDeadlineTimer::current(Qt::TimerType timerType) noexcept { Q_STATIC_ASSERT(QDeadlineTimerNanosecondsInT2); QDeadlineTimer result; diff --git a/src/corelib/kernel/qelapsedtimer_win.cpp b/src/corelib/kernel/qelapsedtimer_win.cpp index a63290d2f8..d8a50a8277 100644 --- a/src/corelib/kernel/qelapsedtimer_win.cpp +++ b/src/corelib/kernel/qelapsedtimer_win.cpp @@ -110,25 +110,25 @@ quint64 qt_msectime() return ticksToNanoseconds(getTickCount()) / 1000000; } -QElapsedTimer::ClockType QElapsedTimer::clockType() Q_DECL_NOTHROW +QElapsedTimer::ClockType QElapsedTimer::clockType() noexcept { resolveCounterFrequency(); return counterFrequency > 0 ? PerformanceCounter : TickCounter; } -bool QElapsedTimer::isMonotonic() Q_DECL_NOTHROW +bool QElapsedTimer::isMonotonic() noexcept { return true; } -void QElapsedTimer::start() Q_DECL_NOTHROW +void QElapsedTimer::start() noexcept { t1 = getTickCount(); t2 = 0; } -qint64 QElapsedTimer::restart() Q_DECL_NOTHROW +qint64 QElapsedTimer::restart() noexcept { qint64 oldt1 = t1; t1 = getTickCount(); @@ -136,40 +136,40 @@ qint64 QElapsedTimer::restart() Q_DECL_NOTHROW return ticksToNanoseconds(t1 - oldt1) / 1000000; } -qint64 QElapsedTimer::nsecsElapsed() const Q_DECL_NOTHROW +qint64 QElapsedTimer::nsecsElapsed() const noexcept { qint64 elapsed = getTickCount() - t1; return ticksToNanoseconds(elapsed); } -qint64 QElapsedTimer::elapsed() const Q_DECL_NOTHROW +qint64 QElapsedTimer::elapsed() const noexcept { qint64 elapsed = getTickCount() - t1; return ticksToNanoseconds(elapsed) / 1000000; } -qint64 QElapsedTimer::msecsSinceReference() const Q_DECL_NOTHROW +qint64 QElapsedTimer::msecsSinceReference() const noexcept { return ticksToNanoseconds(t1) / 1000000; } -qint64 QElapsedTimer::msecsTo(const QElapsedTimer &other) const Q_DECL_NOTHROW +qint64 QElapsedTimer::msecsTo(const QElapsedTimer &other) const noexcept { qint64 difference = other.t1 - t1; return ticksToNanoseconds(difference) / 1000000; } -qint64 QElapsedTimer::secsTo(const QElapsedTimer &other) const Q_DECL_NOTHROW +qint64 QElapsedTimer::secsTo(const QElapsedTimer &other) const noexcept { return msecsTo(other) / 1000; } -bool operator<(const QElapsedTimer &v1, const QElapsedTimer &v2) Q_DECL_NOTHROW +bool operator<(const QElapsedTimer &v1, const QElapsedTimer &v2) noexcept { return (v1.t1 - v2.t1) < 0; } -QDeadlineTimer QDeadlineTimer::current(Qt::TimerType timerType) Q_DECL_NOTHROW +QDeadlineTimer QDeadlineTimer::current(Qt::TimerType timerType) noexcept { Q_STATIC_ASSERT(!QDeadlineTimerNanosecondsInT2); QDeadlineTimer result; diff --git a/src/corelib/kernel/qeventdispatcher_unix_p.h b/src/corelib/kernel/qeventdispatcher_unix_p.h index 8cfa4bbdf7..f37edfc967 100644 --- a/src/corelib/kernel/qeventdispatcher_unix_p.h +++ b/src/corelib/kernel/qeventdispatcher_unix_p.h @@ -64,10 +64,10 @@ class QEventDispatcherUNIXPrivate; struct Q_CORE_EXPORT QSocketNotifierSetUNIX final { - inline QSocketNotifierSetUNIX() Q_DECL_NOTHROW; + inline QSocketNotifierSetUNIX() noexcept; - inline bool isEmpty() const Q_DECL_NOTHROW; - inline short events() const Q_DECL_NOTHROW; + inline bool isEmpty() const noexcept; + inline short events() const noexcept; QSocketNotifier *notifiers[3]; }; @@ -150,19 +150,19 @@ public: QAtomicInt interrupt; // bool }; -inline QSocketNotifierSetUNIX::QSocketNotifierSetUNIX() Q_DECL_NOTHROW +inline QSocketNotifierSetUNIX::QSocketNotifierSetUNIX() noexcept { notifiers[0] = nullptr; notifiers[1] = nullptr; notifiers[2] = nullptr; } -inline bool QSocketNotifierSetUNIX::isEmpty() const Q_DECL_NOTHROW +inline bool QSocketNotifierSetUNIX::isEmpty() const noexcept { return !notifiers[0] && !notifiers[1] && !notifiers[2]; } -inline short QSocketNotifierSetUNIX::events() const Q_DECL_NOTHROW +inline short QSocketNotifierSetUNIX::events() const noexcept { short result = 0; diff --git a/src/corelib/kernel/qfunctions_fake_env_p.h b/src/corelib/kernel/qfunctions_fake_env_p.h index 7010d2cf5d..68d17ed4a1 100644 --- a/src/corelib/kernel/qfunctions_fake_env_p.h +++ b/src/corelib/kernel/qfunctions_fake_env_p.h @@ -72,8 +72,8 @@ Q_DECLARE_TYPEINFO(Variable, Q_MOVABLE_TYPE); struct NameEquals { typedef bool result_type; const char *name; - explicit NameEquals(const char *name) Q_DECL_NOTHROW : name(name) {} - result_type operator()(const Variable &other) const Q_DECL_NOTHROW + explicit NameEquals(const char *name) noexcept : name(name) {} + result_type operator()(const Variable &other) const noexcept { return qstrcmp(other.name, name) == 0; } }; diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index c15a9f7b0f..ace3eac2ac 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -335,7 +335,7 @@ const char *QMetaObject::className() const \since 5.7 */ -bool QMetaObject::inherits(const QMetaObject *metaObject) const Q_DECL_NOEXCEPT +bool QMetaObject::inherits(const QMetaObject *metaObject) const noexcept { const QMetaObject *m = this; do { diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp index 45d0b5df6c..19bda7e8d6 100644 --- a/src/corelib/kernel/qmetatype.cpp +++ b/src/corelib/kernel/qmetatype.cpp @@ -915,7 +915,7 @@ template struct MetaTypeOffsetsblockSig; diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h index 63c5a9ad73..6d7b9521c2 100644 --- a/src/corelib/kernel/qobject.h +++ b/src/corelib/kernel/qobject.h @@ -142,8 +142,8 @@ public: inline bool isWidgetType() const { return d_ptr->isWidget; } inline bool isWindowType() const { return d_ptr->isWindow; } - inline bool signalsBlocked() const Q_DECL_NOTHROW { return d_ptr->blockSig; } - bool blockSignals(bool b) Q_DECL_NOTHROW; + inline bool signalsBlocked() const noexcept { return d_ptr->blockSig; } + bool blockSignals(bool b) noexcept; QThread *thread() const; void moveToThread(QThread *thread); @@ -436,7 +436,7 @@ protected: QScopedPointer d_ptr; static const QMetaObject staticQtMetaObject; - friend inline const QMetaObject *qt_getQtMetaObject() Q_DECL_NOEXCEPT; + friend inline const QMetaObject *qt_getQtMetaObject() noexcept; friend struct QMetaObject; friend struct QMetaObjectPrivate; @@ -467,7 +467,7 @@ inline QMetaObject::Connection QObject::connect(const QObject *asender, const ch const char *amember, Qt::ConnectionType atype) const { return connect(asender, asignal, this, amember, atype); } -inline const QMetaObject *qt_getQtMetaObject() Q_DECL_NOEXCEPT +inline const QMetaObject *qt_getQtMetaObject() noexcept { return &QObject::staticQtMetaObject; } #ifndef QT_NO_USERDATA @@ -540,17 +540,17 @@ Q_CORE_EXPORT QDebug operator<<(QDebug, const QObject *); class QSignalBlocker { public: - inline explicit QSignalBlocker(QObject *o) Q_DECL_NOTHROW; - inline explicit QSignalBlocker(QObject &o) Q_DECL_NOTHROW; + inline explicit QSignalBlocker(QObject *o) noexcept; + inline explicit QSignalBlocker(QObject &o) noexcept; inline ~QSignalBlocker(); #ifdef Q_COMPILER_RVALUE_REFS - inline QSignalBlocker(QSignalBlocker &&other) Q_DECL_NOTHROW; - inline QSignalBlocker &operator=(QSignalBlocker &&other) Q_DECL_NOTHROW; + inline QSignalBlocker(QSignalBlocker &&other) noexcept; + inline QSignalBlocker &operator=(QSignalBlocker &&other) noexcept; #endif - inline void reblock() Q_DECL_NOTHROW; - inline void unblock() Q_DECL_NOTHROW; + inline void reblock() noexcept; + inline void unblock() noexcept; private: Q_DISABLE_COPY(QSignalBlocker) QObject * m_o; @@ -558,20 +558,20 @@ private: bool m_inhibited; }; -QSignalBlocker::QSignalBlocker(QObject *o) Q_DECL_NOTHROW +QSignalBlocker::QSignalBlocker(QObject *o) noexcept : m_o(o), m_blocked(o && o->blockSignals(true)), m_inhibited(false) {} -QSignalBlocker::QSignalBlocker(QObject &o) Q_DECL_NOTHROW +QSignalBlocker::QSignalBlocker(QObject &o) noexcept : m_o(&o), m_blocked(o.blockSignals(true)), m_inhibited(false) {} #ifdef Q_COMPILER_RVALUE_REFS -QSignalBlocker::QSignalBlocker(QSignalBlocker &&other) Q_DECL_NOTHROW +QSignalBlocker::QSignalBlocker(QSignalBlocker &&other) noexcept : m_o(other.m_o), m_blocked(other.m_blocked), m_inhibited(other.m_inhibited) @@ -579,7 +579,7 @@ QSignalBlocker::QSignalBlocker(QSignalBlocker &&other) Q_DECL_NOTHROW other.m_o = nullptr; } -QSignalBlocker &QSignalBlocker::operator=(QSignalBlocker &&other) Q_DECL_NOTHROW +QSignalBlocker &QSignalBlocker::operator=(QSignalBlocker &&other) noexcept { if (this != &other) { // if both *this and other block the same object's signals: @@ -602,13 +602,13 @@ QSignalBlocker::~QSignalBlocker() m_o->blockSignals(m_blocked); } -void QSignalBlocker::reblock() Q_DECL_NOTHROW +void QSignalBlocker::reblock() noexcept { if (m_o) m_o->blockSignals(true); m_inhibited = false; } -void QSignalBlocker::unblock() Q_DECL_NOTHROW +void QSignalBlocker::unblock() noexcept { if (m_o) m_o->blockSignals(m_blocked); m_inhibited = true; diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h index d7ed2b0282..a437a994fd 100644 --- a/src/corelib/kernel/qobjectdefs.h +++ b/src/corelib/kernel/qobjectdefs.h @@ -119,13 +119,13 @@ class QString; #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) Q_DECL_NOEXCEPT { return &staticMetaObject; } \ - friend Q_DECL_CONSTEXPR const char *qt_getEnumName(ENUM) Q_DECL_NOEXCEPT { return #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; } #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) Q_DECL_NOEXCEPT { return &staticMetaObject; } \ - inline Q_DECL_CONSTEXPR const char *qt_getEnumName(ENUM) Q_DECL_NOEXCEPT { return #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; } #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) @@ -340,7 +340,7 @@ struct Q_CORE_EXPORT QMetaObject const char *className() const; const QMetaObject *superClass() const; - bool inherits(const QMetaObject *metaObject) const Q_DECL_NOEXCEPT; + bool inherits(const QMetaObject *metaObject) const noexcept; QObject *cast(QObject *obj) const; const QObject *cast(const QObject *obj) const; @@ -605,8 +605,8 @@ public: operator RestrictedBool() const { return d_ptr && isConnected_helper() ? &Connection::d_ptr : nullptr; } #endif - Connection(Connection &&o) Q_DECL_NOTHROW : d_ptr(o.d_ptr) { o.d_ptr = nullptr; } - Connection &operator=(Connection &&other) Q_DECL_NOTHROW + Connection(Connection &&o) noexcept : d_ptr(o.d_ptr) { o.d_ptr = nullptr; } + Connection &operator=(Connection &&other) noexcept { qSwap(d_ptr, other.d_ptr); return *this; } }; diff --git a/src/corelib/kernel/qobjectdefs_impl.h b/src/corelib/kernel/qobjectdefs_impl.h index aa6bd84e95..31ecc8b20d 100644 --- a/src/corelib/kernel/qobjectdefs_impl.h +++ b/src/corelib/kernel/qobjectdefs_impl.h @@ -386,8 +386,8 @@ namespace QtPrivate { public: explicit QSlotObjectBase(ImplFn fn) : m_ref(1), m_impl(fn) {} - inline int ref() Q_DECL_NOTHROW { return m_ref.ref(); } - inline void destroyIfLastRef() Q_DECL_NOTHROW + inline int ref() noexcept { return m_ref.ref(); } + inline void destroyIfLastRef() noexcept { if (!m_ref.deref()) m_impl(Destroy, this, nullptr, nullptr, nullptr); } inline bool compare(void **a) { bool ret = false; m_impl(Compare, this, nullptr, a, &ret); return ret; } diff --git a/src/corelib/kernel/qtimer.h b/src/corelib/kernel/qtimer.h index 66f317c567..ae5552f1c9 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) Q_DECL_NOTHROW + static Q_DECL_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/qvariant.h b/src/corelib/kernel/qvariant.h index 90f5f5fc34..6b35bfa9e9 100644 --- a/src/corelib/kernel/qvariant.h +++ b/src/corelib/kernel/qvariant.h @@ -201,7 +201,7 @@ class Q_CORE_EXPORT QVariant LastType = 0xffffffff // need this so that gcc >= 3.4 allocates 32 bits for Type }; - QVariant() Q_DECL_NOTHROW : d() {} + QVariant() noexcept : d() {} ~QVariant(); QVariant(Type type); QVariant(int typeId, const void *copy); @@ -268,13 +268,13 @@ class Q_CORE_EXPORT QVariant QVariant& operator=(const QVariant &other); #ifdef Q_COMPILER_RVALUE_REFS - inline QVariant(QVariant &&other) Q_DECL_NOTHROW : d(other.d) + inline QVariant(QVariant &&other) noexcept : d(other.d) { other.d = Private(); } - inline QVariant &operator=(QVariant &&other) Q_DECL_NOTHROW + inline QVariant &operator=(QVariant &&other) noexcept { qSwap(d, other.d); return *this; } #endif - inline void swap(QVariant &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + inline void swap(QVariant &other) noexcept { qSwap(d, other.d); } Type type() const; int userType() const; @@ -387,15 +387,15 @@ class Q_CORE_EXPORT QVariant }; struct Private { - inline Private() Q_DECL_NOTHROW : type(Invalid), is_shared(false), is_null(true) + inline Private() noexcept : type(Invalid), is_shared(false), is_null(true) { data.ptr = nullptr; } // Internal constructor for initialized variants. - explicit inline Private(uint variantType) Q_DECL_NOTHROW + explicit inline Private(uint variantType) noexcept : type(variantType), is_shared(false), is_null(false) {} - inline Private(const Private &other) Q_DECL_NOTHROW + inline Private(const Private &other) noexcept : data(other.data), type(other.type), is_shared(other.is_shared), is_null(other.is_null) {} diff --git a/src/corelib/mimetypes/qmimeglobpattern_p.h b/src/corelib/mimetypes/qmimeglobpattern_p.h index bb6f64320b..cf27d6ab30 100644 --- a/src/corelib/mimetypes/qmimeglobpattern_p.h +++ b/src/corelib/mimetypes/qmimeglobpattern_p.h @@ -88,7 +88,7 @@ public: { } - void swap(QMimeGlobPattern &other) Q_DECL_NOTHROW + void swap(QMimeGlobPattern &other) noexcept { qSwap(m_pattern, other.m_pattern); qSwap(m_mimeType, other.m_mimeType); diff --git a/src/corelib/mimetypes/qmimemagicrule_p.h b/src/corelib/mimetypes/qmimemagicrule_p.h index 6962a6ca59..5091d483b6 100644 --- a/src/corelib/mimetypes/qmimemagicrule_p.h +++ b/src/corelib/mimetypes/qmimemagicrule_p.h @@ -69,7 +69,7 @@ public: QMimeMagicRule(const QString &typeStr, const QByteArray &value, const QString &offsets, const QByteArray &mask, QString *errorString); - void swap(QMimeMagicRule &other) Q_DECL_NOTHROW + void swap(QMimeMagicRule &other) noexcept { qSwap(m_type, other.m_type); qSwap(m_value, other.m_value); diff --git a/src/corelib/mimetypes/qmimemagicrulematcher_p.h b/src/corelib/mimetypes/qmimemagicrulematcher_p.h index 5e74e2e3fc..fe714987e6 100644 --- a/src/corelib/mimetypes/qmimemagicrulematcher_p.h +++ b/src/corelib/mimetypes/qmimemagicrulematcher_p.h @@ -66,7 +66,7 @@ class QMimeMagicRuleMatcher public: explicit QMimeMagicRuleMatcher(const QString &mime, unsigned priority = 65535); - void swap(QMimeMagicRuleMatcher &other) Q_DECL_NOTHROW + void swap(QMimeMagicRuleMatcher &other) noexcept { qSwap(m_list, other.m_list); qSwap(m_priority, other.m_priority); diff --git a/src/corelib/mimetypes/qmimetype.cpp b/src/corelib/mimetypes/qmimetype.cpp index 55c7de0c87..cf01c9503b 100644 --- a/src/corelib/mimetypes/qmimetype.cpp +++ b/src/corelib/mimetypes/qmimetype.cpp @@ -192,7 +192,7 @@ bool QMimeType::operator==(const QMimeType &other) const Returns the hash value for \a key, using \a seed to seed the calculation. */ -uint qHash(const QMimeType &key, uint seed) Q_DECL_NOTHROW +uint qHash(const QMimeType &key, uint seed) noexcept { return qHash(key.d->name, seed); } diff --git a/src/corelib/mimetypes/qmimetype.h b/src/corelib/mimetypes/qmimetype.h index 8287f1434b..c496af7d58 100644 --- a/src/corelib/mimetypes/qmimetype.h +++ b/src/corelib/mimetypes/qmimetype.h @@ -55,7 +55,7 @@ class QMimeTypePrivate; class QStringList; class QMimeType; -Q_CORE_EXPORT uint qHash(const QMimeType &key, uint seed = 0) Q_DECL_NOTHROW; +Q_CORE_EXPORT uint qHash(const QMimeType &key, uint seed = 0) noexcept; class Q_CORE_EXPORT QMimeType { @@ -79,9 +79,9 @@ public: QMimeType(const QMimeType &other); QMimeType &operator=(const QMimeType &other); #ifdef Q_COMPILER_RVALUE_REFS - QMimeType &operator=(QMimeType &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QMimeType &operator=(QMimeType &&other) noexcept { swap(other); return *this; } #endif - void swap(QMimeType &other) Q_DECL_NOTHROW + void swap(QMimeType &other) noexcept { qSwap(d, other.d); } @@ -121,7 +121,7 @@ protected: friend class QMimeXMLProvider; friend class QMimeBinaryProvider; friend class QMimeTypePrivate; - friend Q_CORE_EXPORT uint qHash(const QMimeType &key, uint seed) Q_DECL_NOTHROW; + friend Q_CORE_EXPORT uint qHash(const QMimeType &key, uint seed) noexcept; QExplicitlySharedDataPointer d; }; diff --git a/src/corelib/plugin/quuid.cpp b/src/corelib/plugin/quuid.cpp index 8bb5e1463a..83873edf6f 100644 --- a/src/corelib/plugin/quuid.cpp +++ b/src/corelib/plugin/quuid.cpp @@ -397,7 +397,7 @@ QUuid::QUuid(const QString &text) \sa toString(), QUuid() */ -QUuid QUuid::fromString(QStringView text) Q_DECL_NOTHROW +QUuid QUuid::fromString(QStringView text) noexcept { if (text.size() > MaxStringUuidLength) text = text.left(MaxStringUuidLength); // text.truncate(MaxStringUuidLength); @@ -427,7 +427,7 @@ QUuid QUuid::fromString(QStringView text) Q_DECL_NOTHROW \sa toString(), QUuid() */ -QUuid QUuid::fromString(QLatin1String text) Q_DECL_NOTHROW +QUuid QUuid::fromString(QLatin1String text) noexcept { if (Q_UNLIKELY(text.size() < MaxStringUuidLength - 2 || (text.front() == QLatin1Char('{') && text.size() < MaxStringUuidLength - 1))) { @@ -864,7 +864,7 @@ QDataStream &operator>>(QDataStream &s, QUuid &id) Returns \c true if this is the null UUID {00000000-0000-0000-0000-000000000000}; otherwise returns \c false. */ -bool QUuid::isNull() const Q_DECL_NOTHROW +bool QUuid::isNull() const noexcept { return data4[0] == 0 && data4[1] == 0 && data4[2] == 0 && data4[3] == 0 && data4[4] == 0 && data4[5] == 0 && data4[6] == 0 && data4[7] == 0 && @@ -913,7 +913,7 @@ bool QUuid::isNull() const Q_DECL_NOTHROW \sa version() */ -QUuid::Variant QUuid::variant() const Q_DECL_NOTHROW +QUuid::Variant QUuid::variant() const noexcept { if (isNull()) return VarUnknown; @@ -934,7 +934,7 @@ QUuid::Variant QUuid::variant() const Q_DECL_NOTHROW \sa variant() */ -QUuid::Version QUuid::version() const Q_DECL_NOTHROW +QUuid::Version QUuid::version() const noexcept { // Check the 4 MSB of data3 Version ver = (Version)(data3>>12); @@ -957,7 +957,7 @@ QUuid::Version QUuid::version() const Q_DECL_NOTHROW \sa variant() */ -bool QUuid::operator<(const QUuid &other) const Q_DECL_NOTHROW +bool QUuid::operator<(const QUuid &other) const noexcept { if (variant() != other.variant()) return variant() < other.variant(); @@ -984,7 +984,7 @@ bool QUuid::operator<(const QUuid &other) const Q_DECL_NOTHROW \sa variant() */ -bool QUuid::operator>(const QUuid &other) const Q_DECL_NOTHROW +bool QUuid::operator>(const QUuid &other) const noexcept { return other < *this; } @@ -1089,7 +1089,7 @@ QDebug operator<<(QDebug dbg, const QUuid &id) \relates QUuid Returns a hash of the UUID \a uuid, using \a seed to seed the calculation. */ -uint qHash(const QUuid &uuid, uint seed) Q_DECL_NOTHROW +uint qHash(const QUuid &uuid, uint seed) noexcept { return uuid.data1 ^ uuid.data2 ^ (uuid.data3 << 16) ^ ((uuid.data4[0] << 24) | (uuid.data4[1] << 16) | (uuid.data4[2] << 8) | uuid.data4[3]) diff --git a/src/corelib/plugin/quuid.h b/src/corelib/plugin/quuid.h index 08a1843640..713ca070c8 100644 --- a/src/corelib/plugin/quuid.h +++ b/src/corelib/plugin/quuid.h @@ -93,13 +93,13 @@ public: #if defined(Q_COMPILER_UNIFORM_INIT) && !defined(Q_CLANG_QDOC) - Q_DECL_CONSTEXPR QUuid() Q_DECL_NOTHROW : data1(0), data2(0), data3(0), data4{0,0,0,0,0,0,0,0} {} + Q_DECL_CONSTEXPR QUuid() noexcept : data1(0), data2(0), data3(0), data4{0,0,0,0,0,0,0,0} {} Q_DECL_CONSTEXPR QUuid(uint l, ushort w1, ushort w2, uchar b1, uchar b2, uchar b3, - uchar b4, uchar b5, uchar b6, uchar b7, uchar b8) Q_DECL_NOTHROW + uchar b4, uchar b5, uchar b6, uchar b7, uchar b8) noexcept : data1(l), data2(w1), data3(w2), data4{b1, b2, b3, b4, b5, b6, b7, b8} {} #else - QUuid() Q_DECL_NOTHROW + QUuid() noexcept { data1 = 0; data2 = 0; @@ -107,7 +107,7 @@ public: for(int i = 0; i < 8; i++) data4[i] = 0; } - QUuid(uint l, ushort w1, ushort w2, uchar b1, uchar b2, uchar b3, uchar b4, uchar b5, uchar b6, uchar b7, uchar b8) Q_DECL_NOTHROW + QUuid(uint l, ushort w1, ushort w2, uchar b1, uchar b2, uchar b3, uchar b4, uchar b5, uchar b6, uchar b7, uchar b8) noexcept { data1 = l; data2 = w1; @@ -124,8 +124,8 @@ public: #endif QUuid(const QString &); - static QUuid fromString(QStringView string) Q_DECL_NOTHROW; - static QUuid fromString(QLatin1String string) Q_DECL_NOTHROW; + static QUuid fromString(QStringView string) noexcept; + static QUuid fromString(QLatin1String string) noexcept; QUuid(const char *); QString toString() const; QString toString(StringFormat mode) const; // ### Qt6: merge with previous @@ -134,9 +134,9 @@ public: QByteArray toByteArray(StringFormat mode) const; // ### Qt6: merge with previous QByteArray toRfc4122() const; static QUuid fromRfc4122(const QByteArray &); - bool isNull() const Q_DECL_NOTHROW; + bool isNull() const noexcept; - Q_DECL_RELAXED_CONSTEXPR bool operator==(const QUuid &orig) const Q_DECL_NOTHROW + Q_DECL_RELAXED_CONSTEXPR bool operator==(const QUuid &orig) const noexcept { if (data1 != orig.data1 || data2 != orig.data2 || data3 != orig.data3) @@ -149,24 +149,24 @@ public: return true; } - Q_DECL_RELAXED_CONSTEXPR bool operator!=(const QUuid &orig) const Q_DECL_NOTHROW + Q_DECL_RELAXED_CONSTEXPR bool operator!=(const QUuid &orig) const noexcept { return !(*this == orig); } - bool operator<(const QUuid &other) const Q_DECL_NOTHROW; - bool operator>(const QUuid &other) const Q_DECL_NOTHROW; + bool operator<(const QUuid &other) const noexcept; + bool operator>(const QUuid &other) const noexcept; #if defined(Q_OS_WIN) || defined(Q_CLANG_QDOC) // On Windows we have a type GUID that is used by the platform API, so we // provide convenience operators to cast from and to this type. #if defined(Q_COMPILER_UNIFORM_INIT) && !defined(Q_CLANG_QDOC) - Q_DECL_CONSTEXPR QUuid(const GUID &guid) Q_DECL_NOTHROW + Q_DECL_CONSTEXPR QUuid(const GUID &guid) noexcept : data1(guid.Data1), data2(guid.Data2), data3(guid.Data3), data4{guid.Data4[0], guid.Data4[1], guid.Data4[2], guid.Data4[3], guid.Data4[4], guid.Data4[5], guid.Data4[6], guid.Data4[7]} {} #else - QUuid(const GUID &guid) Q_DECL_NOTHROW + QUuid(const GUID &guid) noexcept { data1 = guid.Data1; data2 = guid.Data2; @@ -176,24 +176,24 @@ public: } #endif - Q_DECL_RELAXED_CONSTEXPR QUuid &operator=(const GUID &guid) Q_DECL_NOTHROW + Q_DECL_RELAXED_CONSTEXPR QUuid &operator=(const GUID &guid) noexcept { *this = QUuid(guid); return *this; } - Q_DECL_RELAXED_CONSTEXPR operator GUID() const Q_DECL_NOTHROW + Q_DECL_RELAXED_CONSTEXPR operator GUID() const noexcept { GUID guid = { data1, data2, data3, { data4[0], data4[1], data4[2], data4[3], data4[4], data4[5], data4[6], data4[7] } }; return guid; } - Q_DECL_RELAXED_CONSTEXPR bool operator==(const GUID &guid) const Q_DECL_NOTHROW + Q_DECL_RELAXED_CONSTEXPR bool operator==(const GUID &guid) const noexcept { return *this == QUuid(guid); } - Q_DECL_RELAXED_CONSTEXPR bool operator!=(const GUID &guid) const Q_DECL_NOTHROW + Q_DECL_RELAXED_CONSTEXPR bool operator!=(const GUID &guid) const noexcept { return !(*this == guid); } @@ -216,8 +216,8 @@ public: } - QUuid::Variant variant() const Q_DECL_NOTHROW; - QUuid::Version version() const Q_DECL_NOTHROW; + QUuid::Variant variant() const noexcept; + QUuid::Version version() const noexcept; #if defined(Q_OS_DARWIN) || defined(Q_CLANG_QDOC) static QUuid fromCFUUID(CFUUIDRef uuid); @@ -243,11 +243,11 @@ Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QUuid &); Q_CORE_EXPORT QDebug operator<<(QDebug, const QUuid &); #endif -Q_CORE_EXPORT uint qHash(const QUuid &uuid, uint seed = 0) Q_DECL_NOTHROW; +Q_CORE_EXPORT uint qHash(const QUuid &uuid, uint seed = 0) noexcept; -inline bool operator<=(const QUuid &lhs, const QUuid &rhs) Q_DECL_NOTHROW +inline bool operator<=(const QUuid &lhs, const QUuid &rhs) noexcept { return !(rhs < lhs); } -inline bool operator>=(const QUuid &lhs, const QUuid &rhs) Q_DECL_NOTHROW +inline bool operator>=(const QUuid &lhs, const QUuid &rhs) noexcept { return !(lhs < rhs); } QT_END_NAMESPACE diff --git a/src/corelib/serialization/qjson_p.h b/src/corelib/serialization/qjson_p.h index a9e7059cbe..85fb2a1254 100644 --- a/src/corelib/serialization/qjson_p.h +++ b/src/corelib/serialization/qjson_p.h @@ -304,7 +304,7 @@ public: return *this; } - QLatin1String toQLatin1String() const Q_DECL_NOTHROW { + QLatin1String toQLatin1String() const noexcept { return QLatin1String(d->latin1, d->length); } @@ -339,23 +339,23 @@ public: }; #define DEF_OP(op) \ - inline bool operator op(Latin1String lhs, Latin1String rhs) Q_DECL_NOTHROW \ + inline bool operator op(Latin1String lhs, Latin1String rhs) noexcept \ { \ return lhs.toQLatin1String() op rhs.toQLatin1String(); \ } \ - inline bool operator op(QLatin1String lhs, Latin1String rhs) Q_DECL_NOTHROW \ + inline bool operator op(QLatin1String lhs, Latin1String rhs) noexcept \ { \ return lhs op rhs.toQLatin1String(); \ } \ - inline bool operator op(Latin1String lhs, QLatin1String rhs) Q_DECL_NOTHROW \ + inline bool operator op(Latin1String lhs, QLatin1String rhs) noexcept \ { \ return lhs.toQLatin1String() op rhs; \ } \ - inline bool operator op(const QString &lhs, Latin1String rhs) Q_DECL_NOTHROW \ + inline bool operator op(const QString &lhs, Latin1String rhs) noexcept \ { \ return lhs op rhs.toQLatin1String(); \ } \ - inline bool operator op(Latin1String lhs, const QString &rhs) Q_DECL_NOTHROW \ + inline bool operator op(Latin1String lhs, const QString &rhs) noexcept \ { \ return lhs.toQLatin1String() op rhs; \ } \ diff --git a/src/corelib/serialization/qjsonarray.h b/src/corelib/serialization/qjsonarray.h index ba346fb848..86b7bf9d76 100644 --- a/src/corelib/serialization/qjsonarray.h +++ b/src/corelib/serialization/qjsonarray.h @@ -72,7 +72,7 @@ public: QJsonArray(const QJsonArray &other); QJsonArray &operator =(const QJsonArray &other); - QJsonArray(QJsonArray &&other) Q_DECL_NOTHROW + QJsonArray(QJsonArray &&other) noexcept : d(other.d), a(other.a) { @@ -80,7 +80,7 @@ public: other.a = nullptr; } - QJsonArray &operator =(QJsonArray &&other) Q_DECL_NOTHROW + QJsonArray &operator =(QJsonArray &&other) noexcept { swap(other); return *this; @@ -115,7 +115,7 @@ public: bool operator==(const QJsonArray &other) const; bool operator!=(const QJsonArray &other) const; - void swap(QJsonArray &other) Q_DECL_NOTHROW + void swap(QJsonArray &other) noexcept { qSwap(d, other.d); qSwap(a, other.a); diff --git a/src/corelib/serialization/qjsondocument.h b/src/corelib/serialization/qjsondocument.h index a749439b7d..a8006a6cc5 100644 --- a/src/corelib/serialization/qjsondocument.h +++ b/src/corelib/serialization/qjsondocument.h @@ -93,19 +93,19 @@ public: QJsonDocument(const QJsonDocument &other); QJsonDocument &operator =(const QJsonDocument &other); - QJsonDocument(QJsonDocument &&other) Q_DECL_NOTHROW + QJsonDocument(QJsonDocument &&other) noexcept : d(other.d) { other.d = nullptr; } - QJsonDocument &operator =(QJsonDocument &&other) Q_DECL_NOTHROW + QJsonDocument &operator =(QJsonDocument &&other) noexcept { swap(other); return *this; } - void swap(QJsonDocument &other) Q_DECL_NOTHROW + void swap(QJsonDocument &other) noexcept { qSwap(d, other.d); } diff --git a/src/corelib/serialization/qjsonobject.h b/src/corelib/serialization/qjsonobject.h index 80fe6b2f3f..92d45cc838 100644 --- a/src/corelib/serialization/qjsonobject.h +++ b/src/corelib/serialization/qjsonobject.h @@ -74,20 +74,20 @@ public: QJsonObject(const QJsonObject &other); QJsonObject &operator =(const QJsonObject &other); - QJsonObject(QJsonObject &&other) Q_DECL_NOTHROW + QJsonObject(QJsonObject &&other) noexcept : d(other.d), o(other.o) { other.d = nullptr; other.o = nullptr; } - QJsonObject &operator =(QJsonObject &&other) Q_DECL_NOTHROW + QJsonObject &operator =(QJsonObject &&other) noexcept { swap(other); return *this; } - void swap(QJsonObject &other) Q_DECL_NOTHROW + void swap(QJsonObject &other) noexcept { qSwap(d, other.d); qSwap(o, other.o); diff --git a/src/corelib/serialization/qjsonvalue.h b/src/corelib/serialization/qjsonvalue.h index 0339eb59f7..37d84f9e60 100644 --- a/src/corelib/serialization/qjsonvalue.h +++ b/src/corelib/serialization/qjsonvalue.h @@ -92,7 +92,7 @@ public: QJsonValue(const QJsonValue &other); QJsonValue &operator =(const QJsonValue &other); - QJsonValue(QJsonValue &&other) Q_DECL_NOTHROW + QJsonValue(QJsonValue &&other) noexcept : ui(other.ui), d(other.d), t(other.t) @@ -102,13 +102,13 @@ public: other.t = Null; } - QJsonValue &operator =(QJsonValue &&other) Q_DECL_NOTHROW + QJsonValue &operator =(QJsonValue &&other) noexcept { swap(other); return *this; } - void swap(QJsonValue &other) Q_DECL_NOTHROW + void swap(QJsonValue &other) noexcept { qSwap(ui, other.ui); qSwap(d, other.d); diff --git a/src/corelib/serialization/qtextstream.h b/src/corelib/serialization/qtextstream.h index 7673e5d87e..4efa84f1f1 100644 --- a/src/corelib/serialization/qtextstream.h +++ b/src/corelib/serialization/qtextstream.h @@ -213,8 +213,8 @@ typedef void (QTextStream::*QTSMFC)(QChar); // manipulator w/QChar argument class Q_CORE_EXPORT QTextStreamManipulator { public: - Q_DECL_CONSTEXPR QTextStreamManipulator(QTSMFI m, int a) Q_DECL_NOTHROW : mf(m), mc(nullptr), arg(a), ch() {} - Q_DECL_CONSTEXPR QTextStreamManipulator(QTSMFC m, QChar c) Q_DECL_NOTHROW : mf(nullptr), mc(m), arg(-1), ch(c) {} + Q_DECL_CONSTEXPR QTextStreamManipulator(QTSMFI m, int a) noexcept : mf(m), mc(nullptr), arg(a), ch() {} + Q_DECL_CONSTEXPR QTextStreamManipulator(QTSMFC m, QChar c) noexcept : mf(nullptr), mc(m), arg(-1), ch(c) {} void exec(QTextStream &s) { if (mf) { (s.*mf)(arg); } else { (s.*mc)(ch); } } private: diff --git a/src/corelib/serialization/qxmlstream.h b/src/corelib/serialization/qxmlstream.h index d30c6bc01f..fedd149fd0 100644 --- a/src/corelib/serialization/qxmlstream.h +++ b/src/corelib/serialization/qxmlstream.h @@ -60,16 +60,16 @@ public: :m_string(aString.string()?*aString.string():QString()), m_position(aString.position()), m_size(aString.size()){} QXmlStreamStringRef(const QString &aString) : m_string(aString), m_position(0), m_size(m_string.size()) {} #ifdef Q_COMPILER_RVALUE_REFS - QXmlStreamStringRef(QString &&aString) Q_DECL_NOTHROW : m_string(std::move(aString)), m_position(0), m_size(m_string.size()) {} + QXmlStreamStringRef(QString &&aString) noexcept : m_string(std::move(aString)), m_position(0), m_size(m_string.size()) {} #endif #if QT_VERSION < QT_VERSION_CHECK(6,0,0) QXmlStreamStringRef(const QXmlStreamStringRef &other) // = default : m_string(other.m_string), m_position(other.m_position), m_size(other.m_size) {} #ifdef Q_COMPILER_RVALUE_REFS - QXmlStreamStringRef(QXmlStreamStringRef &&other) Q_DECL_NOTHROW // = default + QXmlStreamStringRef(QXmlStreamStringRef &&other) noexcept // = default : m_string(std::move(other.m_string)), m_position(other.m_position), m_size(other.m_size) {} - QXmlStreamStringRef &operator=(QXmlStreamStringRef &&other) Q_DECL_NOTHROW // = default + QXmlStreamStringRef &operator=(QXmlStreamStringRef &&other) noexcept // = default { swap(other); return *this; } #endif QXmlStreamStringRef &operator=(const QXmlStreamStringRef &other) // = default @@ -79,7 +79,7 @@ public: // ### Qt 5, since that would change the way its passed to functions. In Qt 6, remove all. #endif // Qt < 6.0 - void swap(QXmlStreamStringRef &other) Q_DECL_NOTHROW + void swap(QXmlStreamStringRef &other) noexcept { qSwap(m_string, other.m_string); qSwap(m_position, other.m_position); @@ -112,7 +112,7 @@ public: QXmlStreamAttribute(const QString &namespaceUri, const QString &name, const QString &value); QXmlStreamAttribute(const QXmlStreamAttribute &); #ifdef Q_COMPILER_RVALUE_REFS - QXmlStreamAttribute(QXmlStreamAttribute &&other) Q_DECL_NOTHROW // = default; + QXmlStreamAttribute(QXmlStreamAttribute &&other) noexcept // = default; : m_name(std::move(other.m_name)), m_namespaceUri(std::move(other.m_namespaceUri)), m_qualifiedName(std::move(other.m_qualifiedName)), @@ -122,7 +122,7 @@ public: { other.reserved = nullptr; } - QXmlStreamAttribute &operator=(QXmlStreamAttribute &&other) Q_DECL_NOTHROW // = default; + QXmlStreamAttribute &operator=(QXmlStreamAttribute &&other) noexcept // = default; { m_name = std::move(other.m_name); m_namespaceUri = std::move(other.m_namespaceUri); @@ -199,14 +199,14 @@ public: QXmlStreamNamespaceDeclaration(); #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QXmlStreamNamespaceDeclaration(const QXmlStreamNamespaceDeclaration &); - QXmlStreamNamespaceDeclaration(QXmlStreamNamespaceDeclaration &&other) Q_DECL_NOTHROW // = default + QXmlStreamNamespaceDeclaration(QXmlStreamNamespaceDeclaration &&other) noexcept // = default : m_prefix(std::move(other.m_prefix)), m_namespaceUri(std::move(other.m_namespaceUri)), reserved(other.reserved) { other.reserved = nullptr; } - QXmlStreamNamespaceDeclaration &operator=(QXmlStreamNamespaceDeclaration &&other) Q_DECL_NOTHROW // = default + QXmlStreamNamespaceDeclaration &operator=(QXmlStreamNamespaceDeclaration &&other) noexcept // = default { m_prefix = std::move(other.m_prefix); m_namespaceUri = std::move(other.m_namespaceUri); @@ -242,7 +242,7 @@ public: #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) ~QXmlStreamNotationDeclaration(); QXmlStreamNotationDeclaration(const QXmlStreamNotationDeclaration &); - QXmlStreamNotationDeclaration(QXmlStreamNotationDeclaration &&other) Q_DECL_NOTHROW // = default + QXmlStreamNotationDeclaration(QXmlStreamNotationDeclaration &&other) noexcept // = default : m_name(std::move(other.m_name)), m_systemId(std::move(other.m_systemId)), m_publicId(std::move(other.m_publicId)), @@ -251,7 +251,7 @@ public: other.reserved = nullptr; } QXmlStreamNotationDeclaration& operator=(const QXmlStreamNotationDeclaration &); - QXmlStreamNotationDeclaration &operator=(QXmlStreamNotationDeclaration &&other) Q_DECL_NOTHROW // = default + QXmlStreamNotationDeclaration &operator=(QXmlStreamNotationDeclaration &&other) noexcept // = default { m_name = std::move(other.m_name); m_systemId = std::move(other.m_systemId); @@ -287,7 +287,7 @@ public: #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) ~QXmlStreamEntityDeclaration(); QXmlStreamEntityDeclaration(const QXmlStreamEntityDeclaration &); - QXmlStreamEntityDeclaration(QXmlStreamEntityDeclaration &&other) Q_DECL_NOTHROW // = default + QXmlStreamEntityDeclaration(QXmlStreamEntityDeclaration &&other) noexcept // = default : m_name(std::move(other.m_name)), m_notationName(std::move(other.m_notationName)), m_systemId(std::move(other.m_systemId)), @@ -298,7 +298,7 @@ public: other.reserved = nullptr; } QXmlStreamEntityDeclaration& operator=(const QXmlStreamEntityDeclaration &); - QXmlStreamEntityDeclaration &operator=(QXmlStreamEntityDeclaration &&other) Q_DECL_NOTHROW // = default + QXmlStreamEntityDeclaration &operator=(QXmlStreamEntityDeclaration &&other) noexcept // = default { m_name = std::move(other.m_name); m_notationName = std::move(other.m_notationName); diff --git a/src/corelib/statemachine/qstatemachine_p.h b/src/corelib/statemachine/qstatemachine_p.h index c66130b8ce..3d12477c87 100644 --- a/src/corelib/statemachine/qstatemachine_p.h +++ b/src/corelib/statemachine/qstatemachine_p.h @@ -222,14 +222,14 @@ public: { return qHash(qMakePair(key.obj, key.prop), seed); } friend uint qHash(const RestorableId &key) Q_DECL_NOEXCEPT_EXPR(noexcept(qHash(key, 0U))) { return qHash(key, 0U); } - friend bool operator==(const RestorableId &lhs, const RestorableId &rhs) Q_DECL_NOTHROW + friend bool operator==(const RestorableId &lhs, const RestorableId &rhs) noexcept { return lhs.obj == rhs.obj && lhs.prop == rhs.prop; } - friend bool operator!=(const RestorableId &lhs, const RestorableId &rhs) Q_DECL_NOTHROW + friend bool operator!=(const RestorableId &lhs, const RestorableId &rhs) noexcept { return !operator==(lhs, rhs); } public: - explicit RestorableId(QObject *o, QByteArray p) Q_DECL_NOTHROW : guard(o), obj(o), prop(qMove(p)) {} - QObject *object() const Q_DECL_NOTHROW { return guard; } - QByteArray propertyName() const Q_DECL_NOTHROW { return prop; } + explicit RestorableId(QObject *o, QByteArray p) noexcept : guard(o), obj(o), prop(qMove(p)) {} + QObject *object() const noexcept { return guard; } + QByteArray propertyName() const noexcept { return prop; } }; QHash > registeredRestorablesForState; bool hasRestorable(QAbstractState *state, QObject *object, const QByteArray &propertyName) const; @@ -271,7 +271,7 @@ public: QList handledAnimations; QList localResetEndValues; - void swap(InitializeAnimationResult &other) Q_DECL_NOTHROW + void swap(InitializeAnimationResult &other) noexcept { qSwap(handledAnimations, other.handledAnimations); qSwap(localResetEndValues, other.localResetEndValues); diff --git a/src/corelib/thread/qatomic.h b/src/corelib/thread/qatomic.h index f842534c38..280ce96b76 100644 --- a/src/corelib/thread/qatomic.h +++ b/src/corelib/thread/qatomic.h @@ -57,15 +57,15 @@ class QAtomicInteger : public QBasicAtomicInteger public: // Non-atomic API #ifdef QT_BASIC_ATOMIC_HAS_CONSTRUCTORS - constexpr QAtomicInteger(T value = 0) Q_DECL_NOTHROW : QBasicAtomicInteger(value) {} + constexpr QAtomicInteger(T value = 0) noexcept : QBasicAtomicInteger(value) {} #else - inline QAtomicInteger(T value = 0) Q_DECL_NOTHROW + inline QAtomicInteger(T value = 0) noexcept { this->_q_value = value; } #endif - inline QAtomicInteger(const QAtomicInteger &other) Q_DECL_NOTHROW + inline QAtomicInteger(const QAtomicInteger &other) noexcept #ifdef QT_BASIC_ATOMIC_HAS_CONSTRUCTORS : QBasicAtomicInteger() #endif @@ -73,7 +73,7 @@ public: this->storeRelease(other.loadAcquire()); } - inline QAtomicInteger &operator=(const QAtomicInteger &other) Q_DECL_NOTHROW + inline QAtomicInteger &operator=(const QAtomicInteger &other) noexcept { this->storeRelease(other.loadAcquire()); return *this; @@ -159,7 +159,7 @@ public: #ifdef QT_BASIC_ATOMIC_HAS_CONSTRUCTORS constexpr #endif - QAtomicInt(int value = 0) Q_DECL_NOTHROW : QAtomicInteger(value) {} + QAtomicInt(int value = 0) noexcept : QAtomicInteger(value) {} }; // High-level atomic pointer operations @@ -168,14 +168,14 @@ class QAtomicPointer : public QBasicAtomicPointer { public: #ifdef QT_BASIC_ATOMIC_HAS_CONSTRUCTORS - constexpr QAtomicPointer(T *value = nullptr) Q_DECL_NOTHROW : QBasicAtomicPointer(value) {} + constexpr QAtomicPointer(T *value = nullptr) noexcept : QBasicAtomicPointer(value) {} #else - inline QAtomicPointer(T *value = nullptr) Q_DECL_NOTHROW + inline QAtomicPointer(T *value = nullptr) noexcept { this->store(value); } #endif - inline QAtomicPointer(const QAtomicPointer &other) Q_DECL_NOTHROW + inline QAtomicPointer(const QAtomicPointer &other) noexcept #ifdef QT_BASIC_ATOMIC_HAS_CONSTRUCTORS : QBasicAtomicPointer() #endif @@ -183,7 +183,7 @@ public: this->storeRelease(other.loadAcquire()); } - inline QAtomicPointer &operator=(const QAtomicPointer &other) Q_DECL_NOTHROW + inline QAtomicPointer &operator=(const QAtomicPointer &other) noexcept { this->storeRelease(other.loadAcquire()); return *this; diff --git a/src/corelib/thread/qatomic_bootstrap.h b/src/corelib/thread/qatomic_bootstrap.h index 27a67fb2ee..c4279ee7b1 100644 --- a/src/corelib/thread/qatomic_bootstrap.h +++ b/src/corelib/thread/qatomic_bootstrap.h @@ -56,16 +56,16 @@ template struct QAtomicOps: QGenericAtomicOps > { typedef T Type; - static bool ref(T &_q_value) Q_DECL_NOTHROW + static bool ref(T &_q_value) noexcept { return ++_q_value != 0; } - static bool deref(T &_q_value) Q_DECL_NOTHROW + static bool deref(T &_q_value) noexcept { return --_q_value != 0; } - static bool testAndSetRelaxed(T &_q_value, T expectedValue, T newValue, T *currentValue = nullptr) Q_DECL_NOTHROW + static bool testAndSetRelaxed(T &_q_value, T expectedValue, T newValue, T *currentValue = nullptr) noexcept { if (currentValue) *currentValue = _q_value; @@ -76,7 +76,7 @@ template struct QAtomicOps: QGenericAtomicOps > return false; } - static T fetchAndStoreRelaxed(T &_q_value, T newValue) Q_DECL_NOTHROW + static T fetchAndStoreRelaxed(T &_q_value, T newValue) noexcept { T tmp = _q_value; _q_value = newValue; @@ -84,7 +84,7 @@ template struct QAtomicOps: QGenericAtomicOps > } template static - T fetchAndAddRelaxed(T &_q_value, AdditiveType valueToAdd) Q_DECL_NOTHROW + T fetchAndAddRelaxed(T &_q_value, AdditiveType valueToAdd) noexcept { T returnValue = _q_value; _q_value += valueToAdd; diff --git a/src/corelib/thread/qatomic_cxx11.h b/src/corelib/thread/qatomic_cxx11.h index 2fc0bf5419..32d27734fc 100644 --- a/src/corelib/thread/qatomic_cxx11.h +++ b/src/corelib/thread/qatomic_cxx11.h @@ -222,43 +222,43 @@ template struct QAtomicOps typedef std::atomic Type; template static inline - T load(const std::atomic &_q_value) Q_DECL_NOTHROW + T load(const std::atomic &_q_value) noexcept { return _q_value.load(std::memory_order_relaxed); } template static inline - T load(const volatile std::atomic &_q_value) Q_DECL_NOTHROW + T load(const volatile std::atomic &_q_value) noexcept { return _q_value.load(std::memory_order_relaxed); } template static inline - T loadAcquire(const std::atomic &_q_value) Q_DECL_NOTHROW + T loadAcquire(const std::atomic &_q_value) noexcept { return _q_value.load(std::memory_order_acquire); } template static inline - T loadAcquire(const volatile std::atomic &_q_value) Q_DECL_NOTHROW + T loadAcquire(const volatile std::atomic &_q_value) noexcept { return _q_value.load(std::memory_order_acquire); } template static inline - void store(std::atomic &_q_value, T newValue) Q_DECL_NOTHROW + void store(std::atomic &_q_value, T newValue) noexcept { _q_value.store(newValue, std::memory_order_relaxed); } template static inline - void storeRelease(std::atomic &_q_value, T newValue) Q_DECL_NOTHROW + void storeRelease(std::atomic &_q_value, T newValue) noexcept { _q_value.store(newValue, std::memory_order_release); } - static inline Q_DECL_CONSTEXPR bool isReferenceCountingNative() Q_DECL_NOTHROW { return isTestAndSetNative(); } - static inline Q_DECL_CONSTEXPR bool isReferenceCountingWaitFree() Q_DECL_NOTHROW { return false; } + static inline Q_DECL_CONSTEXPR bool isReferenceCountingNative() noexcept { return isTestAndSetNative(); } + static inline Q_DECL_CONSTEXPR bool isReferenceCountingWaitFree() noexcept { return false; } template static inline bool ref(std::atomic &_q_value) { @@ -266,17 +266,17 @@ template struct QAtomicOps } template - static inline bool deref(std::atomic &_q_value) Q_DECL_NOTHROW + static inline bool deref(std::atomic &_q_value) noexcept { return --_q_value != 0; } - static inline Q_DECL_CONSTEXPR bool isTestAndSetNative() Q_DECL_NOTHROW + static inline Q_DECL_CONSTEXPR bool isTestAndSetNative() noexcept { return QAtomicTraits::isLockFree(); } - static inline Q_DECL_CONSTEXPR bool isTestAndSetWaitFree() Q_DECL_NOTHROW { return false; } + static inline Q_DECL_CONSTEXPR bool isTestAndSetWaitFree() noexcept { return false; } template - static bool testAndSetRelaxed(std::atomic &_q_value, T expectedValue, T newValue, T *currentValue = nullptr) Q_DECL_NOTHROW + static bool testAndSetRelaxed(std::atomic &_q_value, T expectedValue, T newValue, T *currentValue = nullptr) noexcept { bool tmp = _q_value.compare_exchange_strong(expectedValue, newValue, std::memory_order_relaxed, std::memory_order_relaxed); if (currentValue) @@ -285,7 +285,7 @@ template struct QAtomicOps } template - static bool testAndSetAcquire(std::atomic &_q_value, T expectedValue, T newValue, T *currentValue = nullptr) Q_DECL_NOTHROW + static bool testAndSetAcquire(std::atomic &_q_value, T expectedValue, T newValue, T *currentValue = nullptr) noexcept { bool tmp = _q_value.compare_exchange_strong(expectedValue, newValue, std::memory_order_acquire, std::memory_order_acquire); if (currentValue) @@ -294,7 +294,7 @@ template struct QAtomicOps } template - static bool testAndSetRelease(std::atomic &_q_value, T expectedValue, T newValue, T *currentValue = nullptr) Q_DECL_NOTHROW + static bool testAndSetRelease(std::atomic &_q_value, T expectedValue, T newValue, T *currentValue = nullptr) noexcept { bool tmp = _q_value.compare_exchange_strong(expectedValue, newValue, std::memory_order_release, std::memory_order_relaxed); if (currentValue) @@ -303,7 +303,7 @@ template struct QAtomicOps } template - static bool testAndSetOrdered(std::atomic &_q_value, T expectedValue, T newValue, T *currentValue = nullptr) Q_DECL_NOTHROW + static bool testAndSetOrdered(std::atomic &_q_value, T expectedValue, T newValue, T *currentValue = nullptr) noexcept { bool tmp = _q_value.compare_exchange_strong(expectedValue, newValue, std::memory_order_acq_rel, std::memory_order_acquire); if (currentValue) @@ -311,152 +311,152 @@ template struct QAtomicOps return tmp; } - static inline Q_DECL_CONSTEXPR bool isFetchAndStoreNative() Q_DECL_NOTHROW { return isTestAndSetNative(); } - static inline Q_DECL_CONSTEXPR bool isFetchAndStoreWaitFree() Q_DECL_NOTHROW { return false; } + static inline Q_DECL_CONSTEXPR bool isFetchAndStoreNative() noexcept { return isTestAndSetNative(); } + static inline Q_DECL_CONSTEXPR bool isFetchAndStoreWaitFree() noexcept { return false; } template - static T fetchAndStoreRelaxed(std::atomic &_q_value, T newValue) Q_DECL_NOTHROW + static T fetchAndStoreRelaxed(std::atomic &_q_value, T newValue) noexcept { return _q_value.exchange(newValue, std::memory_order_relaxed); } template - static T fetchAndStoreAcquire(std::atomic &_q_value, T newValue) Q_DECL_NOTHROW + static T fetchAndStoreAcquire(std::atomic &_q_value, T newValue) noexcept { return _q_value.exchange(newValue, std::memory_order_acquire); } template - static T fetchAndStoreRelease(std::atomic &_q_value, T newValue) Q_DECL_NOTHROW + static T fetchAndStoreRelease(std::atomic &_q_value, T newValue) noexcept { return _q_value.exchange(newValue, std::memory_order_release); } template - static T fetchAndStoreOrdered(std::atomic &_q_value, T newValue) Q_DECL_NOTHROW + static T fetchAndStoreOrdered(std::atomic &_q_value, T newValue) noexcept { return _q_value.exchange(newValue, std::memory_order_acq_rel); } - static inline Q_DECL_CONSTEXPR bool isFetchAndAddNative() Q_DECL_NOTHROW { return isTestAndSetNative(); } - static inline Q_DECL_CONSTEXPR bool isFetchAndAddWaitFree() Q_DECL_NOTHROW { return false; } + static inline Q_DECL_CONSTEXPR bool isFetchAndAddNative() noexcept { return isTestAndSetNative(); } + static inline Q_DECL_CONSTEXPR bool isFetchAndAddWaitFree() noexcept { return false; } template static inline - T fetchAndAddRelaxed(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW + T fetchAndAddRelaxed(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) noexcept { return _q_value.fetch_add(valueToAdd, std::memory_order_relaxed); } template static inline - T fetchAndAddAcquire(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW + T fetchAndAddAcquire(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) noexcept { return _q_value.fetch_add(valueToAdd, std::memory_order_acquire); } template static inline - T fetchAndAddRelease(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW + T fetchAndAddRelease(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) noexcept { return _q_value.fetch_add(valueToAdd, std::memory_order_release); } template static inline - T fetchAndAddOrdered(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW + T fetchAndAddOrdered(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) noexcept { return _q_value.fetch_add(valueToAdd, std::memory_order_acq_rel); } template static inline - T fetchAndSubRelaxed(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW + T fetchAndSubRelaxed(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) noexcept { return _q_value.fetch_sub(valueToAdd, std::memory_order_relaxed); } template static inline - T fetchAndSubAcquire(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW + T fetchAndSubAcquire(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) noexcept { return _q_value.fetch_sub(valueToAdd, std::memory_order_acquire); } template static inline - T fetchAndSubRelease(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW + T fetchAndSubRelease(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) noexcept { return _q_value.fetch_sub(valueToAdd, std::memory_order_release); } template static inline - T fetchAndSubOrdered(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW + T fetchAndSubOrdered(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) noexcept { return _q_value.fetch_sub(valueToAdd, std::memory_order_acq_rel); } template static inline - T fetchAndAndRelaxed(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW + T fetchAndAndRelaxed(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) noexcept { return _q_value.fetch_and(valueToAdd, std::memory_order_relaxed); } template static inline - T fetchAndAndAcquire(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW + T fetchAndAndAcquire(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) noexcept { return _q_value.fetch_and(valueToAdd, std::memory_order_acquire); } template static inline - T fetchAndAndRelease(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW + T fetchAndAndRelease(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) noexcept { return _q_value.fetch_and(valueToAdd, std::memory_order_release); } template static inline - T fetchAndAndOrdered(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW + T fetchAndAndOrdered(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) noexcept { return _q_value.fetch_and(valueToAdd, std::memory_order_acq_rel); } template static inline - T fetchAndOrRelaxed(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW + T fetchAndOrRelaxed(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) noexcept { return _q_value.fetch_or(valueToAdd, std::memory_order_relaxed); } template static inline - T fetchAndOrAcquire(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW + T fetchAndOrAcquire(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) noexcept { return _q_value.fetch_or(valueToAdd, std::memory_order_acquire); } template static inline - T fetchAndOrRelease(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW + T fetchAndOrRelease(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) noexcept { return _q_value.fetch_or(valueToAdd, std::memory_order_release); } template static inline - T fetchAndOrOrdered(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW + T fetchAndOrOrdered(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) noexcept { return _q_value.fetch_or(valueToAdd, std::memory_order_acq_rel); } template static inline - T fetchAndXorRelaxed(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW + T fetchAndXorRelaxed(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) noexcept { return _q_value.fetch_xor(valueToAdd, std::memory_order_relaxed); } template static inline - T fetchAndXorAcquire(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW + T fetchAndXorAcquire(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) noexcept { return _q_value.fetch_xor(valueToAdd, std::memory_order_acquire); } template static inline - T fetchAndXorRelease(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW + T fetchAndXorRelease(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) noexcept { return _q_value.fetch_xor(valueToAdd, std::memory_order_release); } template static inline - T fetchAndXorOrdered(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW + T fetchAndXorOrdered(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) noexcept { return _q_value.fetch_xor(valueToAdd, std::memory_order_acq_rel); } diff --git a/src/corelib/thread/qatomic_msvc.h b/src/corelib/thread/qatomic_msvc.h index 5eae2bdc48..67b5224cd7 100644 --- a/src/corelib/thread/qatomic_msvc.h +++ b/src/corelib/thread/qatomic_msvc.h @@ -269,24 +269,24 @@ template <> struct QAtomicWindowsType<4> { typedef long Type; }; template struct QAtomicOpsBySize : QGenericAtomicOps > { - static inline Q_DECL_CONSTEXPR bool isReferenceCountingNative() Q_DECL_NOTHROW { return true; } - static inline Q_DECL_CONSTEXPR bool isReferenceCountingWaitFree() Q_DECL_NOTHROW { return true; } - template static bool ref(T &_q_value) Q_DECL_NOTHROW; - template static bool deref(T &_q_value) Q_DECL_NOTHROW; + static inline Q_DECL_CONSTEXPR bool isReferenceCountingNative() noexcept { return true; } + static inline Q_DECL_CONSTEXPR bool isReferenceCountingWaitFree() noexcept { return true; } + template static bool ref(T &_q_value) noexcept; + template static bool deref(T &_q_value) noexcept; - static inline Q_DECL_CONSTEXPR bool isTestAndSetNative() Q_DECL_NOTHROW { return true; } - static inline Q_DECL_CONSTEXPR bool isTestAndSetWaitFree() Q_DECL_NOTHROW { return true; } - template static bool testAndSetRelaxed(T &_q_value, T expectedValue, T newValue) Q_DECL_NOTHROW; + static inline Q_DECL_CONSTEXPR bool isTestAndSetNative() noexcept { return true; } + static inline Q_DECL_CONSTEXPR bool isTestAndSetWaitFree() noexcept { return true; } + template static bool testAndSetRelaxed(T &_q_value, T expectedValue, T newValue) noexcept; template - static bool testAndSetRelaxed(T &_q_value, T expectedValue, T newValue, T *currentValue) Q_DECL_NOTHROW; + static bool testAndSetRelaxed(T &_q_value, T expectedValue, T newValue, T *currentValue) noexcept; - static inline Q_DECL_CONSTEXPR bool isFetchAndStoreNative() Q_DECL_NOTHROW { return true; } - static inline Q_DECL_CONSTEXPR bool isFetchAndStoreWaitFree() Q_DECL_NOTHROW { return true; } - template static T fetchAndStoreRelaxed(T &_q_value, T newValue) Q_DECL_NOTHROW; + static inline Q_DECL_CONSTEXPR bool isFetchAndStoreNative() noexcept { return true; } + static inline Q_DECL_CONSTEXPR bool isFetchAndStoreWaitFree() noexcept { return true; } + template static T fetchAndStoreRelaxed(T &_q_value, T newValue) noexcept; - static inline Q_DECL_CONSTEXPR bool isFetchAndAddNative() Q_DECL_NOTHROW { return true; } - static inline Q_DECL_CONSTEXPR bool isFetchAndAddWaitFree() Q_DECL_NOTHROW { return true; } - template static T fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW; + static inline Q_DECL_CONSTEXPR bool isFetchAndAddNative() noexcept { return true; } + static inline Q_DECL_CONSTEXPR bool isFetchAndAddWaitFree() noexcept { return true; } + template static T fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) noexcept; private: typedef typename QAtomicWindowsType::Type Type; @@ -303,76 +303,76 @@ struct QAtomicOps : QAtomicOpsBySize }; template<> template -inline bool QAtomicOpsBySize<4>::ref(T &_q_value) Q_DECL_NOTHROW +inline bool QAtomicOpsBySize<4>::ref(T &_q_value) noexcept { return QT_INTERLOCKED_FUNCTION(Increment)(atomic(&_q_value)) != 0; } template<> template -inline bool QAtomicOpsBySize<4>::deref(T &_q_value) Q_DECL_NOTHROW +inline bool QAtomicOpsBySize<4>::deref(T &_q_value) noexcept { return QT_INTERLOCKED_FUNCTION(Decrement)(atomic(&_q_value)) != 0; } template<> template -inline bool QAtomicOpsBySize<4>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue) Q_DECL_NOTHROW +inline bool QAtomicOpsBySize<4>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue) noexcept { return QT_INTERLOCKED_FUNCTION(CompareExchange)(atomic(&_q_value), value(newValue), value(expectedValue)) == value(expectedValue); } template<> template -inline bool QAtomicOpsBySize<4>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue, T *currentValue) Q_DECL_NOTHROW +inline bool QAtomicOpsBySize<4>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue, T *currentValue) noexcept { *currentValue = T(QT_INTERLOCKED_FUNCTION(CompareExchange)(atomic(&_q_value), newValue, expectedValue)); return *currentValue == expectedValue; } template<> template -inline T QAtomicOpsBySize<4>::fetchAndStoreRelaxed(T &_q_value, T newValue) Q_DECL_NOTHROW +inline T QAtomicOpsBySize<4>::fetchAndStoreRelaxed(T &_q_value, T newValue) noexcept { return QT_INTERLOCKED_FUNCTION(Exchange)(atomic(&_q_value), value(newValue)); } template<> template -inline T QAtomicOpsBySize<4>::fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW +inline T QAtomicOpsBySize<4>::fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) noexcept { return QT_INTERLOCKED_FUNCTION(ExchangeAdd)(atomic(&_q_value), value(valueToAdd * QAtomicAdditiveType::AddScale)); } #ifdef Q_ATOMIC_INT16_IS_SUPPORTED template<> template -inline bool QAtomicOpsBySize<2>::ref(T &_q_value) Q_DECL_NOTHROW +inline bool QAtomicOpsBySize<2>::ref(T &_q_value) noexcept { return QT_INTERLOCKED_FUNCTION(Increment16)(atomic(&_q_value)) != 0; } template<> template -inline bool QAtomicOpsBySize<2>::deref(T &_q_value) Q_DECL_NOTHROW +inline bool QAtomicOpsBySize<2>::deref(T &_q_value) noexcept { return QT_INTERLOCKED_FUNCTION(Decrement16)(atomic(&_q_value)) != 0; } template<> template -inline bool QAtomicOpsBySize<2>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue) Q_DECL_NOTHROW +inline bool QAtomicOpsBySize<2>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue) noexcept { return QT_INTERLOCKED_FUNCTION(CompareExchange16)(atomic(&_q_value), value(newValue), value(expectedValue)) == value(expectedValue); } template<> template -inline bool QAtomicOpsBySize<2>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue, T *currentValue) Q_DECL_NOTHROW +inline bool QAtomicOpsBySize<2>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue, T *currentValue) noexcept { *currentValue = T(QT_INTERLOCKED_FUNCTION(CompareExchange16)(atomic(&_q_value), newValue, expectedValue)); return *currentValue == expectedValue; } template<> template -inline T QAtomicOpsBySize<2>::fetchAndStoreRelaxed(T &_q_value, T newValue) Q_DECL_NOTHROW +inline T QAtomicOpsBySize<2>::fetchAndStoreRelaxed(T &_q_value, T newValue) noexcept { return QT_INTERLOCKED_FUNCTION(Exchange16)(atomic(&_q_value), value(newValue)); } template<> template -inline T QAtomicOpsBySize<2>::fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW +inline T QAtomicOpsBySize<2>::fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) noexcept { return QT_INTERLOCKED_FUNCTION(ExchangeAdd16)(atomic(&_q_value), value(valueToAdd * QAtomicAdditiveType::AddScale)); } @@ -380,38 +380,38 @@ inline T QAtomicOpsBySize<2>::fetchAndAddRelaxed(T &_q_value, typename QAtomicAd #ifdef Q_ATOMIC_INT64_IS_SUPPORTED template<> template -inline bool QAtomicOpsBySize<8>::ref(T &_q_value) Q_DECL_NOTHROW +inline bool QAtomicOpsBySize<8>::ref(T &_q_value) noexcept { return QT_INTERLOCKED_FUNCTION(Increment64)(atomic(&_q_value)) != 0; } template<> template -inline bool QAtomicOpsBySize<8>::deref(T &_q_value) Q_DECL_NOTHROW +inline bool QAtomicOpsBySize<8>::deref(T &_q_value) noexcept { return QT_INTERLOCKED_FUNCTION(Decrement64)(atomic(&_q_value)) != 0; } template<> template -inline bool QAtomicOpsBySize<8>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue) Q_DECL_NOTHROW +inline bool QAtomicOpsBySize<8>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue) noexcept { return QT_INTERLOCKED_FUNCTION(CompareExchange64)(atomic(&_q_value), value(newValue), value(expectedValue)) == value(expectedValue); } template<> template -inline bool QAtomicOpsBySize<8>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue, T *currentValue) Q_DECL_NOTHROW +inline bool QAtomicOpsBySize<8>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue, T *currentValue) noexcept { *currentValue = T(QT_INTERLOCKED_FUNCTION(CompareExchange64)(atomic(&_q_value), newValue, expectedValue)); return *currentValue == expectedValue; } template<> template -inline T QAtomicOpsBySize<8>::fetchAndStoreRelaxed(T &_q_value, T newValue) Q_DECL_NOTHROW +inline T QAtomicOpsBySize<8>::fetchAndStoreRelaxed(T &_q_value, T newValue) noexcept { return QT_INTERLOCKED_FUNCTION(Exchange64)(atomic(&_q_value), value(newValue)); } template<> template -inline T QAtomicOpsBySize<8>::fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW +inline T QAtomicOpsBySize<8>::fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) noexcept { return QT_INTERLOCKED_FUNCTION(ExchangeAdd64)(atomic(&_q_value), value(valueToAdd * QAtomicAdditiveType::AddScale)); } @@ -423,41 +423,41 @@ struct QAtomicOps : QGenericAtomicOps > { typedef T *Type; - static inline Q_DECL_CONSTEXPR bool isTestAndSetNative() Q_DECL_NOTHROW { return true; } - static inline Q_DECL_CONSTEXPR bool isTestAndSetWaitFree() Q_DECL_NOTHROW { return true; } - static bool testAndSetRelaxed(T *&_q_value, T *expectedValue, T *newValue) Q_DECL_NOTHROW; - static bool testAndSetRelaxed(T *&_q_value, T *expectedValue, T *newValue, T **currentValue) Q_DECL_NOTHROW; + static inline Q_DECL_CONSTEXPR bool isTestAndSetNative() noexcept { return true; } + static inline Q_DECL_CONSTEXPR bool isTestAndSetWaitFree() noexcept { return true; } + static bool testAndSetRelaxed(T *&_q_value, T *expectedValue, T *newValue) noexcept; + static bool testAndSetRelaxed(T *&_q_value, T *expectedValue, T *newValue, T **currentValue) noexcept; - static inline Q_DECL_CONSTEXPR bool isFetchAndStoreNative() Q_DECL_NOTHROW { return true; } - static inline Q_DECL_CONSTEXPR bool isFetchAndStoreWaitFree() Q_DECL_NOTHROW { return true; } - static T *fetchAndStoreRelaxed(T *&_q_value, T *newValue) Q_DECL_NOTHROW; + static inline Q_DECL_CONSTEXPR bool isFetchAndStoreNative() noexcept { return true; } + static inline Q_DECL_CONSTEXPR bool isFetchAndStoreWaitFree() noexcept { return true; } + static T *fetchAndStoreRelaxed(T *&_q_value, T *newValue) noexcept; - static inline Q_DECL_CONSTEXPR bool isFetchAndAddNative() Q_DECL_NOTHROW { return true; } - static inline Q_DECL_CONSTEXPR bool isFetchAndAddWaitFree() Q_DECL_NOTHROW { return true; } - static T *fetchAndAddRelaxed(T *&_q_value, qptrdiff valueToAdd) Q_DECL_NOTHROW; + static inline Q_DECL_CONSTEXPR bool isFetchAndAddNative() noexcept { return true; } + static inline Q_DECL_CONSTEXPR bool isFetchAndAddWaitFree() noexcept { return true; } + static T *fetchAndAddRelaxed(T *&_q_value, qptrdiff valueToAdd) noexcept; }; template -inline bool QAtomicOps::testAndSetRelaxed(T *&_q_value, T *expectedValue, T *newValue) Q_DECL_NOTHROW +inline bool QAtomicOps::testAndSetRelaxed(T *&_q_value, T *expectedValue, T *newValue) noexcept { return QT_INTERLOCKED_COMPARE_EXCHANGE_POINTER(&_q_value, newValue, expectedValue) == expectedValue; } template -inline bool QAtomicOps::testAndSetRelaxed(T *&_q_value, T *expectedValue, T *newValue, T **currentValue) Q_DECL_NOTHROW +inline bool QAtomicOps::testAndSetRelaxed(T *&_q_value, T *expectedValue, T *newValue, T **currentValue) noexcept { *currentValue = reinterpret_cast(QT_INTERLOCKED_COMPARE_EXCHANGE_POINTER(&_q_value, newValue, expectedValue)); return *currentValue == expectedValue; } template -inline T *QAtomicOps::fetchAndStoreRelaxed(T *&_q_value, T *newValue) Q_DECL_NOTHROW +inline T *QAtomicOps::fetchAndStoreRelaxed(T *&_q_value, T *newValue) noexcept { return reinterpret_cast(QT_INTERLOCKED_EXCHANGE_POINTER(&_q_value, newValue)); } template -inline T *QAtomicOps::fetchAndAddRelaxed(T *&_q_value, qptrdiff valueToAdd) Q_DECL_NOTHROW +inline T *QAtomicOps::fetchAndAddRelaxed(T *&_q_value, qptrdiff valueToAdd) noexcept { return reinterpret_cast(QT_INTERLOCKED_EXCHANGE_ADD_POINTER(&_q_value, valueToAdd * sizeof(T))); } diff --git a/src/corelib/thread/qbasicatomic.h b/src/corelib/thread/qbasicatomic.h index a0304697b8..ad6cba04dd 100644 --- a/src/corelib/thread/qbasicatomic.h +++ b/src/corelib/thread/qbasicatomic.h @@ -100,125 +100,125 @@ public: // Everything below is either implemented in ../arch/qatomic_XXX.h or (as fallback) in qgenericatomic.h - T load() const Q_DECL_NOTHROW { return Ops::load(_q_value); } - void store(T newValue) Q_DECL_NOTHROW { Ops::store(_q_value, newValue); } + T load() const noexcept { return Ops::load(_q_value); } + void store(T newValue) noexcept { Ops::store(_q_value, newValue); } - T loadAcquire() const Q_DECL_NOTHROW { return Ops::loadAcquire(_q_value); } - void storeRelease(T newValue) Q_DECL_NOTHROW { Ops::storeRelease(_q_value, newValue); } - operator T() const Q_DECL_NOTHROW { return loadAcquire(); } - T operator=(T newValue) Q_DECL_NOTHROW { storeRelease(newValue); return newValue; } + T loadAcquire() const noexcept { return Ops::loadAcquire(_q_value); } + void storeRelease(T newValue) noexcept { Ops::storeRelease(_q_value, newValue); } + operator T() const noexcept { return loadAcquire(); } + T operator=(T newValue) noexcept { storeRelease(newValue); return newValue; } - static Q_DECL_CONSTEXPR bool isReferenceCountingNative() Q_DECL_NOTHROW { return Ops::isReferenceCountingNative(); } - static Q_DECL_CONSTEXPR bool isReferenceCountingWaitFree() Q_DECL_NOTHROW { return Ops::isReferenceCountingWaitFree(); } + static Q_DECL_CONSTEXPR bool isReferenceCountingNative() noexcept { return Ops::isReferenceCountingNative(); } + static Q_DECL_CONSTEXPR bool isReferenceCountingWaitFree() noexcept { return Ops::isReferenceCountingWaitFree(); } - bool ref() Q_DECL_NOTHROW { return Ops::ref(_q_value); } - bool deref() Q_DECL_NOTHROW { return Ops::deref(_q_value); } + bool ref() noexcept { return Ops::ref(_q_value); } + bool deref() noexcept { return Ops::deref(_q_value); } - static Q_DECL_CONSTEXPR bool isTestAndSetNative() Q_DECL_NOTHROW { return Ops::isTestAndSetNative(); } - static Q_DECL_CONSTEXPR bool isTestAndSetWaitFree() Q_DECL_NOTHROW { return Ops::isTestAndSetWaitFree(); } + static Q_DECL_CONSTEXPR bool isTestAndSetNative() noexcept { return Ops::isTestAndSetNative(); } + static Q_DECL_CONSTEXPR bool isTestAndSetWaitFree() noexcept { return Ops::isTestAndSetWaitFree(); } - bool testAndSetRelaxed(T expectedValue, T newValue) Q_DECL_NOTHROW + bool testAndSetRelaxed(T expectedValue, T newValue) noexcept { return Ops::testAndSetRelaxed(_q_value, expectedValue, newValue); } - bool testAndSetAcquire(T expectedValue, T newValue) Q_DECL_NOTHROW + bool testAndSetAcquire(T expectedValue, T newValue) noexcept { return Ops::testAndSetAcquire(_q_value, expectedValue, newValue); } - bool testAndSetRelease(T expectedValue, T newValue) Q_DECL_NOTHROW + bool testAndSetRelease(T expectedValue, T newValue) noexcept { return Ops::testAndSetRelease(_q_value, expectedValue, newValue); } - bool testAndSetOrdered(T expectedValue, T newValue) Q_DECL_NOTHROW + bool testAndSetOrdered(T expectedValue, T newValue) noexcept { return Ops::testAndSetOrdered(_q_value, expectedValue, newValue); } - bool testAndSetRelaxed(T expectedValue, T newValue, T ¤tValue) Q_DECL_NOTHROW + bool testAndSetRelaxed(T expectedValue, T newValue, T ¤tValue) noexcept { return Ops::testAndSetRelaxed(_q_value, expectedValue, newValue, ¤tValue); } - bool testAndSetAcquire(T expectedValue, T newValue, T ¤tValue) Q_DECL_NOTHROW + bool testAndSetAcquire(T expectedValue, T newValue, T ¤tValue) noexcept { return Ops::testAndSetAcquire(_q_value, expectedValue, newValue, ¤tValue); } - bool testAndSetRelease(T expectedValue, T newValue, T ¤tValue) Q_DECL_NOTHROW + bool testAndSetRelease(T expectedValue, T newValue, T ¤tValue) noexcept { return Ops::testAndSetRelease(_q_value, expectedValue, newValue, ¤tValue); } - bool testAndSetOrdered(T expectedValue, T newValue, T ¤tValue) Q_DECL_NOTHROW + bool testAndSetOrdered(T expectedValue, T newValue, T ¤tValue) noexcept { return Ops::testAndSetOrdered(_q_value, expectedValue, newValue, ¤tValue); } - static Q_DECL_CONSTEXPR bool isFetchAndStoreNative() Q_DECL_NOTHROW { return Ops::isFetchAndStoreNative(); } - static Q_DECL_CONSTEXPR bool isFetchAndStoreWaitFree() Q_DECL_NOTHROW { return Ops::isFetchAndStoreWaitFree(); } + static Q_DECL_CONSTEXPR bool isFetchAndStoreNative() noexcept { return Ops::isFetchAndStoreNative(); } + static Q_DECL_CONSTEXPR bool isFetchAndStoreWaitFree() noexcept { return Ops::isFetchAndStoreWaitFree(); } - T fetchAndStoreRelaxed(T newValue) Q_DECL_NOTHROW + T fetchAndStoreRelaxed(T newValue) noexcept { return Ops::fetchAndStoreRelaxed(_q_value, newValue); } - T fetchAndStoreAcquire(T newValue) Q_DECL_NOTHROW + T fetchAndStoreAcquire(T newValue) noexcept { return Ops::fetchAndStoreAcquire(_q_value, newValue); } - T fetchAndStoreRelease(T newValue) Q_DECL_NOTHROW + T fetchAndStoreRelease(T newValue) noexcept { return Ops::fetchAndStoreRelease(_q_value, newValue); } - T fetchAndStoreOrdered(T newValue) Q_DECL_NOTHROW + T fetchAndStoreOrdered(T newValue) noexcept { return Ops::fetchAndStoreOrdered(_q_value, newValue); } - static Q_DECL_CONSTEXPR bool isFetchAndAddNative() Q_DECL_NOTHROW { return Ops::isFetchAndAddNative(); } - static Q_DECL_CONSTEXPR bool isFetchAndAddWaitFree() Q_DECL_NOTHROW { return Ops::isFetchAndAddWaitFree(); } + static Q_DECL_CONSTEXPR bool isFetchAndAddNative() noexcept { return Ops::isFetchAndAddNative(); } + static Q_DECL_CONSTEXPR bool isFetchAndAddWaitFree() noexcept { return Ops::isFetchAndAddWaitFree(); } - T fetchAndAddRelaxed(T valueToAdd) Q_DECL_NOTHROW + T fetchAndAddRelaxed(T valueToAdd) noexcept { return Ops::fetchAndAddRelaxed(_q_value, valueToAdd); } - T fetchAndAddAcquire(T valueToAdd) Q_DECL_NOTHROW + T fetchAndAddAcquire(T valueToAdd) noexcept { return Ops::fetchAndAddAcquire(_q_value, valueToAdd); } - T fetchAndAddRelease(T valueToAdd) Q_DECL_NOTHROW + T fetchAndAddRelease(T valueToAdd) noexcept { return Ops::fetchAndAddRelease(_q_value, valueToAdd); } - T fetchAndAddOrdered(T valueToAdd) Q_DECL_NOTHROW + T fetchAndAddOrdered(T valueToAdd) noexcept { return Ops::fetchAndAddOrdered(_q_value, valueToAdd); } - T fetchAndSubRelaxed(T valueToAdd) Q_DECL_NOTHROW + T fetchAndSubRelaxed(T valueToAdd) noexcept { return Ops::fetchAndSubRelaxed(_q_value, valueToAdd); } - T fetchAndSubAcquire(T valueToAdd) Q_DECL_NOTHROW + T fetchAndSubAcquire(T valueToAdd) noexcept { return Ops::fetchAndSubAcquire(_q_value, valueToAdd); } - T fetchAndSubRelease(T valueToAdd) Q_DECL_NOTHROW + T fetchAndSubRelease(T valueToAdd) noexcept { return Ops::fetchAndSubRelease(_q_value, valueToAdd); } - T fetchAndSubOrdered(T valueToAdd) Q_DECL_NOTHROW + T fetchAndSubOrdered(T valueToAdd) noexcept { return Ops::fetchAndSubOrdered(_q_value, valueToAdd); } - T fetchAndAndRelaxed(T valueToAdd) Q_DECL_NOTHROW + T fetchAndAndRelaxed(T valueToAdd) noexcept { return Ops::fetchAndAndRelaxed(_q_value, valueToAdd); } - T fetchAndAndAcquire(T valueToAdd) Q_DECL_NOTHROW + T fetchAndAndAcquire(T valueToAdd) noexcept { return Ops::fetchAndAndAcquire(_q_value, valueToAdd); } - T fetchAndAndRelease(T valueToAdd) Q_DECL_NOTHROW + T fetchAndAndRelease(T valueToAdd) noexcept { return Ops::fetchAndAndRelease(_q_value, valueToAdd); } - T fetchAndAndOrdered(T valueToAdd) Q_DECL_NOTHROW + T fetchAndAndOrdered(T valueToAdd) noexcept { return Ops::fetchAndAndOrdered(_q_value, valueToAdd); } - T fetchAndOrRelaxed(T valueToAdd) Q_DECL_NOTHROW + T fetchAndOrRelaxed(T valueToAdd) noexcept { return Ops::fetchAndOrRelaxed(_q_value, valueToAdd); } - T fetchAndOrAcquire(T valueToAdd) Q_DECL_NOTHROW + T fetchAndOrAcquire(T valueToAdd) noexcept { return Ops::fetchAndOrAcquire(_q_value, valueToAdd); } - T fetchAndOrRelease(T valueToAdd) Q_DECL_NOTHROW + T fetchAndOrRelease(T valueToAdd) noexcept { return Ops::fetchAndOrRelease(_q_value, valueToAdd); } - T fetchAndOrOrdered(T valueToAdd) Q_DECL_NOTHROW + T fetchAndOrOrdered(T valueToAdd) noexcept { return Ops::fetchAndOrOrdered(_q_value, valueToAdd); } - T fetchAndXorRelaxed(T valueToAdd) Q_DECL_NOTHROW + T fetchAndXorRelaxed(T valueToAdd) noexcept { return Ops::fetchAndXorRelaxed(_q_value, valueToAdd); } - T fetchAndXorAcquire(T valueToAdd) Q_DECL_NOTHROW + T fetchAndXorAcquire(T valueToAdd) noexcept { return Ops::fetchAndXorAcquire(_q_value, valueToAdd); } - T fetchAndXorRelease(T valueToAdd) Q_DECL_NOTHROW + T fetchAndXorRelease(T valueToAdd) noexcept { return Ops::fetchAndXorRelease(_q_value, valueToAdd); } - T fetchAndXorOrdered(T valueToAdd) Q_DECL_NOTHROW + T fetchAndXorOrdered(T valueToAdd) noexcept { return Ops::fetchAndXorOrdered(_q_value, valueToAdd); } - T operator++() Q_DECL_NOTHROW + T operator++() noexcept { return fetchAndAddOrdered(1) + 1; } - T operator++(int) Q_DECL_NOTHROW + T operator++(int) noexcept { return fetchAndAddOrdered(1); } - T operator--() Q_DECL_NOTHROW + T operator--() noexcept { return fetchAndSubOrdered(1) - 1; } - T operator--(int) Q_DECL_NOTHROW + T operator--(int) noexcept { return fetchAndSubOrdered(1); } - T operator+=(T v) Q_DECL_NOTHROW + T operator+=(T v) noexcept { return fetchAndAddOrdered(v) + v; } - T operator-=(T v) Q_DECL_NOTHROW + T operator-=(T v) noexcept { return fetchAndSubOrdered(v) - v; } - T operator&=(T v) Q_DECL_NOTHROW + T operator&=(T v) noexcept { return fetchAndAndOrdered(v) & v; } - T operator|=(T v) Q_DECL_NOTHROW + T operator|=(T v) noexcept { return fetchAndOrOrdered(v) | v; } - T operator^=(T v) Q_DECL_NOTHROW + T operator^=(T v) noexcept { return fetchAndXorOrdered(v) ^ v; } #ifdef QT_BASIC_ATOMIC_HAS_CONSTRUCTORS QBasicAtomicInteger() = default; - constexpr QBasicAtomicInteger(T value) Q_DECL_NOTHROW : _q_value(value) {} + constexpr QBasicAtomicInteger(T value) noexcept : _q_value(value) {} QBasicAtomicInteger(const QBasicAtomicInteger &) = delete; QBasicAtomicInteger &operator=(const QBasicAtomicInteger &) = delete; QBasicAtomicInteger &operator=(const QBasicAtomicInteger &) volatile = delete; @@ -236,85 +236,85 @@ public: AtomicType _q_value; - Type load() const Q_DECL_NOTHROW { return Ops::load(_q_value); } - void store(Type newValue) Q_DECL_NOTHROW { Ops::store(_q_value, newValue); } - operator Type() const Q_DECL_NOTHROW { return loadAcquire(); } - Type operator=(Type newValue) Q_DECL_NOTHROW { storeRelease(newValue); return newValue; } + Type load() const noexcept { return Ops::load(_q_value); } + void store(Type newValue) noexcept { Ops::store(_q_value, newValue); } + operator Type() const noexcept { return loadAcquire(); } + Type operator=(Type newValue) noexcept { storeRelease(newValue); return newValue; } // Atomic API, implemented in qatomic_XXX.h - Type loadAcquire() const Q_DECL_NOTHROW { return Ops::loadAcquire(_q_value); } - void storeRelease(Type newValue) Q_DECL_NOTHROW { Ops::storeRelease(_q_value, newValue); } + Type loadAcquire() const noexcept { return Ops::loadAcquire(_q_value); } + void storeRelease(Type newValue) noexcept { Ops::storeRelease(_q_value, newValue); } - static Q_DECL_CONSTEXPR bool isTestAndSetNative() Q_DECL_NOTHROW { return Ops::isTestAndSetNative(); } - static Q_DECL_CONSTEXPR bool isTestAndSetWaitFree() Q_DECL_NOTHROW { return Ops::isTestAndSetWaitFree(); } + static Q_DECL_CONSTEXPR bool isTestAndSetNative() noexcept { return Ops::isTestAndSetNative(); } + static Q_DECL_CONSTEXPR bool isTestAndSetWaitFree() noexcept { return Ops::isTestAndSetWaitFree(); } - bool testAndSetRelaxed(Type expectedValue, Type newValue) Q_DECL_NOTHROW + bool testAndSetRelaxed(Type expectedValue, Type newValue) noexcept { return Ops::testAndSetRelaxed(_q_value, expectedValue, newValue); } - bool testAndSetAcquire(Type expectedValue, Type newValue) Q_DECL_NOTHROW + bool testAndSetAcquire(Type expectedValue, Type newValue) noexcept { return Ops::testAndSetAcquire(_q_value, expectedValue, newValue); } - bool testAndSetRelease(Type expectedValue, Type newValue) Q_DECL_NOTHROW + bool testAndSetRelease(Type expectedValue, Type newValue) noexcept { return Ops::testAndSetRelease(_q_value, expectedValue, newValue); } - bool testAndSetOrdered(Type expectedValue, Type newValue) Q_DECL_NOTHROW + bool testAndSetOrdered(Type expectedValue, Type newValue) noexcept { return Ops::testAndSetOrdered(_q_value, expectedValue, newValue); } - bool testAndSetRelaxed(Type expectedValue, Type newValue, Type ¤tValue) Q_DECL_NOTHROW + bool testAndSetRelaxed(Type expectedValue, Type newValue, Type ¤tValue) noexcept { return Ops::testAndSetRelaxed(_q_value, expectedValue, newValue, ¤tValue); } - bool testAndSetAcquire(Type expectedValue, Type newValue, Type ¤tValue) Q_DECL_NOTHROW + bool testAndSetAcquire(Type expectedValue, Type newValue, Type ¤tValue) noexcept { return Ops::testAndSetAcquire(_q_value, expectedValue, newValue, ¤tValue); } - bool testAndSetRelease(Type expectedValue, Type newValue, Type ¤tValue) Q_DECL_NOTHROW + bool testAndSetRelease(Type expectedValue, Type newValue, Type ¤tValue) noexcept { return Ops::testAndSetRelease(_q_value, expectedValue, newValue, ¤tValue); } - bool testAndSetOrdered(Type expectedValue, Type newValue, Type ¤tValue) Q_DECL_NOTHROW + bool testAndSetOrdered(Type expectedValue, Type newValue, Type ¤tValue) noexcept { return Ops::testAndSetOrdered(_q_value, expectedValue, newValue, ¤tValue); } - static Q_DECL_CONSTEXPR bool isFetchAndStoreNative() Q_DECL_NOTHROW { return Ops::isFetchAndStoreNative(); } - static Q_DECL_CONSTEXPR bool isFetchAndStoreWaitFree() Q_DECL_NOTHROW { return Ops::isFetchAndStoreWaitFree(); } + static Q_DECL_CONSTEXPR bool isFetchAndStoreNative() noexcept { return Ops::isFetchAndStoreNative(); } + static Q_DECL_CONSTEXPR bool isFetchAndStoreWaitFree() noexcept { return Ops::isFetchAndStoreWaitFree(); } - Type fetchAndStoreRelaxed(Type newValue) Q_DECL_NOTHROW + Type fetchAndStoreRelaxed(Type newValue) noexcept { return Ops::fetchAndStoreRelaxed(_q_value, newValue); } - Type fetchAndStoreAcquire(Type newValue) Q_DECL_NOTHROW + Type fetchAndStoreAcquire(Type newValue) noexcept { return Ops::fetchAndStoreAcquire(_q_value, newValue); } - Type fetchAndStoreRelease(Type newValue) Q_DECL_NOTHROW + Type fetchAndStoreRelease(Type newValue) noexcept { return Ops::fetchAndStoreRelease(_q_value, newValue); } - Type fetchAndStoreOrdered(Type newValue) Q_DECL_NOTHROW + Type fetchAndStoreOrdered(Type newValue) noexcept { return Ops::fetchAndStoreOrdered(_q_value, newValue); } - static Q_DECL_CONSTEXPR bool isFetchAndAddNative() Q_DECL_NOTHROW { return Ops::isFetchAndAddNative(); } - static Q_DECL_CONSTEXPR bool isFetchAndAddWaitFree() Q_DECL_NOTHROW { return Ops::isFetchAndAddWaitFree(); } + static Q_DECL_CONSTEXPR bool isFetchAndAddNative() noexcept { return Ops::isFetchAndAddNative(); } + static Q_DECL_CONSTEXPR bool isFetchAndAddWaitFree() noexcept { return Ops::isFetchAndAddWaitFree(); } - Type fetchAndAddRelaxed(qptrdiff valueToAdd) Q_DECL_NOTHROW + Type fetchAndAddRelaxed(qptrdiff valueToAdd) noexcept { return Ops::fetchAndAddRelaxed(_q_value, valueToAdd); } - Type fetchAndAddAcquire(qptrdiff valueToAdd) Q_DECL_NOTHROW + Type fetchAndAddAcquire(qptrdiff valueToAdd) noexcept { return Ops::fetchAndAddAcquire(_q_value, valueToAdd); } - Type fetchAndAddRelease(qptrdiff valueToAdd) Q_DECL_NOTHROW + Type fetchAndAddRelease(qptrdiff valueToAdd) noexcept { return Ops::fetchAndAddRelease(_q_value, valueToAdd); } - Type fetchAndAddOrdered(qptrdiff valueToAdd) Q_DECL_NOTHROW + Type fetchAndAddOrdered(qptrdiff valueToAdd) noexcept { return Ops::fetchAndAddOrdered(_q_value, valueToAdd); } - Type fetchAndSubRelaxed(qptrdiff valueToAdd) Q_DECL_NOTHROW + Type fetchAndSubRelaxed(qptrdiff valueToAdd) noexcept { return Ops::fetchAndSubRelaxed(_q_value, valueToAdd); } - Type fetchAndSubAcquire(qptrdiff valueToAdd) Q_DECL_NOTHROW + Type fetchAndSubAcquire(qptrdiff valueToAdd) noexcept { return Ops::fetchAndSubAcquire(_q_value, valueToAdd); } - Type fetchAndSubRelease(qptrdiff valueToAdd) Q_DECL_NOTHROW + Type fetchAndSubRelease(qptrdiff valueToAdd) noexcept { return Ops::fetchAndSubRelease(_q_value, valueToAdd); } - Type fetchAndSubOrdered(qptrdiff valueToAdd) Q_DECL_NOTHROW + Type fetchAndSubOrdered(qptrdiff valueToAdd) noexcept { return Ops::fetchAndSubOrdered(_q_value, valueToAdd); } - Type operator++() Q_DECL_NOTHROW + Type operator++() noexcept { return fetchAndAddOrdered(1) + 1; } - Type operator++(int) Q_DECL_NOTHROW + Type operator++(int) noexcept { return fetchAndAddOrdered(1); } - Type operator--() Q_DECL_NOTHROW + Type operator--() noexcept { return fetchAndSubOrdered(1) - 1; } - Type operator--(int) Q_DECL_NOTHROW + Type operator--(int) noexcept { return fetchAndSubOrdered(1); } - Type operator+=(qptrdiff valueToAdd) Q_DECL_NOTHROW + Type operator+=(qptrdiff valueToAdd) noexcept { return fetchAndAddOrdered(valueToAdd) + valueToAdd; } - Type operator-=(qptrdiff valueToSub) Q_DECL_NOTHROW + Type operator-=(qptrdiff valueToSub) noexcept { return fetchAndSubOrdered(valueToSub) - valueToSub; } #ifdef QT_BASIC_ATOMIC_HAS_CONSTRUCTORS QBasicAtomicPointer() = default; - constexpr QBasicAtomicPointer(Type value) Q_DECL_NOTHROW : _q_value(value) {} + constexpr QBasicAtomicPointer(Type value) noexcept : _q_value(value) {} QBasicAtomicPointer(const QBasicAtomicPointer &) = delete; QBasicAtomicPointer &operator=(const QBasicAtomicPointer &) = delete; QBasicAtomicPointer &operator=(const QBasicAtomicPointer &) volatile = delete; diff --git a/src/corelib/thread/qfutex_p.h b/src/corelib/thread/qfutex_p.h index 483664c783..136f6bca8c 100644 --- a/src/corelib/thread/qfutex_p.h +++ b/src/corelib/thread/qfutex_p.h @@ -85,7 +85,7 @@ QT_BEGIN_NAMESPACE namespace QtLinuxFutex { constexpr inline bool futexAvailable() { return true; } inline int _q_futex(int *addr, int op, int val, quintptr val2 = 0, - int *addr2 = nullptr, int val3 = 0) Q_DECL_NOTHROW + int *addr2 = nullptr, int val3 = 0) noexcept { // we use __NR_futex because some libcs (like Android's bionic) don't // provide SYS_futex etc. diff --git a/src/corelib/thread/qgenericatomic.h b/src/corelib/thread/qgenericatomic.h index 89c4fe9a11..f8333e7de6 100644 --- a/src/corelib/thread/qgenericatomic.h +++ b/src/corelib/thread/qgenericatomic.h @@ -72,32 +72,32 @@ template struct QGenericAtomicOps { template struct AtomicType { typedef T Type; typedef T *PointerType; }; - template static void acquireMemoryFence(const T &_q_value) Q_DECL_NOTHROW + template static void acquireMemoryFence(const T &_q_value) noexcept { BaseClass::orderedMemoryFence(_q_value); } - template static void releaseMemoryFence(const T &_q_value) Q_DECL_NOTHROW + template static void releaseMemoryFence(const T &_q_value) noexcept { BaseClass::orderedMemoryFence(_q_value); } - template static void orderedMemoryFence(const T &) Q_DECL_NOTHROW + template static void orderedMemoryFence(const T &) noexcept { } template static Q_ALWAYS_INLINE - T load(const T &_q_value) Q_DECL_NOTHROW + T load(const T &_q_value) noexcept { return _q_value; } template static Q_ALWAYS_INLINE - void store(T &_q_value, X newValue) Q_DECL_NOTHROW + void store(T &_q_value, X newValue) noexcept { _q_value = newValue; } template static Q_ALWAYS_INLINE - T loadAcquire(const T &_q_value) Q_DECL_NOTHROW + T loadAcquire(const T &_q_value) noexcept { T tmp = *static_cast(&_q_value); BaseClass::acquireMemoryFence(_q_value); @@ -105,24 +105,24 @@ template struct QGenericAtomicOps } template static Q_ALWAYS_INLINE - void storeRelease(T &_q_value, X newValue) Q_DECL_NOTHROW + void storeRelease(T &_q_value, X newValue) noexcept { BaseClass::releaseMemoryFence(_q_value); *static_cast(&_q_value) = newValue; } - static inline Q_DECL_CONSTEXPR bool isReferenceCountingNative() Q_DECL_NOTHROW + static inline Q_DECL_CONSTEXPR bool isReferenceCountingNative() noexcept { return BaseClass::isFetchAndAddNative(); } - static inline Q_DECL_CONSTEXPR bool isReferenceCountingWaitFree() Q_DECL_NOTHROW + static inline Q_DECL_CONSTEXPR bool isReferenceCountingWaitFree() noexcept { return BaseClass::isFetchAndAddWaitFree(); } template static Q_ALWAYS_INLINE - bool ref(T &_q_value) Q_DECL_NOTHROW + bool ref(T &_q_value) noexcept { return BaseClass::fetchAndAddRelaxed(_q_value, 1) != T(-1); } template static Q_ALWAYS_INLINE - bool deref(T &_q_value) Q_DECL_NOTHROW + bool deref(T &_q_value) noexcept { return BaseClass::fetchAndAddRelaxed(_q_value, -1) != 1; } @@ -130,16 +130,16 @@ template struct QGenericAtomicOps #if 0 // These functions have no default implementation // Archictectures must implement them - static inline Q_DECL_CONSTEXPR bool isTestAndSetNative() Q_DECL_NOTHROW; - static inline Q_DECL_CONSTEXPR bool isTestAndSetWaitFree() Q_DECL_NOTHROW; + static inline Q_DECL_CONSTEXPR bool isTestAndSetNative() noexcept; + static inline Q_DECL_CONSTEXPR bool isTestAndSetWaitFree() noexcept; template static inline - bool testAndSetRelaxed(T &_q_value, X expectedValue, X newValue) Q_DECL_NOTHROW; + bool testAndSetRelaxed(T &_q_value, X expectedValue, X newValue) noexcept; template static inline - bool testAndSetRelaxed(T &_q_value, X expectedValue, X newValue, X *currentValue) Q_DECL_NOTHROW; + bool testAndSetRelaxed(T &_q_value, X expectedValue, X newValue, X *currentValue) noexcept; #endif template static Q_ALWAYS_INLINE - bool testAndSetAcquire(T &_q_value, X expectedValue, X newValue) Q_DECL_NOTHROW + bool testAndSetAcquire(T &_q_value, X expectedValue, X newValue) noexcept { bool tmp = BaseClass::testAndSetRelaxed(_q_value, expectedValue, newValue); BaseClass::acquireMemoryFence(_q_value); @@ -147,21 +147,21 @@ template struct QGenericAtomicOps } template static Q_ALWAYS_INLINE - bool testAndSetRelease(T &_q_value, X expectedValue, X newValue) Q_DECL_NOTHROW + bool testAndSetRelease(T &_q_value, X expectedValue, X newValue) noexcept { BaseClass::releaseMemoryFence(_q_value); return BaseClass::testAndSetRelaxed(_q_value, expectedValue, newValue); } template static Q_ALWAYS_INLINE - bool testAndSetOrdered(T &_q_value, X expectedValue, X newValue) Q_DECL_NOTHROW + bool testAndSetOrdered(T &_q_value, X expectedValue, X newValue) noexcept { BaseClass::orderedMemoryFence(_q_value); return BaseClass::testAndSetRelaxed(_q_value, expectedValue, newValue); } template static Q_ALWAYS_INLINE - bool testAndSetAcquire(T &_q_value, X expectedValue, X newValue, X *currentValue) Q_DECL_NOTHROW + bool testAndSetAcquire(T &_q_value, X expectedValue, X newValue, X *currentValue) noexcept { bool tmp = BaseClass::testAndSetRelaxed(_q_value, expectedValue, newValue, currentValue); BaseClass::acquireMemoryFence(_q_value); @@ -169,24 +169,24 @@ template struct QGenericAtomicOps } template static Q_ALWAYS_INLINE - bool testAndSetRelease(T &_q_value, X expectedValue, X newValue, X *currentValue) Q_DECL_NOTHROW + bool testAndSetRelease(T &_q_value, X expectedValue, X newValue, X *currentValue) noexcept { BaseClass::releaseMemoryFence(_q_value); return BaseClass::testAndSetRelaxed(_q_value, expectedValue, newValue, currentValue); } template static Q_ALWAYS_INLINE - bool testAndSetOrdered(T &_q_value, X expectedValue, X newValue, X *currentValue) Q_DECL_NOTHROW + bool testAndSetOrdered(T &_q_value, X expectedValue, X newValue, X *currentValue) noexcept { BaseClass::orderedMemoryFence(_q_value); return BaseClass::testAndSetRelaxed(_q_value, expectedValue, newValue, currentValue); } - static inline Q_DECL_CONSTEXPR bool isFetchAndStoreNative() Q_DECL_NOTHROW { return false; } - static inline Q_DECL_CONSTEXPR bool isFetchAndStoreWaitFree() Q_DECL_NOTHROW { return false; } + static inline Q_DECL_CONSTEXPR bool isFetchAndStoreNative() noexcept { return false; } + static inline Q_DECL_CONSTEXPR bool isFetchAndStoreWaitFree() noexcept { return false; } template static Q_ALWAYS_INLINE - T fetchAndStoreRelaxed(T &_q_value, X newValue) Q_DECL_NOTHROW + T fetchAndStoreRelaxed(T &_q_value, X newValue) noexcept { // implement fetchAndStore on top of testAndSet Q_FOREVER { @@ -197,7 +197,7 @@ template struct QGenericAtomicOps } template static Q_ALWAYS_INLINE - T fetchAndStoreAcquire(T &_q_value, X newValue) Q_DECL_NOTHROW + T fetchAndStoreAcquire(T &_q_value, X newValue) noexcept { T tmp = BaseClass::fetchAndStoreRelaxed(_q_value, newValue); BaseClass::acquireMemoryFence(_q_value); @@ -205,23 +205,23 @@ template struct QGenericAtomicOps } template static Q_ALWAYS_INLINE - T fetchAndStoreRelease(T &_q_value, X newValue) Q_DECL_NOTHROW + T fetchAndStoreRelease(T &_q_value, X newValue) noexcept { BaseClass::releaseMemoryFence(_q_value); return BaseClass::fetchAndStoreRelaxed(_q_value, newValue); } template static Q_ALWAYS_INLINE - T fetchAndStoreOrdered(T &_q_value, X newValue) Q_DECL_NOTHROW + T fetchAndStoreOrdered(T &_q_value, X newValue) noexcept { BaseClass::orderedMemoryFence(_q_value); return BaseClass::fetchAndStoreRelaxed(_q_value, newValue); } - static inline Q_DECL_CONSTEXPR bool isFetchAndAddNative() Q_DECL_NOTHROW { return false; } - static inline Q_DECL_CONSTEXPR bool isFetchAndAddWaitFree() Q_DECL_NOTHROW { return false; } + static inline Q_DECL_CONSTEXPR bool isFetchAndAddNative() noexcept { return false; } + static inline Q_DECL_CONSTEXPR bool isFetchAndAddWaitFree() noexcept { return false; } template static Q_ALWAYS_INLINE - T fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW + T fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) noexcept { // implement fetchAndAdd on top of testAndSet Q_FOREVER { @@ -232,7 +232,7 @@ template struct QGenericAtomicOps } template static Q_ALWAYS_INLINE - T fetchAndAddAcquire(T &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW + T fetchAndAddAcquire(T &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) noexcept { T tmp = BaseClass::fetchAndAddRelaxed(_q_value, valueToAdd); BaseClass::acquireMemoryFence(_q_value); @@ -240,14 +240,14 @@ template struct QGenericAtomicOps } template static Q_ALWAYS_INLINE - T fetchAndAddRelease(T &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW + T fetchAndAddRelease(T &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) noexcept { BaseClass::releaseMemoryFence(_q_value); return BaseClass::fetchAndAddRelaxed(_q_value, valueToAdd); } template static Q_ALWAYS_INLINE - T fetchAndAddOrdered(T &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW + T fetchAndAddOrdered(T &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) noexcept { BaseClass::orderedMemoryFence(_q_value); return BaseClass::fetchAndAddRelaxed(_q_value, valueToAdd); @@ -256,7 +256,7 @@ template struct QGenericAtomicOps QT_WARNING_PUSH QT_WARNING_DISABLE_MSVC(4146) // unary minus operator applied to unsigned type, result still unsigned template static Q_ALWAYS_INLINE - T fetchAndSubRelaxed(T &_q_value, typename QAtomicAdditiveType::AdditiveT operand) Q_DECL_NOTHROW + T fetchAndSubRelaxed(T &_q_value, typename QAtomicAdditiveType::AdditiveT operand) noexcept { // implement fetchAndSub on top of fetchAndAdd return fetchAndAddRelaxed(_q_value, -operand); @@ -264,7 +264,7 @@ QT_WARNING_DISABLE_MSVC(4146) // unary minus operator applied to unsigned type QT_WARNING_POP template static Q_ALWAYS_INLINE - T fetchAndSubAcquire(T &_q_value, typename QAtomicAdditiveType::AdditiveT operand) Q_DECL_NOTHROW + T fetchAndSubAcquire(T &_q_value, typename QAtomicAdditiveType::AdditiveT operand) noexcept { T tmp = BaseClass::fetchAndSubRelaxed(_q_value, operand); BaseClass::acquireMemoryFence(_q_value); @@ -272,21 +272,21 @@ QT_WARNING_POP } template static Q_ALWAYS_INLINE - T fetchAndSubRelease(T &_q_value, typename QAtomicAdditiveType::AdditiveT operand) Q_DECL_NOTHROW + T fetchAndSubRelease(T &_q_value, typename QAtomicAdditiveType::AdditiveT operand) noexcept { BaseClass::releaseMemoryFence(_q_value); return BaseClass::fetchAndSubRelaxed(_q_value, operand); } template static Q_ALWAYS_INLINE - T fetchAndSubOrdered(T &_q_value, typename QAtomicAdditiveType::AdditiveT operand) Q_DECL_NOTHROW + T fetchAndSubOrdered(T &_q_value, typename QAtomicAdditiveType::AdditiveT operand) noexcept { BaseClass::orderedMemoryFence(_q_value); return BaseClass::fetchAndSubRelaxed(_q_value, operand); } template static Q_ALWAYS_INLINE - T fetchAndAndRelaxed(T &_q_value, typename std::enable_if::isIntegral, T>::type operand) Q_DECL_NOTHROW + T fetchAndAndRelaxed(T &_q_value, typename std::enable_if::isIntegral, T>::type operand) noexcept { // implement fetchAndAnd on top of testAndSet T tmp = BaseClass::load(_q_value); @@ -297,7 +297,7 @@ QT_WARNING_POP } template static Q_ALWAYS_INLINE - T fetchAndAndAcquire(T &_q_value, typename std::enable_if::isIntegral, T>::type operand) Q_DECL_NOTHROW + T fetchAndAndAcquire(T &_q_value, typename std::enable_if::isIntegral, T>::type operand) noexcept { T tmp = BaseClass::fetchAndAndRelaxed(_q_value, operand); BaseClass::acquireMemoryFence(_q_value); @@ -305,21 +305,21 @@ QT_WARNING_POP } template static Q_ALWAYS_INLINE - T fetchAndAndRelease(T &_q_value, typename std::enable_if::isIntegral, T>::type operand) Q_DECL_NOTHROW + T fetchAndAndRelease(T &_q_value, typename std::enable_if::isIntegral, T>::type operand) noexcept { BaseClass::releaseMemoryFence(_q_value); return BaseClass::fetchAndAndRelaxed(_q_value, operand); } template static Q_ALWAYS_INLINE - T fetchAndAndOrdered(T &_q_value, typename std::enable_if::isIntegral, T>::type operand) Q_DECL_NOTHROW + T fetchAndAndOrdered(T &_q_value, typename std::enable_if::isIntegral, T>::type operand) noexcept { BaseClass::orderedMemoryFence(_q_value); return BaseClass::fetchAndAndRelaxed(_q_value, operand); } template static Q_ALWAYS_INLINE - T fetchAndOrRelaxed(T &_q_value, typename std::enable_if::isIntegral, T>::type operand) Q_DECL_NOTHROW + T fetchAndOrRelaxed(T &_q_value, typename std::enable_if::isIntegral, T>::type operand) noexcept { // implement fetchAndOr on top of testAndSet T tmp = BaseClass::load(_q_value); @@ -330,7 +330,7 @@ QT_WARNING_POP } template static Q_ALWAYS_INLINE - T fetchAndOrAcquire(T &_q_value, typename std::enable_if::isIntegral, T>::type operand) Q_DECL_NOTHROW + T fetchAndOrAcquire(T &_q_value, typename std::enable_if::isIntegral, T>::type operand) noexcept { T tmp = BaseClass::fetchAndOrRelaxed(_q_value, operand); BaseClass::acquireMemoryFence(_q_value); @@ -338,21 +338,21 @@ QT_WARNING_POP } template static Q_ALWAYS_INLINE - T fetchAndOrRelease(T &_q_value, typename std::enable_if::isIntegral, T>::type operand) Q_DECL_NOTHROW + T fetchAndOrRelease(T &_q_value, typename std::enable_if::isIntegral, T>::type operand) noexcept { BaseClass::releaseMemoryFence(_q_value); return BaseClass::fetchAndOrRelaxed(_q_value, operand); } template static Q_ALWAYS_INLINE - T fetchAndOrOrdered(T &_q_value, typename std::enable_if::isIntegral, T>::type operand) Q_DECL_NOTHROW + T fetchAndOrOrdered(T &_q_value, typename std::enable_if::isIntegral, T>::type operand) noexcept { BaseClass::orderedMemoryFence(_q_value); return BaseClass::fetchAndOrRelaxed(_q_value, operand); } template static Q_ALWAYS_INLINE - T fetchAndXorRelaxed(T &_q_value, typename std::enable_if::isIntegral, T>::type operand) Q_DECL_NOTHROW + T fetchAndXorRelaxed(T &_q_value, typename std::enable_if::isIntegral, T>::type operand) noexcept { // implement fetchAndXor on top of testAndSet T tmp = BaseClass::load(_q_value); @@ -363,7 +363,7 @@ QT_WARNING_POP } template static Q_ALWAYS_INLINE - T fetchAndXorAcquire(T &_q_value, typename std::enable_if::isIntegral, T>::type operand) Q_DECL_NOTHROW + T fetchAndXorAcquire(T &_q_value, typename std::enable_if::isIntegral, T>::type operand) noexcept { T tmp = BaseClass::fetchAndXorRelaxed(_q_value, operand); BaseClass::acquireMemoryFence(_q_value); @@ -371,14 +371,14 @@ QT_WARNING_POP } template static Q_ALWAYS_INLINE - T fetchAndXorRelease(T &_q_value, typename std::enable_if::isIntegral, T>::type operand) Q_DECL_NOTHROW + T fetchAndXorRelease(T &_q_value, typename std::enable_if::isIntegral, T>::type operand) noexcept { BaseClass::releaseMemoryFence(_q_value); return BaseClass::fetchAndXorRelaxed(_q_value, operand); } template static Q_ALWAYS_INLINE - T fetchAndXorOrdered(T &_q_value, typename std::enable_if::isIntegral, T>::type operand) Q_DECL_NOTHROW + T fetchAndXorOrdered(T &_q_value, typename std::enable_if::isIntegral, T>::type operand) noexcept { BaseClass::orderedMemoryFence(_q_value); return BaseClass::fetchAndXorRelaxed(_q_value, operand); diff --git a/src/corelib/thread/qmutex.cpp b/src/corelib/thread/qmutex.cpp index 3881ac017e..4f55e50fe5 100644 --- a/src/corelib/thread/qmutex.cpp +++ b/src/corelib/thread/qmutex.cpp @@ -82,7 +82,7 @@ public: QMutex mutex; bool lock(int timeout) QT_MUTEX_LOCK_NOEXCEPT; - void unlock() Q_DECL_NOTHROW; + void unlock() noexcept; }; /* @@ -329,7 +329,7 @@ bool QMutex::tryLock(int timeout) QT_MUTEX_LOCK_NOEXCEPT \sa lock() */ -void QMutex::unlock() Q_DECL_NOTHROW +void QMutex::unlock() noexcept { QMutexData *current; if (fastTryUnlock(current)) @@ -348,7 +348,7 @@ void QMutex::unlock() Q_DECL_NOTHROW Returns \c true if the mutex is recursive. */ -bool QBasicMutex::isRecursive() Q_DECL_NOTHROW +bool QBasicMutex::isRecursive() noexcept { return QT_PREPEND_NAMESPACE(isRecursive)(d_ptr.loadAcquire()); } @@ -358,7 +358,7 @@ bool QBasicMutex::isRecursive() Q_DECL_NOTHROW Returns \c true if the mutex is recursive. */ -bool QBasicMutex::isRecursive() const Q_DECL_NOTHROW +bool QBasicMutex::isRecursive() const noexcept { return QT_PREPEND_NAMESPACE(isRecursive)(d_ptr.loadAcquire()); } @@ -600,7 +600,7 @@ bool QBasicMutex::lockInternal(int timeout) QT_MUTEX_LOCK_NOEXCEPT /*! \internal */ -void QBasicMutex::unlockInternal() Q_DECL_NOTHROW +void QBasicMutex::unlockInternal() noexcept { QMutexData *copy = d_ptr.loadAcquire(); Q_ASSERT(copy); //we must be locked @@ -675,7 +675,7 @@ void QMutexPrivate::release() } // atomically subtract "value" to the waiters, and remove the QMutexPrivate::BigNumber flag -void QMutexPrivate::derefWaiters(int value) Q_DECL_NOTHROW +void QMutexPrivate::derefWaiters(int value) noexcept { int old_waiters; int new_waiters; @@ -716,7 +716,7 @@ inline bool QRecursiveMutexPrivate::lock(int timeout) QT_MUTEX_LOCK_NOEXCEPT /*! \internal */ -inline void QRecursiveMutexPrivate::unlock() Q_DECL_NOTHROW +inline void QRecursiveMutexPrivate::unlock() noexcept { if (count > 0) { count--; diff --git a/src/corelib/thread/qmutex.h b/src/corelib/thread/qmutex.h index 837355a602..d7796092d1 100644 --- a/src/corelib/thread/qmutex.h +++ b/src/corelib/thread/qmutex.h @@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE #if QT_CONFIG(thread) || defined(Q_CLANG_QDOC) #ifdef Q_OS_LINUX -# define QT_MUTEX_LOCK_NOEXCEPT Q_DECL_NOTHROW +# define QT_MUTEX_LOCK_NOEXCEPT noexcept #else # define QT_MUTEX_LOCK_NOEXCEPT #endif @@ -80,39 +80,39 @@ public: } // BasicLockable concept - inline void unlock() Q_DECL_NOTHROW { + inline void unlock() noexcept { Q_ASSERT(d_ptr.load()); //mutex must be locked if (!fastTryUnlock()) unlockInternal(); } - bool tryLock() Q_DECL_NOTHROW { + bool tryLock() noexcept { return fastTryLock(); } // Lockable concept - bool try_lock() Q_DECL_NOTHROW { return tryLock(); } + bool try_lock() noexcept { return tryLock(); } - bool isRecursive() Q_DECL_NOTHROW; //### Qt6: remove me - bool isRecursive() const Q_DECL_NOTHROW; + bool isRecursive() noexcept; //### Qt6: remove me + bool isRecursive() const noexcept; private: - inline bool fastTryLock() Q_DECL_NOTHROW { + inline bool fastTryLock() noexcept { return d_ptr.testAndSetAcquire(nullptr, dummyLocked()); } - inline bool fastTryUnlock() Q_DECL_NOTHROW { + inline bool fastTryUnlock() noexcept { return d_ptr.testAndSetRelease(dummyLocked(), nullptr); } - inline bool fastTryLock(QMutexData *¤t) Q_DECL_NOTHROW { + inline bool fastTryLock(QMutexData *¤t) noexcept { return d_ptr.testAndSetAcquire(nullptr, dummyLocked(), current); } - inline bool fastTryUnlock(QMutexData *¤t) Q_DECL_NOTHROW { + inline bool fastTryUnlock(QMutexData *¤t) noexcept { return d_ptr.testAndSetRelease(dummyLocked(), nullptr, current); } void lockInternal() QT_MUTEX_LOCK_NOEXCEPT; bool lockInternal(int timeout) QT_MUTEX_LOCK_NOEXCEPT; - void unlockInternal() Q_DECL_NOTHROW; + void unlockInternal() noexcept; QBasicAtomicPointer d_ptr; static inline QMutexData *dummyLocked() { @@ -134,7 +134,7 @@ public: void lock() QT_MUTEX_LOCK_NOEXCEPT; bool tryLock(int timeout = 0) QT_MUTEX_LOCK_NOEXCEPT; // BasicLockable concept - void unlock() Q_DECL_NOTHROW; + void unlock() noexcept; // Lockable concept bool try_lock() QT_MUTEX_LOCK_NOEXCEPT { return tryLock(); } @@ -158,7 +158,7 @@ public: } #endif - bool isRecursive() const Q_DECL_NOTHROW + bool isRecursive() const noexcept { return QBasicMutex::isRecursive(); } private: @@ -212,7 +212,7 @@ public: #endif inline ~QMutexLocker() { unlock(); } - inline void unlock() Q_DECL_NOTHROW + inline void unlock() noexcept { if ((val & quintptr(1u)) == quintptr(1u)) { val &= ~quintptr(1u); @@ -257,24 +257,24 @@ class Q_CORE_EXPORT QMutex public: enum RecursionMode { NonRecursive, Recursive }; - inline Q_DECL_CONSTEXPR explicit QMutex(RecursionMode = NonRecursive) Q_DECL_NOTHROW { } + inline Q_DECL_CONSTEXPR explicit QMutex(RecursionMode = NonRecursive) noexcept { } - inline void lock() Q_DECL_NOTHROW {} - inline bool tryLock(int timeout = 0) Q_DECL_NOTHROW { Q_UNUSED(timeout); return true; } - inline bool try_lock() Q_DECL_NOTHROW { return true; } - inline void unlock() Q_DECL_NOTHROW {} - inline bool isRecursive() const Q_DECL_NOTHROW { return true; } + inline void lock() noexcept {} + inline bool tryLock(int timeout = 0) noexcept { Q_UNUSED(timeout); return true; } + inline bool try_lock() noexcept { return true; } + inline void unlock() noexcept {} + inline bool isRecursive() const noexcept { return true; } #if QT_HAS_INCLUDE() template - inline bool try_lock_for(std::chrono::duration duration) Q_DECL_NOTHROW + inline bool try_lock_for(std::chrono::duration duration) noexcept { Q_UNUSED(duration); return true; } template - inline bool try_lock_until(std::chrono::time_point timePoint) Q_DECL_NOTHROW + inline bool try_lock_until(std::chrono::time_point timePoint) noexcept { Q_UNUSED(timePoint); return true; @@ -288,12 +288,12 @@ private: class Q_CORE_EXPORT QMutexLocker { public: - inline explicit QMutexLocker(QMutex *) Q_DECL_NOTHROW {} - inline ~QMutexLocker() Q_DECL_NOTHROW {} + inline explicit QMutexLocker(QMutex *) noexcept {} + inline ~QMutexLocker() noexcept {} - inline void unlock() Q_DECL_NOTHROW {} - void relock() Q_DECL_NOTHROW {} - inline QMutex *mutex() const Q_DECL_NOTHROW { return nullptr; } + inline void unlock() noexcept {} + void relock() noexcept {} + inline QMutex *mutex() const noexcept { return nullptr; } private: Q_DISABLE_COPY(QMutexLocker) diff --git a/src/corelib/thread/qmutex_linux.cpp b/src/corelib/thread/qmutex_linux.cpp index 507e72cb76..b006ff1033 100644 --- a/src/corelib/thread/qmutex_linux.cpp +++ b/src/corelib/thread/qmutex_linux.cpp @@ -106,7 +106,7 @@ static inline QMutexData *dummyFutexValue() } template static inline -bool lockInternal_helper(QBasicAtomicPointer &d_ptr, int timeout = -1, QElapsedTimer *elapsedTimer = 0) Q_DECL_NOTHROW +bool lockInternal_helper(QBasicAtomicPointer &d_ptr, int timeout = -1, QElapsedTimer *elapsedTimer = 0) noexcept { if (!IsTimed) timeout = -1; @@ -153,13 +153,13 @@ bool lockInternal_helper(QBasicAtomicPointer &d_ptr, int timeout = - return true; } -void QBasicMutex::lockInternal() Q_DECL_NOTHROW +void QBasicMutex::lockInternal() noexcept { Q_ASSERT(!isRecursive()); lockInternal_helper(d_ptr); } -bool QBasicMutex::lockInternal(int timeout) Q_DECL_NOTHROW +bool QBasicMutex::lockInternal(int timeout) noexcept { Q_ASSERT(!isRecursive()); QElapsedTimer elapsedTimer; @@ -167,7 +167,7 @@ bool QBasicMutex::lockInternal(int timeout) Q_DECL_NOTHROW return lockInternal_helper(d_ptr, timeout, &elapsedTimer); } -void QBasicMutex::unlockInternal() Q_DECL_NOTHROW +void QBasicMutex::unlockInternal() noexcept { QMutexData *d = d_ptr.load(); Q_ASSERT(d); //we must be locked diff --git a/src/corelib/thread/qmutex_mac.cpp b/src/corelib/thread/qmutex_mac.cpp index 9a8d9bc750..923f89f697 100644 --- a/src/corelib/thread/qmutex_mac.cpp +++ b/src/corelib/thread/qmutex_mac.cpp @@ -79,7 +79,7 @@ bool QMutexPrivate::wait(int timeout) return (r == KERN_SUCCESS); } -void QMutexPrivate::wakeUp() Q_DECL_NOTHROW +void QMutexPrivate::wakeUp() noexcept { semaphore_signal(mach_semaphore); } diff --git a/src/corelib/thread/qmutex_p.h b/src/corelib/thread/qmutex_p.h index ec9bfc1152..5025f836b9 100644 --- a/src/corelib/thread/qmutex_p.h +++ b/src/corelib/thread/qmutex_p.h @@ -92,7 +92,7 @@ public: QMutexPrivate(); bool wait(int timeout = -1); - void wakeUp() Q_DECL_NOTHROW; + void wakeUp() noexcept; // Control the lifetime of the privates QAtomicInt refCount; @@ -125,7 +125,7 @@ public: when the mutex is unlocked. */ enum { BigNumber = 0x100000 }; //Must be bigger than the possible number of waiters (number of threads) - void derefWaiters(int value) Q_DECL_NOTHROW; + void derefWaiters(int value) noexcept; //platform specific stuff #if defined(Q_OS_MAC) diff --git a/src/corelib/thread/qmutex_unix.cpp b/src/corelib/thread/qmutex_unix.cpp index 3ee24a292c..a92ac4f943 100644 --- a/src/corelib/thread/qmutex_unix.cpp +++ b/src/corelib/thread/qmutex_unix.cpp @@ -99,7 +99,7 @@ bool QMutexPrivate::wait(int timeout) return true; } -void QMutexPrivate::wakeUp() Q_DECL_NOTHROW +void QMutexPrivate::wakeUp() noexcept { report_error(sem_post(&semaphore), "QMutex::unlock", "sem_post"); } @@ -146,7 +146,7 @@ bool QMutexPrivate::wait(int timeout) return ret; } -void QMutexPrivate::wakeUp() Q_DECL_NOTHROW +void QMutexPrivate::wakeUp() noexcept { report_error(pthread_mutex_lock(&mutex), "QMutex::unlock", "mutex lock"); wakeup = true; diff --git a/src/corelib/thread/qmutex_win.cpp b/src/corelib/thread/qmutex_win.cpp index 3c314a4c0c..e221bc89cb 100644 --- a/src/corelib/thread/qmutex_win.cpp +++ b/src/corelib/thread/qmutex_win.cpp @@ -64,7 +64,7 @@ bool QMutexPrivate::wait(int timeout) return (WaitForSingleObjectEx(event, timeout < 0 ? INFINITE : timeout, FALSE) == WAIT_OBJECT_0); } -void QMutexPrivate::wakeUp() Q_DECL_NOTHROW +void QMutexPrivate::wakeUp() noexcept { SetEvent(event); } QT_END_NAMESPACE diff --git a/src/corelib/thread/qorderedmutexlocker_p.h b/src/corelib/thread/qorderedmutexlocker_p.h index 5b2c7ab112..e0a67388d4 100644 --- a/src/corelib/thread/qorderedmutexlocker_p.h +++ b/src/corelib/thread/qorderedmutexlocker_p.h @@ -129,7 +129,7 @@ public: } inline ~QBasicMutexLocker() { if (isLocked) unlock(); } - inline void unlock() Q_DECL_NOTHROW + inline void unlock() noexcept { isLocked = false; m->unlock(); diff --git a/src/corelib/thread/qreadwritelock.h b/src/corelib/thread/qreadwritelock.h index 65fa76fd6d..139fde9214 100644 --- a/src/corelib/thread/qreadwritelock.h +++ b/src/corelib/thread/qreadwritelock.h @@ -180,18 +180,18 @@ class Q_CORE_EXPORT QReadWriteLock { public: enum RecursionMode { NonRecursive, Recursive }; - inline explicit QReadWriteLock(RecursionMode = NonRecursive) Q_DECL_NOTHROW { } + inline explicit QReadWriteLock(RecursionMode = NonRecursive) noexcept { } inline ~QReadWriteLock() { } - static inline void lockForRead() Q_DECL_NOTHROW { } - static inline bool tryLockForRead() Q_DECL_NOTHROW { return true; } - static inline bool tryLockForRead(int timeout) Q_DECL_NOTHROW { Q_UNUSED(timeout); return true; } + static inline void lockForRead() noexcept { } + static inline bool tryLockForRead() noexcept { return true; } + static inline bool tryLockForRead(int timeout) noexcept { Q_UNUSED(timeout); return true; } - static inline void lockForWrite() Q_DECL_NOTHROW { } - static inline bool tryLockForWrite() Q_DECL_NOTHROW { return true; } - static inline bool tryLockForWrite(int timeout) Q_DECL_NOTHROW { Q_UNUSED(timeout); return true; } + static inline void lockForWrite() noexcept { } + static inline bool tryLockForWrite() noexcept { return true; } + static inline bool tryLockForWrite(int timeout) noexcept { Q_UNUSED(timeout); return true; } - static inline void unlock() Q_DECL_NOTHROW { } + static inline void unlock() noexcept { } private: Q_DISABLE_COPY(QReadWriteLock) @@ -200,12 +200,12 @@ private: class Q_CORE_EXPORT QReadLocker { public: - inline QReadLocker(QReadWriteLock *) Q_DECL_NOTHROW { } - inline ~QReadLocker() Q_DECL_NOTHROW { } + inline QReadLocker(QReadWriteLock *) noexcept { } + inline ~QReadLocker() noexcept { } - static inline void unlock() Q_DECL_NOTHROW { } - static inline void relock() Q_DECL_NOTHROW { } - static inline QReadWriteLock *readWriteLock() Q_DECL_NOTHROW { return nullptr; } + static inline void unlock() noexcept { } + static inline void relock() noexcept { } + static inline QReadWriteLock *readWriteLock() noexcept { return nullptr; } private: Q_DISABLE_COPY(QReadLocker) @@ -214,12 +214,12 @@ private: class Q_CORE_EXPORT QWriteLocker { public: - inline explicit QWriteLocker(QReadWriteLock *) Q_DECL_NOTHROW { } - inline ~QWriteLocker() Q_DECL_NOTHROW { } + inline explicit QWriteLocker(QReadWriteLock *) noexcept { } + inline ~QWriteLocker() noexcept { } - static inline void unlock() Q_DECL_NOTHROW { } - static inline void relock() Q_DECL_NOTHROW { } - static inline QReadWriteLock *readWriteLock() Q_DECL_NOTHROW { return nullptr; } + static inline void unlock() noexcept { } + static inline void relock() noexcept { } + static inline QReadWriteLock *readWriteLock() noexcept { return nullptr; } private: Q_DISABLE_COPY(QWriteLocker) diff --git a/src/corelib/thread/qsemaphore.h b/src/corelib/thread/qsemaphore.h index b830ff1bfd..58c12997ad 100644 --- a/src/corelib/thread/qsemaphore.h +++ b/src/corelib/thread/qsemaphore.h @@ -75,14 +75,14 @@ class QSemaphoreReleaser { public: QSemaphoreReleaser() = default; - explicit QSemaphoreReleaser(QSemaphore &sem, int n = 1) Q_DECL_NOTHROW + explicit QSemaphoreReleaser(QSemaphore &sem, int n = 1) noexcept : m_sem(&sem), m_n(n) {} - explicit QSemaphoreReleaser(QSemaphore *sem, int n = 1) Q_DECL_NOTHROW + explicit QSemaphoreReleaser(QSemaphore *sem, int n = 1) noexcept : m_sem(sem), m_n(n) {} - QSemaphoreReleaser(QSemaphoreReleaser &&other) Q_DECL_NOTHROW + QSemaphoreReleaser(QSemaphoreReleaser &&other) noexcept : m_sem(other.m_sem), m_n(other.m_n) { other.m_sem = nullptr; } - QSemaphoreReleaser &operator=(QSemaphoreReleaser &&other) Q_DECL_NOTHROW + QSemaphoreReleaser &operator=(QSemaphoreReleaser &&other) noexcept { QSemaphoreReleaser moved(std::move(other)); swap(moved); return *this; } ~QSemaphoreReleaser() @@ -91,16 +91,16 @@ public: m_sem->release(m_n); } - void swap(QSemaphoreReleaser &other) Q_DECL_NOTHROW + void swap(QSemaphoreReleaser &other) noexcept { qSwap(m_sem, other.m_sem); qSwap(m_n, other.m_n); } - QSemaphore *semaphore() const Q_DECL_NOTHROW + QSemaphore *semaphore() const noexcept { return m_sem; } - QSemaphore *cancel() Q_DECL_NOTHROW + QSemaphore *cancel() noexcept { QSemaphore *old = m_sem; m_sem = nullptr; diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp index b023ae9ed2..170cd0dec4 100644 --- a/src/corelib/thread/qthread.cpp +++ b/src/corelib/thread/qthread.cpp @@ -839,7 +839,7 @@ bool QThread::event(QEvent* event) return QObject::event(event); } -Qt::HANDLE QThread::currentThreadId() Q_DECL_NOTHROW +Qt::HANDLE QThread::currentThreadId() noexcept { return Qt::HANDLE(currentThread()); } @@ -849,7 +849,7 @@ QThread *QThread::currentThread() return QThreadData::current()->thread; } -int QThread::idealThreadCount() Q_DECL_NOTHROW +int QThread::idealThreadCount() noexcept { return 1; } diff --git a/src/corelib/thread/qthread.h b/src/corelib/thread/qthread.h index b6c5bf47d0..8e92d75401 100644 --- a/src/corelib/thread/qthread.h +++ b/src/corelib/thread/qthread.h @@ -70,9 +70,9 @@ class Q_CORE_EXPORT QThread : public QObject { Q_OBJECT public: - static Qt::HANDLE currentThreadId() Q_DECL_NOTHROW Q_DECL_PURE_FUNCTION; + static Qt::HANDLE currentThreadId() noexcept Q_DECL_PURE_FUNCTION; static QThread *currentThread(); - static int idealThreadCount() Q_DECL_NOTHROW; + static int idealThreadCount() noexcept; static void yieldCurrentThread(); explicit QThread(QObject *parent = nullptr); diff --git a/src/corelib/thread/qthread_p.h b/src/corelib/thread/qthread_p.h index e614ddd004..209225de98 100644 --- a/src/corelib/thread/qthread_p.h +++ b/src/corelib/thread/qthread_p.h @@ -187,8 +187,8 @@ public: #endif // Q_OS_UNIX #ifdef Q_OS_WIN - static unsigned int __stdcall start(void *) Q_DECL_NOEXCEPT; - static void finish(void *, bool lockAnyway=true) Q_DECL_NOEXCEPT; + static unsigned int __stdcall start(void *) noexcept; + static void finish(void *, bool lockAnyway=true) noexcept; Qt::HANDLE handle; unsigned int id; diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp index a13f8ca215..8328e514a8 100644 --- a/src/corelib/thread/qthread_unix.cpp +++ b/src/corelib/thread/qthread_unix.cpp @@ -443,7 +443,7 @@ void QThreadPrivate::finish(void *arg) ** QThread *************************************************************************/ -Qt::HANDLE QThread::currentThreadId() Q_DECL_NOTHROW +Qt::HANDLE QThread::currentThreadId() noexcept { // requires a C cast here otherwise we run into trouble on AIX return to_HANDLE(pthread_self()); @@ -454,7 +454,7 @@ Qt::HANDLE QThread::currentThreadId() Q_DECL_NOTHROW # define _SC_NPROCESSORS_ONLN 84 #endif -int QThread::idealThreadCount() Q_DECL_NOTHROW +int QThread::idealThreadCount() noexcept { int cores = 1; diff --git a/src/corelib/thread/qthread_win.cpp b/src/corelib/thread/qthread_win.cpp index e56fe2c6ae..ee73280707 100644 --- a/src/corelib/thread/qthread_win.cpp +++ b/src/corelib/thread/qthread_win.cpp @@ -372,7 +372,7 @@ QAbstractEventDispatcher *QThreadPrivate::createEventDispatcher(QThreadData *dat #if QT_CONFIG(thread) -unsigned int __stdcall QT_ENSURE_STACK_ALIGNED_FOR_SSE QThreadPrivate::start(void *arg) Q_DECL_NOEXCEPT +unsigned int __stdcall QT_ENSURE_STACK_ALIGNED_FOR_SSE QThreadPrivate::start(void *arg) noexcept { QThread *thr = reinterpret_cast(arg); QThreadData *data = QThreadData::get2(thr); @@ -406,7 +406,7 @@ unsigned int __stdcall QT_ENSURE_STACK_ALIGNED_FOR_SSE QThreadPrivate::start(voi return 0; } -void QThreadPrivate::finish(void *arg, bool lockAnyway) Q_DECL_NOEXCEPT +void QThreadPrivate::finish(void *arg, bool lockAnyway) noexcept { QThread *thr = reinterpret_cast(arg); QThreadPrivate *d = thr->d_func(); @@ -447,12 +447,12 @@ void QThreadPrivate::finish(void *arg, bool lockAnyway) Q_DECL_NOEXCEPT ** QThread *************************************************************************/ -Qt::HANDLE QThread::currentThreadId() Q_DECL_NOTHROW +Qt::HANDLE QThread::currentThreadId() noexcept { return reinterpret_cast(quintptr(GetCurrentThreadId())); } -int QThread::idealThreadCount() Q_DECL_NOTHROW +int QThread::idealThreadCount() noexcept { SYSTEM_INFO sysinfo; #ifndef Q_OS_WINRT diff --git a/src/corelib/tools/qalgorithms.h b/src/corelib/tools/qalgorithms.h index 0146e22fa3..f1243b5c61 100644 --- a/src/corelib/tools/qalgorithms.h +++ b/src/corelib/tools/qalgorithms.h @@ -533,7 +533,7 @@ QT_DEPRECATED_X("Use std::binary_search") Q_OUTOFLINE_TEMPLATE RandomAccessItera #if defined QT_HAS_CONSTEXPR_BUILTINS #if defined(Q_CC_GNU) || defined(Q_CC_CLANG) # define QT_HAS_BUILTIN_CTZS -Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_ctzs(quint16 v) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_ctzs(quint16 v) noexcept { # if QT_HAS_BUILTIN(__builtin_ctzs) return __builtin_ctzs(v); @@ -542,7 +542,7 @@ Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_ctzs(quint16 v) Q_DECL_NOTHROW # endif } #define QT_HAS_BUILTIN_CLZS -Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_clzs(quint16 v) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_clzs(quint16 v) noexcept { # if QT_HAS_BUILTIN(__builtin_clzs) return __builtin_clzs(v); @@ -551,40 +551,40 @@ Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_clzs(quint16 v) Q_DECL_NOTHROW # endif } #define QT_HAS_BUILTIN_CTZ -Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_ctz(quint32 v) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_ctz(quint32 v) noexcept { return __builtin_ctz(v); } #define QT_HAS_BUILTIN_CLZ -Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_clz(quint32 v) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_clz(quint32 v) noexcept { return __builtin_clz(v); } #define QT_HAS_BUILTIN_CTZLL -Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_ctzll(quint64 v) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_ctzll(quint64 v) noexcept { return __builtin_ctzll(v); } #define QT_HAS_BUILTIN_CLZLL -Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_clzll(quint64 v) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_clzll(quint64 v) noexcept { return __builtin_clzll(v); } #define QALGORITHMS_USE_BUILTIN_POPCOUNT -Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_popcount(quint32 v) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_popcount(quint32 v) noexcept { return __builtin_popcount(v); } -Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_popcount(quint8 v) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_popcount(quint8 v) noexcept { return __builtin_popcount(v); } -Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_popcount(quint16 v) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_popcount(quint16 v) noexcept { return __builtin_popcount(v); } #define QALGORITHMS_USE_BUILTIN_POPCOUNTLL -Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_popcountll(quint64 v) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_popcountll(quint64 v) noexcept { return __builtin_popcountll(v); } @@ -630,12 +630,12 @@ Q_ALWAYS_INLINE unsigned long qt_builtin_clzll(quint64 val) } #endif // MSVC 64bit # define QT_HAS_BUILTIN_CTZS -Q_ALWAYS_INLINE uint qt_builtin_ctzs(quint16 v) Q_DECL_NOTHROW +Q_ALWAYS_INLINE uint qt_builtin_ctzs(quint16 v) noexcept { return qt_builtin_ctz(v); } #define QT_HAS_BUILTIN_CLZS -Q_ALWAYS_INLINE uint qt_builtin_clzs(quint16 v) Q_DECL_NOTHROW +Q_ALWAYS_INLINE uint qt_builtin_clzs(quint16 v) noexcept { return qt_builtin_clz(v) - 16U; } @@ -652,19 +652,19 @@ Q_ALWAYS_INLINE uint qt_builtin_clzs(quint16 v) Q_DECL_NOTHROW #if defined(__AVX__) || defined(__SSE4_2__) || defined(__POPCNT__) #define QALGORITHMS_USE_BUILTIN_POPCOUNT #define QALGORITHMS_USE_BUILTIN_POPCOUNTLL -Q_ALWAYS_INLINE uint qt_builtin_popcount(quint32 v) Q_DECL_NOTHROW +Q_ALWAYS_INLINE uint qt_builtin_popcount(quint32 v) noexcept { return __popcnt(v); } -Q_ALWAYS_INLINE uint qt_builtin_popcount(quint8 v) Q_DECL_NOTHROW +Q_ALWAYS_INLINE uint qt_builtin_popcount(quint8 v) noexcept { return __popcnt16(v); } -Q_ALWAYS_INLINE uint qt_builtin_popcount(quint16 v) Q_DECL_NOTHROW +Q_ALWAYS_INLINE uint qt_builtin_popcount(quint16 v) noexcept { return __popcnt16(v); } -Q_ALWAYS_INLINE uint qt_builtin_popcountll(quint64 v) Q_DECL_NOTHROW +Q_ALWAYS_INLINE uint qt_builtin_popcountll(quint64 v) noexcept { #if Q_PROCESSOR_WORDSIZE == 8 return __popcnt64(v); @@ -685,7 +685,7 @@ Q_ALWAYS_INLINE uint qt_builtin_popcountll(quint64 v) Q_DECL_NOTHROW } //namespace QAlgorithmsPrivate -Q_DECL_CONST_FUNCTION QT_POPCOUNT_CONSTEXPR inline uint qPopulationCount(quint32 v) Q_DECL_NOTHROW +Q_DECL_CONST_FUNCTION QT_POPCOUNT_CONSTEXPR inline uint qPopulationCount(quint32 v) noexcept { #ifdef QALGORITHMS_USE_BUILTIN_POPCOUNT return QAlgorithmsPrivate::qt_builtin_popcount(v); @@ -698,7 +698,7 @@ Q_DECL_CONST_FUNCTION QT_POPCOUNT_CONSTEXPR inline uint qPopulationCount(quint32 #endif } -Q_DECL_CONST_FUNCTION QT_POPCOUNT_CONSTEXPR inline uint qPopulationCount(quint8 v) Q_DECL_NOTHROW +Q_DECL_CONST_FUNCTION QT_POPCOUNT_CONSTEXPR inline uint qPopulationCount(quint8 v) noexcept { #ifdef QALGORITHMS_USE_BUILTIN_POPCOUNT return QAlgorithmsPrivate::qt_builtin_popcount(v); @@ -708,7 +708,7 @@ Q_DECL_CONST_FUNCTION QT_POPCOUNT_CONSTEXPR inline uint qPopulationCount(quint8 #endif } -Q_DECL_CONST_FUNCTION QT_POPCOUNT_CONSTEXPR inline uint qPopulationCount(quint16 v) Q_DECL_NOTHROW +Q_DECL_CONST_FUNCTION QT_POPCOUNT_CONSTEXPR inline uint qPopulationCount(quint16 v) noexcept { #ifdef QALGORITHMS_USE_BUILTIN_POPCOUNT return QAlgorithmsPrivate::qt_builtin_popcount(v); @@ -719,7 +719,7 @@ Q_DECL_CONST_FUNCTION QT_POPCOUNT_CONSTEXPR inline uint qPopulationCount(quint16 #endif } -Q_DECL_CONST_FUNCTION QT_POPCOUNT_CONSTEXPR inline uint qPopulationCount(quint64 v) Q_DECL_NOTHROW +Q_DECL_CONST_FUNCTION QT_POPCOUNT_CONSTEXPR inline uint qPopulationCount(quint64 v) noexcept { #ifdef QALGORITHMS_USE_BUILTIN_POPCOUNTLL return QAlgorithmsPrivate::qt_builtin_popcountll(v); @@ -734,7 +734,7 @@ Q_DECL_CONST_FUNCTION QT_POPCOUNT_CONSTEXPR inline uint qPopulationCount(quint64 #endif } -Q_DECL_CONST_FUNCTION QT_POPCOUNT_CONSTEXPR inline uint qPopulationCount(long unsigned int v) Q_DECL_NOTHROW +Q_DECL_CONST_FUNCTION QT_POPCOUNT_CONSTEXPR inline uint qPopulationCount(long unsigned int v) noexcept { return qPopulationCount(static_cast(v)); } @@ -744,7 +744,7 @@ Q_DECL_CONST_FUNCTION QT_POPCOUNT_CONSTEXPR inline uint qPopulationCount(long un #endif #undef QT_POPCOUNT_CONSTEXPR -Q_DECL_RELAXED_CONSTEXPR inline uint qCountTrailingZeroBits(quint32 v) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline uint qCountTrailingZeroBits(quint32 v) noexcept { #if defined(QT_HAS_BUILTIN_CTZ) return v ? QAlgorithmsPrivate::qt_builtin_ctz(v) : 32U; @@ -762,7 +762,7 @@ Q_DECL_RELAXED_CONSTEXPR inline uint qCountTrailingZeroBits(quint32 v) Q_DECL_NO #endif } -Q_DECL_RELAXED_CONSTEXPR inline uint qCountTrailingZeroBits(quint8 v) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline uint qCountTrailingZeroBits(quint8 v) noexcept { #if defined(QT_HAS_BUILTIN_CTZ) return v ? QAlgorithmsPrivate::qt_builtin_ctz(v) : 8U; @@ -777,7 +777,7 @@ Q_DECL_RELAXED_CONSTEXPR inline uint qCountTrailingZeroBits(quint8 v) Q_DECL_NOT #endif } -Q_DECL_RELAXED_CONSTEXPR inline uint qCountTrailingZeroBits(quint16 v) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline uint qCountTrailingZeroBits(quint16 v) noexcept { #if defined(QT_HAS_BUILTIN_CTZS) return v ? QAlgorithmsPrivate::qt_builtin_ctzs(v) : 16U; @@ -793,7 +793,7 @@ Q_DECL_RELAXED_CONSTEXPR inline uint qCountTrailingZeroBits(quint16 v) Q_DECL_NO #endif } -Q_DECL_RELAXED_CONSTEXPR inline uint qCountTrailingZeroBits(quint64 v) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline uint qCountTrailingZeroBits(quint64 v) noexcept { #if defined(QT_HAS_BUILTIN_CTZLL) return v ? QAlgorithmsPrivate::qt_builtin_ctzll(v) : 64; @@ -804,12 +804,12 @@ Q_DECL_RELAXED_CONSTEXPR inline uint qCountTrailingZeroBits(quint64 v) Q_DECL_NO #endif } -Q_DECL_RELAXED_CONSTEXPR inline uint qCountTrailingZeroBits(unsigned long v) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline uint qCountTrailingZeroBits(unsigned long v) noexcept { return qCountTrailingZeroBits(QIntegerForSizeof::Unsigned(v)); } -Q_DECL_RELAXED_CONSTEXPR inline uint qCountLeadingZeroBits(quint32 v) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline uint qCountLeadingZeroBits(quint32 v) noexcept { #if defined(QT_HAS_BUILTIN_CLZ) return v ? QAlgorithmsPrivate::qt_builtin_clz(v) : 32U; @@ -824,7 +824,7 @@ Q_DECL_RELAXED_CONSTEXPR inline uint qCountLeadingZeroBits(quint32 v) Q_DECL_NOT #endif } -QT_POPCOUNT_RELAXED_CONSTEXPR inline uint qCountLeadingZeroBits(quint8 v) Q_DECL_NOTHROW +QT_POPCOUNT_RELAXED_CONSTEXPR inline uint qCountLeadingZeroBits(quint8 v) noexcept { #if defined(QT_HAS_BUILTIN_CLZ) return v ? QAlgorithmsPrivate::qt_builtin_clz(v)-24U : 8U; @@ -836,7 +836,7 @@ QT_POPCOUNT_RELAXED_CONSTEXPR inline uint qCountLeadingZeroBits(quint8 v) Q_DECL #endif } -QT_POPCOUNT_RELAXED_CONSTEXPR inline uint qCountLeadingZeroBits(quint16 v) Q_DECL_NOTHROW +QT_POPCOUNT_RELAXED_CONSTEXPR inline uint qCountLeadingZeroBits(quint16 v) noexcept { #if defined(QT_HAS_BUILTIN_CLZS) return v ? QAlgorithmsPrivate::qt_builtin_clzs(v) : 16U; @@ -849,7 +849,7 @@ QT_POPCOUNT_RELAXED_CONSTEXPR inline uint qCountLeadingZeroBits(quint16 v) Q_DEC #endif } -QT_POPCOUNT_RELAXED_CONSTEXPR inline uint qCountLeadingZeroBits(quint64 v) Q_DECL_NOTHROW +QT_POPCOUNT_RELAXED_CONSTEXPR inline uint qCountLeadingZeroBits(quint64 v) noexcept { #if defined(QT_HAS_BUILTIN_CLZLL) return v ? QAlgorithmsPrivate::qt_builtin_clzll(v) : 64U; @@ -864,7 +864,7 @@ QT_POPCOUNT_RELAXED_CONSTEXPR inline uint qCountLeadingZeroBits(quint64 v) Q_DEC #endif } -QT_POPCOUNT_RELAXED_CONSTEXPR inline uint qCountLeadingZeroBits(unsigned long v) Q_DECL_NOTHROW +QT_POPCOUNT_RELAXED_CONSTEXPR inline uint qCountLeadingZeroBits(unsigned long v) noexcept { return qCountLeadingZeroBits(QIntegerForSizeof::Unsigned(v)); } diff --git a/src/corelib/tools/qarraydata.cpp b/src/corelib/tools/qarraydata.cpp index a91d833e3b..bcc0688a91 100644 --- a/src/corelib/tools/qarraydata.cpp +++ b/src/corelib/tools/qarraydata.cpp @@ -87,7 +87,7 @@ static QArrayData *reallocateData(QArrayData *header, size_t allocSize, uint opt } QArrayData *QArrayData::allocate(size_t objectSize, size_t alignment, - size_t capacity, AllocationOptions options) Q_DECL_NOTHROW + size_t capacity, AllocationOptions options) noexcept { // Alignment is a power of two Q_ASSERT(alignment >= Q_ALIGNOF(QArrayData) @@ -135,7 +135,7 @@ QArrayData *QArrayData::allocate(size_t objectSize, size_t alignment, } QArrayData *QArrayData::reallocateUnaligned(QArrayData *data, size_t objectSize, size_t capacity, - AllocationOptions options) Q_DECL_NOTHROW + AllocationOptions options) noexcept { Q_ASSERT(data); Q_ASSERT(data->isMutable()); @@ -150,7 +150,7 @@ QArrayData *QArrayData::reallocateUnaligned(QArrayData *data, size_t objectSize, } void QArrayData::deallocate(QArrayData *data, size_t objectSize, - size_t alignment) Q_DECL_NOTHROW + size_t alignment) noexcept { // Alignment is a power of two Q_ASSERT(alignment >= Q_ALIGNOF(QArrayData) diff --git a/src/corelib/tools/qarraydata.h b/src/corelib/tools/qarraydata.h index a642fb9b39..f78b9be2db 100644 --- a/src/corelib/tools/qarraydata.h +++ b/src/corelib/tools/qarraydata.h @@ -113,14 +113,14 @@ struct Q_CORE_EXPORT QArrayData } Q_REQUIRED_RESULT static QArrayData *allocate(size_t objectSize, size_t alignment, - size_t capacity, AllocationOptions options = Default) Q_DECL_NOTHROW; + size_t capacity, AllocationOptions options = Default) noexcept; Q_REQUIRED_RESULT static QArrayData *reallocateUnaligned(QArrayData *data, size_t objectSize, - size_t newCapacity, AllocationOptions newOptions = Default) Q_DECL_NOTHROW; + size_t newCapacity, AllocationOptions newOptions = Default) noexcept; static void deallocate(QArrayData *data, size_t objectSize, - size_t alignment) Q_DECL_NOTHROW; + size_t alignment) noexcept; static const QArrayData shared_null[2]; - static QArrayData *sharedNull() Q_DECL_NOTHROW { return const_cast(shared_null); } + static QArrayData *sharedNull() noexcept { return const_cast(shared_null); } }; Q_DECLARE_OPERATORS_FOR_FLAGS(QArrayData::AllocationOptions) @@ -254,7 +254,7 @@ struct QTypedArrayData return result; } - static QTypedArrayData *sharedNull() Q_DECL_NOTHROW + static QTypedArrayData *sharedNull() noexcept { Q_STATIC_ASSERT(sizeof(QTypedArrayData) == sizeof(QArrayData)); return static_cast(QArrayData::sharedNull()); diff --git a/src/corelib/tools/qarraydatapointer.h b/src/corelib/tools/qarraydatapointer.h index 51cfa6e849..bce8fc8ddc 100644 --- a/src/corelib/tools/qarraydatapointer.h +++ b/src/corelib/tools/qarraydatapointer.h @@ -52,7 +52,7 @@ private: typedef QArrayDataOps DataOps; public: - QArrayDataPointer() Q_DECL_NOTHROW + QArrayDataPointer() noexcept : d(Data::sharedNull()) { } @@ -83,13 +83,13 @@ public: } #ifdef Q_COMPILER_RVALUE_REFS - QArrayDataPointer(QArrayDataPointer &&other) Q_DECL_NOTHROW + QArrayDataPointer(QArrayDataPointer &&other) noexcept : d(other.d) { other.d = Data::sharedNull(); } - QArrayDataPointer &operator=(QArrayDataPointer &&other) Q_DECL_NOTHROW + QArrayDataPointer &operator=(QArrayDataPointer &&other) noexcept { QArrayDataPointer moved(std::move(other)); this->swap(moved); @@ -150,7 +150,7 @@ public: bool isSharable() const { return d->isSharable(); } #endif - void swap(QArrayDataPointer &other) Q_DECL_NOTHROW + void swap(QArrayDataPointer &other) noexcept { qSwap(d, other.d); } diff --git a/src/corelib/tools/qbitarray.h b/src/corelib/tools/qbitarray.h index ff40bf5654..78beff0d42 100644 --- a/src/corelib/tools/qbitarray.h +++ b/src/corelib/tools/qbitarray.h @@ -50,21 +50,21 @@ class Q_CORE_EXPORT QBitArray { friend Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QBitArray &); friend Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QBitArray &); - friend Q_CORE_EXPORT uint qHash(const QBitArray &key, uint seed) Q_DECL_NOTHROW; + friend Q_CORE_EXPORT uint qHash(const QBitArray &key, uint seed) noexcept; QByteArray d; public: - inline QBitArray() Q_DECL_NOTHROW {} + inline QBitArray() noexcept {} explicit QBitArray(int size, bool val = false); QBitArray(const QBitArray &other) : d(other.d) {} inline QBitArray &operator=(const QBitArray &other) { d = other.d; return *this; } #ifdef Q_COMPILER_RVALUE_REFS - inline QBitArray(QBitArray &&other) Q_DECL_NOTHROW : d(std::move(other.d)) {} - inline QBitArray &operator=(QBitArray &&other) Q_DECL_NOTHROW + inline QBitArray(QBitArray &&other) noexcept : d(std::move(other.d)) {} + inline QBitArray &operator=(QBitArray &&other) noexcept { qSwap(d, other.d); return *this; } #endif - inline void swap(QBitArray &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + inline void swap(QBitArray &other) noexcept { qSwap(d, other.d); } inline int size() const { return (d.size() << 3) - *d.constData(); } inline int count() const { return (d.size() << 3) - *d.constData(); } diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp index 8bf20350d6..a5a473acf4 100644 --- a/src/corelib/tools/qbytearray.cpp +++ b/src/corelib/tools/qbytearray.cpp @@ -165,7 +165,7 @@ int qFindByteArray( This function returns SIZE_MAX (~0) on overflow or if the memory block size would not fit an int. */ -size_t qCalculateBlockSize(size_t elementCount, size_t elementSize, size_t headerSize) Q_DECL_NOTHROW +size_t qCalculateBlockSize(size_t elementCount, size_t elementSize, size_t headerSize) noexcept { unsigned count = unsigned(elementCount); unsigned size = unsigned(elementSize); @@ -206,7 +206,7 @@ size_t qCalculateBlockSize(size_t elementCount, size_t elementSize, size_t heade needed. */ CalculateGrowingBlockSizeResult -qCalculateGrowingBlockSize(size_t elementCount, size_t elementSize, size_t headerSize) Q_DECL_NOTHROW +qCalculateGrowingBlockSize(size_t elementCount, size_t elementSize, size_t headerSize) noexcept { CalculateGrowingBlockSizeResult result = { std::numeric_limits::max(),std::numeric_limits::max() @@ -1281,7 +1281,7 @@ QByteArray qUncompress(const uchar* data, int nbytes) Assigns \a other to this byte array and returns a reference to this byte array. */ -QByteArray &QByteArray::operator=(const QByteArray & other) Q_DECL_NOTHROW +QByteArray &QByteArray::operator=(const QByteArray & other) noexcept { other.d->ref.ref(); if (!d->ref.deref()) diff --git a/src/corelib/tools/qbytearray.h b/src/corelib/tools/qbytearray.h index 8ee3a29ecc..318d773eb6 100644 --- a/src/corelib/tools/qbytearray.h +++ b/src/corelib/tools/qbytearray.h @@ -168,22 +168,22 @@ public: }; Q_DECLARE_FLAGS(Base64Options, Base64Option) - inline QByteArray() Q_DECL_NOTHROW; + inline QByteArray() noexcept; QByteArray(const char *, int size = -1); QByteArray(int size, char c); QByteArray(int size, Qt::Initialization); - inline QByteArray(const QByteArray &) Q_DECL_NOTHROW; + inline QByteArray(const QByteArray &) noexcept; inline ~QByteArray(); - QByteArray &operator=(const QByteArray &) Q_DECL_NOTHROW; + QByteArray &operator=(const QByteArray &) noexcept; QByteArray &operator=(const char *str); #ifdef Q_COMPILER_RVALUE_REFS - inline QByteArray(QByteArray && other) Q_DECL_NOTHROW : d(other.d) { other.d = Data::sharedNull(); } - inline QByteArray &operator=(QByteArray &&other) Q_DECL_NOTHROW + inline QByteArray(QByteArray && other) noexcept : d(other.d) { other.d = Data::sharedNull(); } + inline QByteArray &operator=(QByteArray &&other) noexcept { qSwap(d, other.d); return *this; } #endif - inline void swap(QByteArray &other) Q_DECL_NOTHROW + inline void swap(QByteArray &other) noexcept { qSwap(d, other.d); } inline int size() const; @@ -472,7 +472,7 @@ public: Q_DECLARE_OPERATORS_FOR_FLAGS(QByteArray::Base64Options) -inline QByteArray::QByteArray() Q_DECL_NOTHROW : d(Data::sharedNull()) { } +inline QByteArray::QByteArray() noexcept : d(Data::sharedNull()) { } inline QByteArray::~QByteArray() { if (!d->ref.deref()) Data::deallocate(d); } inline int QByteArray::size() const { return d->size; } @@ -502,7 +502,7 @@ inline void QByteArray::detach() { if (d->ref.isShared() || (d->offset != sizeof(QByteArrayData))) reallocData(uint(d->size) + 1u, d->detachFlags()); } inline bool QByteArray::isDetached() const { return !d->ref.isShared(); } -inline QByteArray::QByteArray(const QByteArray &a) Q_DECL_NOTHROW : d(a.d) +inline QByteArray::QByteArray(const QByteArray &a) noexcept : d(a.d) { d->ref.ref(); } inline int QByteArray::capacity() const @@ -617,41 +617,41 @@ inline int QByteArray::compare(const QByteArray &a, Qt::CaseSensitivity cs) cons return cs == Qt::CaseSensitive ? qstrcmp(*this, a) : qstrnicmp(data(), size(), a.data(), a.size()); } -inline bool operator==(const QByteArray &a1, const QByteArray &a2) Q_DECL_NOTHROW +inline bool operator==(const QByteArray &a1, const QByteArray &a2) noexcept { return (a1.size() == a2.size()) && (memcmp(a1.constData(), a2.constData(), a1.size())==0); } -inline bool operator==(const QByteArray &a1, const char *a2) Q_DECL_NOTHROW +inline bool operator==(const QByteArray &a1, const char *a2) noexcept { return a2 ? qstrcmp(a1,a2) == 0 : a1.isEmpty(); } -inline bool operator==(const char *a1, const QByteArray &a2) Q_DECL_NOTHROW +inline bool operator==(const char *a1, const QByteArray &a2) noexcept { return a1 ? qstrcmp(a1,a2) == 0 : a2.isEmpty(); } -inline bool operator!=(const QByteArray &a1, const QByteArray &a2) Q_DECL_NOTHROW +inline bool operator!=(const QByteArray &a1, const QByteArray &a2) noexcept { return !(a1==a2); } -inline bool operator!=(const QByteArray &a1, const char *a2) Q_DECL_NOTHROW +inline bool operator!=(const QByteArray &a1, const char *a2) noexcept { return a2 ? qstrcmp(a1,a2) != 0 : !a1.isEmpty(); } -inline bool operator!=(const char *a1, const QByteArray &a2) Q_DECL_NOTHROW +inline bool operator!=(const char *a1, const QByteArray &a2) noexcept { return a1 ? qstrcmp(a1,a2) != 0 : !a2.isEmpty(); } -inline bool operator<(const QByteArray &a1, const QByteArray &a2) Q_DECL_NOTHROW +inline bool operator<(const QByteArray &a1, const QByteArray &a2) noexcept { return qstrcmp(a1, a2) < 0; } - inline bool operator<(const QByteArray &a1, const char *a2) Q_DECL_NOTHROW + inline bool operator<(const QByteArray &a1, const char *a2) noexcept { return qstrcmp(a1, a2) < 0; } -inline bool operator<(const char *a1, const QByteArray &a2) Q_DECL_NOTHROW +inline bool operator<(const char *a1, const QByteArray &a2) noexcept { return qstrcmp(a1, a2) < 0; } -inline bool operator<=(const QByteArray &a1, const QByteArray &a2) Q_DECL_NOTHROW +inline bool operator<=(const QByteArray &a1, const QByteArray &a2) noexcept { return qstrcmp(a1, a2) <= 0; } -inline bool operator<=(const QByteArray &a1, const char *a2) Q_DECL_NOTHROW +inline bool operator<=(const QByteArray &a1, const char *a2) noexcept { return qstrcmp(a1, a2) <= 0; } -inline bool operator<=(const char *a1, const QByteArray &a2) Q_DECL_NOTHROW +inline bool operator<=(const char *a1, const QByteArray &a2) noexcept { return qstrcmp(a1, a2) <= 0; } -inline bool operator>(const QByteArray &a1, const QByteArray &a2) Q_DECL_NOTHROW +inline bool operator>(const QByteArray &a1, const QByteArray &a2) noexcept { return qstrcmp(a1, a2) > 0; } -inline bool operator>(const QByteArray &a1, const char *a2) Q_DECL_NOTHROW +inline bool operator>(const QByteArray &a1, const char *a2) noexcept { return qstrcmp(a1, a2) > 0; } -inline bool operator>(const char *a1, const QByteArray &a2) Q_DECL_NOTHROW +inline bool operator>(const char *a1, const QByteArray &a2) noexcept { return qstrcmp(a1, a2) > 0; } -inline bool operator>=(const QByteArray &a1, const QByteArray &a2) Q_DECL_NOTHROW +inline bool operator>=(const QByteArray &a1, const QByteArray &a2) noexcept { return qstrcmp(a1, a2) >= 0; } -inline bool operator>=(const QByteArray &a1, const char *a2) Q_DECL_NOTHROW +inline bool operator>=(const QByteArray &a1, const char *a2) noexcept { return qstrcmp(a1, a2) >= 0; } -inline bool operator>=(const char *a1, const QByteArray &a2) Q_DECL_NOTHROW +inline bool operator>=(const char *a1, const QByteArray &a2) noexcept { return qstrcmp(a1, a2) >= 0; } #if !defined(QT_USE_QSTRINGBUILDER) inline const QByteArray operator+(const QByteArray &a1, const QByteArray &a2) diff --git a/src/corelib/tools/qbytearraymatcher.cpp b/src/corelib/tools/qbytearraymatcher.cpp index 72f0e0519d..d2eb4e0e3c 100644 --- a/src/corelib/tools/qbytearraymatcher.cpp +++ b/src/corelib/tools/qbytearraymatcher.cpp @@ -404,7 +404,7 @@ int qFindByteArray( /*! \internal */ -int QStaticByteArrayMatcherBase::indexOfIn(const char *needle, uint nlen, const char *haystack, int hlen, int from) const Q_DECL_NOTHROW +int QStaticByteArrayMatcherBase::indexOfIn(const char *needle, uint nlen, const char *haystack, int hlen, int from) const noexcept { if (from < 0) from = 0; diff --git a/src/corelib/tools/qbytearraymatcher.h b/src/corelib/tools/qbytearraymatcher.h index dafaea9c12..0eedfc1d20 100644 --- a/src/corelib/tools/qbytearraymatcher.h +++ b/src/corelib/tools/qbytearraymatcher.h @@ -90,15 +90,15 @@ class QStaticByteArrayMatcherBase uchar data[256]; } m_skiptable; protected: - explicit Q_DECL_RELAXED_CONSTEXPR QStaticByteArrayMatcherBase(const char *pattern, uint n) Q_DECL_NOTHROW + explicit Q_DECL_RELAXED_CONSTEXPR QStaticByteArrayMatcherBase(const char *pattern, uint n) noexcept : m_skiptable(generate(pattern, n)) {} // compiler-generated copy/more ctors/assignment operators are ok! // compiler-generated dtor is ok! - Q_CORE_EXPORT int indexOfIn(const char *needle, uint nlen, const char *haystack, int hlen, int from) const Q_DECL_NOTHROW; + Q_CORE_EXPORT int indexOfIn(const char *needle, uint nlen, const char *haystack, int hlen, int from) const noexcept; private: - static Q_DECL_RELAXED_CONSTEXPR Skiptable generate(const char *pattern, uint n) Q_DECL_NOTHROW + static Q_DECL_RELAXED_CONSTEXPR Skiptable generate(const char *pattern, uint n) noexcept { const auto uchar_max = (std::numeric_limits::max)(); uchar max = n > uchar_max ? uchar_max : n; @@ -140,23 +140,23 @@ class QStaticByteArrayMatcher : QStaticByteArrayMatcherBase char m_pattern[N]; Q_STATIC_ASSERT_X(N > 2, "QStaticByteArrayMatcher makes no sense for finding a single-char pattern"); public: - explicit Q_DECL_RELAXED_CONSTEXPR QStaticByteArrayMatcher(const char (&patternToMatch)[N]) Q_DECL_NOTHROW + explicit Q_DECL_RELAXED_CONSTEXPR QStaticByteArrayMatcher(const char (&patternToMatch)[N]) noexcept : QStaticByteArrayMatcherBase(patternToMatch, N - 1), m_pattern() { for (uint i = 0; i < N; ++i) m_pattern[i] = patternToMatch[i]; } - int indexIn(const QByteArray &haystack, int from = 0) const Q_DECL_NOTHROW + int indexIn(const QByteArray &haystack, int from = 0) const noexcept { return this->indexOfIn(m_pattern, N - 1, haystack.data(), haystack.size(), from); } - int indexIn(const char *haystack, int hlen, int from = 0) const Q_DECL_NOTHROW + int indexIn(const char *haystack, int hlen, int from = 0) const noexcept { return this->indexOfIn(m_pattern, N - 1, haystack, hlen, from); } QByteArray pattern() const { return QByteArray(m_pattern, int(N - 1)); } }; template -Q_DECL_RELAXED_CONSTEXPR QStaticByteArrayMatcher qMakeStaticByteArrayMatcher(const char (&pattern)[N]) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR QStaticByteArrayMatcher qMakeStaticByteArrayMatcher(const char (&pattern)[N]) noexcept { return QStaticByteArrayMatcher(pattern); } QT_END_NAMESPACE diff --git a/src/corelib/tools/qcache.h b/src/corelib/tools/qcache.h index b558a8358d..4fcde46fbc 100644 --- a/src/corelib/tools/qcache.h +++ b/src/corelib/tools/qcache.h @@ -89,7 +89,7 @@ class QCache Q_DISABLE_COPY(QCache) public: - inline explicit QCache(int maxCost = 100) Q_DECL_NOTHROW; + inline explicit QCache(int maxCost = 100) noexcept; inline ~QCache() { clear(); } inline int maxCost() const { return mx; } @@ -116,7 +116,7 @@ private: }; template -inline QCache::QCache(int amaxCost) Q_DECL_NOTHROW +inline QCache::QCache(int amaxCost) noexcept : f(nullptr), l(nullptr), mx(amaxCost), total(0) {} template diff --git a/src/corelib/tools/qchar.cpp b/src/corelib/tools/qchar.cpp index 47c853084b..d6061defc3 100644 --- a/src/corelib/tools/qchar.cpp +++ b/src/corelib/tools/qchar.cpp @@ -733,7 +733,7 @@ QT_BEGIN_NAMESPACE Note that this gives no indication of whether the character is available in a particular font. */ -bool QChar::isPrint(uint ucs4) Q_DECL_NOTHROW +bool QChar::isPrint(uint ucs4) noexcept { if (ucs4 > LastValidCodePoint) return false; @@ -766,7 +766,7 @@ bool QChar::isPrint(uint ucs4) Q_DECL_NOTHROW /*! \internal */ -bool QT_FASTCALL QChar::isSpace_helper(uint ucs4) Q_DECL_NOTHROW +bool QT_FASTCALL QChar::isSpace_helper(uint ucs4) noexcept { if (ucs4 > LastValidCodePoint) return false; @@ -792,7 +792,7 @@ bool QT_FASTCALL QChar::isSpace_helper(uint ucs4) Q_DECL_NOTHROW Returns \c true if the UCS-4-encoded character specified by \a ucs4 is a mark (Mark_* categories); otherwise returns \c false. */ -bool QChar::isMark(uint ucs4) Q_DECL_NOTHROW +bool QChar::isMark(uint ucs4) noexcept { if (ucs4 > LastValidCodePoint) return false; @@ -816,7 +816,7 @@ bool QChar::isMark(uint ucs4) Q_DECL_NOTHROW Returns \c true if the UCS-4-encoded character specified by \a ucs4 is a punctuation mark (Punctuation_* categories); otherwise returns \c false. */ -bool QChar::isPunct(uint ucs4) Q_DECL_NOTHROW +bool QChar::isPunct(uint ucs4) noexcept { if (ucs4 > LastValidCodePoint) return false; @@ -844,7 +844,7 @@ bool QChar::isPunct(uint ucs4) Q_DECL_NOTHROW Returns \c true if the UCS-4-encoded character specified by \a ucs4 is a symbol (Symbol_* categories); otherwise returns \c false. */ -bool QChar::isSymbol(uint ucs4) Q_DECL_NOTHROW +bool QChar::isSymbol(uint ucs4) noexcept { if (ucs4 > LastValidCodePoint) return false; @@ -874,7 +874,7 @@ bool QChar::isSymbol(uint ucs4) Q_DECL_NOTHROW /*! \internal */ -bool QT_FASTCALL QChar::isLetter_helper(uint ucs4) Q_DECL_NOTHROW +bool QT_FASTCALL QChar::isLetter_helper(uint ucs4) noexcept { if (ucs4 > LastValidCodePoint) return false; @@ -909,7 +909,7 @@ bool QT_FASTCALL QChar::isLetter_helper(uint ucs4) Q_DECL_NOTHROW /*! \internal */ -bool QT_FASTCALL QChar::isNumber_helper(uint ucs4) Q_DECL_NOTHROW +bool QT_FASTCALL QChar::isNumber_helper(uint ucs4) noexcept { if (ucs4 > LastValidCodePoint) return false; @@ -938,7 +938,7 @@ bool QT_FASTCALL QChar::isNumber_helper(uint ucs4) Q_DECL_NOTHROW /*! \internal */ -bool QT_FASTCALL QChar::isLetterOrNumber_helper(uint ucs4) Q_DECL_NOTHROW +bool QT_FASTCALL QChar::isLetterOrNumber_helper(uint ucs4) noexcept { if (ucs4 > LastValidCodePoint) return false; @@ -1101,7 +1101,7 @@ bool QT_FASTCALL QChar::isLetterOrNumber_helper(uint ucs4) Q_DECL_NOTHROW Returns the numeric value of the digit specified by the UCS-4-encoded character, \a ucs4, or -1 if the character is not a digit. */ -int QChar::digitValue(uint ucs4) Q_DECL_NOTHROW +int QChar::digitValue(uint ucs4) noexcept { if (ucs4 > LastValidCodePoint) return -1; @@ -1118,7 +1118,7 @@ int QChar::digitValue(uint ucs4) Q_DECL_NOTHROW \overload Returns the category of the UCS-4-encoded character specified by \a ucs4. */ -QChar::Category QChar::category(uint ucs4) Q_DECL_NOTHROW +QChar::Category QChar::category(uint ucs4) noexcept { if (ucs4 > LastValidCodePoint) return QChar::Other_NotAssigned; @@ -1135,7 +1135,7 @@ QChar::Category QChar::category(uint ucs4) Q_DECL_NOTHROW \overload Returns the direction of the UCS-4-encoded character specified by \a ucs4. */ -QChar::Direction QChar::direction(uint ucs4) Q_DECL_NOTHROW +QChar::Direction QChar::direction(uint ucs4) noexcept { if (ucs4 > LastValidCodePoint) return QChar::DirL; @@ -1158,7 +1158,7 @@ QChar::Direction QChar::direction(uint ucs4) Q_DECL_NOTHROW character specified by \a ucs4 (needed for certain languages such as Arabic or Syriac). */ -QChar::JoiningType QChar::joiningType(uint ucs4) Q_DECL_NOTHROW +QChar::JoiningType QChar::joiningType(uint ucs4) noexcept { if (ucs4 > LastValidCodePoint) return QChar::Joining_None; @@ -1181,7 +1181,7 @@ QChar::JoiningType QChar::joiningType(uint ucs4) Q_DECL_NOTHROW Returns information about the joining properties of the UCS-4-encoded character specified by \a ucs4 (needed for certain languages such as Arabic). */ -QChar::Joining QChar::joining(uint ucs4) Q_DECL_NOTHROW +QChar::Joining QChar::joining(uint ucs4) noexcept { if (ucs4 > LastValidCodePoint) return QChar::OtherJoining; @@ -1217,7 +1217,7 @@ QChar::Joining QChar::joining(uint ucs4) Q_DECL_NOTHROW \sa mirroredChar() */ -bool QChar::hasMirrored(uint ucs4) Q_DECL_NOTHROW +bool QChar::hasMirrored(uint ucs4) noexcept { if (ucs4 > LastValidCodePoint) return false; @@ -1299,7 +1299,7 @@ bool QChar::hasMirrored(uint ucs4) Q_DECL_NOTHROW \sa hasMirrored() */ -uint QChar::mirroredChar(uint ucs4) Q_DECL_NOTHROW +uint QChar::mirroredChar(uint ucs4) noexcept { if (ucs4 > LastValidCodePoint) return ucs4; @@ -1383,7 +1383,7 @@ QString QChar::decomposition(uint ucs4) Returns the tag defining the composition of the UCS-4-encoded character specified by \a ucs4. Returns QChar::NoDecomposition if no decomposition exists. */ -QChar::Decomposition QChar::decompositionTag(uint ucs4) Q_DECL_NOTHROW +QChar::Decomposition QChar::decompositionTag(uint ucs4) noexcept { if (ucs4 >= Hangul_SBase && ucs4 < Hangul_SBase + Hangul_SCount) return QChar::Canonical; @@ -1409,7 +1409,7 @@ QChar::Decomposition QChar::decompositionTag(uint ucs4) Q_DECL_NOTHROW Returns the combining class for the UCS-4-encoded character specified by \a ucs4, as defined in the Unicode standard. */ -unsigned char QChar::combiningClass(uint ucs4) Q_DECL_NOTHROW +unsigned char QChar::combiningClass(uint ucs4) noexcept { if (ucs4 > LastValidCodePoint) return 0; @@ -1430,7 +1430,7 @@ unsigned char QChar::combiningClass(uint ucs4) Q_DECL_NOTHROW Returns the Unicode script property value for the character specified in its UCS-4-encoded form as \a ucs4. */ -QChar::Script QChar::script(uint ucs4) Q_DECL_NOTHROW +QChar::Script QChar::script(uint ucs4) noexcept { if (ucs4 > LastValidCodePoint) return QChar::Script_Unknown; @@ -1448,7 +1448,7 @@ QChar::Script QChar::script(uint ucs4) Q_DECL_NOTHROW Returns the Unicode version that introduced the character specified in its UCS-4-encoded form as \a ucs4. */ -QChar::UnicodeVersion QChar::unicodeVersion(uint ucs4) Q_DECL_NOTHROW +QChar::UnicodeVersion QChar::unicodeVersion(uint ucs4) noexcept { if (ucs4 > LastValidCodePoint) return QChar::Unicode_Unassigned; @@ -1458,14 +1458,14 @@ QChar::UnicodeVersion QChar::unicodeVersion(uint ucs4) Q_DECL_NOTHROW /*! Returns the most recent supported Unicode version. */ -QChar::UnicodeVersion QChar::currentUnicodeVersion() Q_DECL_NOTHROW +QChar::UnicodeVersion QChar::currentUnicodeVersion() noexcept { return UNICODE_DATA_VERSION; } template -Q_DECL_CONST_FUNCTION static inline T convertCase_helper(T uc) Q_DECL_NOTHROW +Q_DECL_CONST_FUNCTION static inline T convertCase_helper(T uc) noexcept { const QUnicodeTables::Properties *prop = qGetProp(uc); @@ -1491,7 +1491,7 @@ Q_DECL_CONST_FUNCTION static inline T convertCase_helper(T uc) Q_DECL_NOTHROW by \a ucs4 if the character is uppercase or titlecase; otherwise returns the character itself. */ -uint QChar::toLower(uint ucs4) Q_DECL_NOTHROW +uint QChar::toLower(uint ucs4) noexcept { if (ucs4 > LastValidCodePoint) return ucs4; @@ -1511,7 +1511,7 @@ uint QChar::toLower(uint ucs4) Q_DECL_NOTHROW by \a ucs4 if the character is lowercase or titlecase; otherwise returns the character itself. */ -uint QChar::toUpper(uint ucs4) Q_DECL_NOTHROW +uint QChar::toUpper(uint ucs4) noexcept { if (ucs4 > LastValidCodePoint) return ucs4; @@ -1531,7 +1531,7 @@ uint QChar::toUpper(uint ucs4) Q_DECL_NOTHROW by \a ucs4 if the character is lowercase or uppercase; otherwise returns the character itself. */ -uint QChar::toTitleCase(uint ucs4) Q_DECL_NOTHROW +uint QChar::toTitleCase(uint ucs4) noexcept { if (ucs4 > LastValidCodePoint) return ucs4; @@ -1546,7 +1546,7 @@ static inline uint foldCase(const ushort *ch, const ushort *start) return convertCase_helper(ucs4); } -static inline uint foldCase(uint ch, uint &last) Q_DECL_NOTHROW +static inline uint foldCase(uint ch, uint &last) noexcept { uint ucs4 = ch; if (QChar::isLowSurrogate(ucs4) && QChar::isHighSurrogate(last)) @@ -1555,12 +1555,12 @@ static inline uint foldCase(uint ch, uint &last) Q_DECL_NOTHROW return convertCase_helper(ucs4); } -static inline ushort foldCase(ushort ch) Q_DECL_NOTHROW +static inline ushort foldCase(ushort ch) noexcept { return convertCase_helper(ch); } -static inline QChar foldCase(QChar ch) Q_DECL_NOTHROW +static inline QChar foldCase(QChar ch) noexcept { return QChar(foldCase(ch.unicode())); } @@ -1577,7 +1577,7 @@ static inline QChar foldCase(QChar ch) Q_DECL_NOTHROW Returns the case folded equivalent of the UCS-4-encoded character specified by \a ucs4. For most Unicode characters this is the same as toLower(). */ -uint QChar::toCaseFolded(uint ucs4) Q_DECL_NOTHROW +uint QChar::toCaseFolded(uint ucs4) noexcept { if (ucs4 > LastValidCodePoint) return ucs4; diff --git a/src/corelib/tools/qchar.h b/src/corelib/tools/qchar.h index 8590b91ba3..be344838ed 100644 --- a/src/corelib/tools/qchar.h +++ b/src/corelib/tools/qchar.h @@ -50,9 +50,9 @@ class QString; struct QLatin1Char { public: - Q_DECL_CONSTEXPR inline explicit QLatin1Char(char c) Q_DECL_NOTHROW : ch(c) {} - Q_DECL_CONSTEXPR inline char toLatin1() const Q_DECL_NOTHROW { return ch; } - Q_DECL_CONSTEXPR inline ushort unicode() const Q_DECL_NOTHROW { return ushort(uchar(ch)); } + Q_DECL_CONSTEXPR inline explicit QLatin1Char(char c) noexcept : ch(c) {} + Q_DECL_CONSTEXPR inline char toLatin1() const noexcept { return ch; } + Q_DECL_CONSTEXPR inline ushort unicode() const noexcept { return ushort(uchar(ch)); } private: char ch; @@ -78,30 +78,30 @@ public: LastValidCodePoint = 0x10ffff }; - Q_DECL_CONSTEXPR QChar() Q_DECL_NOTHROW : ucs(0) {} - Q_DECL_CONSTEXPR QChar(ushort rc) Q_DECL_NOTHROW : ucs(rc) {} // implicit - Q_DECL_CONSTEXPR QChar(uchar c, uchar r) Q_DECL_NOTHROW : ucs(ushort((r << 8) | c)) {} - Q_DECL_CONSTEXPR QChar(short rc) Q_DECL_NOTHROW : ucs(ushort(rc)) {} // implicit - Q_DECL_CONSTEXPR QChar(uint rc) Q_DECL_NOTHROW : ucs(ushort(rc & 0xffff)) {} - Q_DECL_CONSTEXPR QChar(int rc) Q_DECL_NOTHROW : ucs(ushort(rc & 0xffff)) {} - Q_DECL_CONSTEXPR QChar(SpecialCharacter s) Q_DECL_NOTHROW : ucs(ushort(s)) {} // implicit - Q_DECL_CONSTEXPR QChar(QLatin1Char ch) Q_DECL_NOTHROW : ucs(ch.unicode()) {} // implicit + Q_DECL_CONSTEXPR QChar() noexcept : ucs(0) {} + Q_DECL_CONSTEXPR QChar(ushort rc) noexcept : ucs(rc) {} // implicit + Q_DECL_CONSTEXPR QChar(uchar c, uchar r) noexcept : ucs(ushort((r << 8) | c)) {} + Q_DECL_CONSTEXPR QChar(short rc) noexcept : ucs(ushort(rc)) {} // implicit + Q_DECL_CONSTEXPR QChar(uint rc) noexcept : ucs(ushort(rc & 0xffff)) {} + Q_DECL_CONSTEXPR QChar(int rc) noexcept : ucs(ushort(rc & 0xffff)) {} + Q_DECL_CONSTEXPR QChar(SpecialCharacter s) noexcept : ucs(ushort(s)) {} // implicit + Q_DECL_CONSTEXPR QChar(QLatin1Char ch) noexcept : ucs(ch.unicode()) {} // implicit #if defined(Q_COMPILER_UNICODE_STRINGS) - Q_DECL_CONSTEXPR QChar(char16_t ch) Q_DECL_NOTHROW : ucs(ushort(ch)) {} // implicit + Q_DECL_CONSTEXPR QChar(char16_t ch) noexcept : ucs(ushort(ch)) {} // implicit #endif #if defined(Q_OS_WIN) Q_STATIC_ASSERT(sizeof(wchar_t) == sizeof(ushort)); #endif #if defined(Q_OS_WIN) || defined(Q_CLANG_QDOC) # if !defined(_WCHAR_T_DEFINED) || defined(_NATIVE_WCHAR_T_DEFINED) - Q_DECL_CONSTEXPR QChar(wchar_t ch) Q_DECL_NOTHROW : ucs(ushort(ch)) {} // implicit + Q_DECL_CONSTEXPR QChar(wchar_t ch) noexcept : ucs(ushort(ch)) {} // implicit # endif #endif #ifndef QT_NO_CAST_FROM_ASCII - QT_ASCII_CAST_WARN Q_DECL_CONSTEXPR explicit QChar(char c) Q_DECL_NOTHROW : ucs(uchar(c)) { } + QT_ASCII_CAST_WARN Q_DECL_CONSTEXPR explicit QChar(char c) noexcept : ucs(uchar(c)) { } #ifndef QT_RESTRICTED_CAST_FROM_ASCII - QT_ASCII_CAST_WARN Q_DECL_CONSTEXPR explicit QChar(uchar c) Q_DECL_NOTHROW : ucs(c) { } + QT_ASCII_CAST_WARN Q_DECL_CONSTEXPR explicit QChar(uchar c) noexcept : ucs(c) { } #endif #endif // Unicode information @@ -411,11 +411,11 @@ public: }; // ****** WHEN ADDING FUNCTIONS, CONSIDER ADDING TO QCharRef TOO - inline Category category() const Q_DECL_NOTHROW { return QChar::category(ucs); } - inline Direction direction() const Q_DECL_NOTHROW { return QChar::direction(ucs); } - inline JoiningType joiningType() const Q_DECL_NOTHROW { return QChar::joiningType(ucs); } + inline Category category() const noexcept { return QChar::category(ucs); } + inline Direction direction() const noexcept { return QChar::direction(ucs); } + inline JoiningType joiningType() const noexcept { return QChar::joiningType(ucs); } #if QT_DEPRECATED_SINCE(5, 3) - QT_DEPRECATED inline Joining joining() const Q_DECL_NOTHROW + QT_DEPRECATED inline Joining joining() const noexcept { switch (QChar::joiningType(ucs)) { case QChar::Joining_Causing: return QChar::Center; @@ -428,198 +428,198 @@ public: } } #endif - inline unsigned char combiningClass() const Q_DECL_NOTHROW { return QChar::combiningClass(ucs); } + inline unsigned char combiningClass() const noexcept { return QChar::combiningClass(ucs); } - inline QChar mirroredChar() const Q_DECL_NOTHROW { return QChar::mirroredChar(ucs); } - inline bool hasMirrored() const Q_DECL_NOTHROW { return QChar::hasMirrored(ucs); } + inline QChar mirroredChar() const noexcept { return QChar::mirroredChar(ucs); } + inline bool hasMirrored() const noexcept { return QChar::hasMirrored(ucs); } QString decomposition() const; - inline Decomposition decompositionTag() const Q_DECL_NOTHROW { return QChar::decompositionTag(ucs); } + inline Decomposition decompositionTag() const noexcept { return QChar::decompositionTag(ucs); } - inline int digitValue() const Q_DECL_NOTHROW { return QChar::digitValue(ucs); } - inline QChar toLower() const Q_DECL_NOTHROW { return QChar::toLower(ucs); } - inline QChar toUpper() const Q_DECL_NOTHROW { return QChar::toUpper(ucs); } - inline QChar toTitleCase() const Q_DECL_NOTHROW { return QChar::toTitleCase(ucs); } - inline QChar toCaseFolded() const Q_DECL_NOTHROW { return QChar::toCaseFolded(ucs); } + inline int digitValue() const noexcept { return QChar::digitValue(ucs); } + inline QChar toLower() const noexcept { return QChar::toLower(ucs); } + inline QChar toUpper() const noexcept { return QChar::toUpper(ucs); } + inline QChar toTitleCase() const noexcept { return QChar::toTitleCase(ucs); } + inline QChar toCaseFolded() const noexcept { return QChar::toCaseFolded(ucs); } - inline Script script() const Q_DECL_NOTHROW { return QChar::script(ucs); } + inline Script script() const noexcept { return QChar::script(ucs); } - inline UnicodeVersion unicodeVersion() const Q_DECL_NOTHROW { return QChar::unicodeVersion(ucs); } + inline UnicodeVersion unicodeVersion() const noexcept { return QChar::unicodeVersion(ucs); } #if QT_DEPRECATED_SINCE(5, 0) - QT_DEPRECATED Q_DECL_CONSTEXPR inline char toAscii() const Q_DECL_NOTHROW { return toLatin1(); } + QT_DEPRECATED Q_DECL_CONSTEXPR inline char toAscii() const noexcept { return toLatin1(); } #endif - Q_DECL_CONSTEXPR inline char toLatin1() const Q_DECL_NOTHROW { return ucs > 0xff ? '\0' : char(ucs); } - Q_DECL_CONSTEXPR inline ushort unicode() const Q_DECL_NOTHROW { return ucs; } - Q_DECL_RELAXED_CONSTEXPR inline ushort &unicode() Q_DECL_NOTHROW { return ucs; } + Q_DECL_CONSTEXPR inline char toLatin1() const noexcept { return ucs > 0xff ? '\0' : char(ucs); } + Q_DECL_CONSTEXPR inline ushort unicode() const noexcept { return ucs; } + Q_DECL_RELAXED_CONSTEXPR inline ushort &unicode() noexcept { return ucs; } #if QT_DEPRECATED_SINCE(5, 0) - QT_DEPRECATED static Q_DECL_CONSTEXPR inline QChar fromAscii(char c) Q_DECL_NOTHROW + QT_DEPRECATED static Q_DECL_CONSTEXPR inline QChar fromAscii(char c) noexcept { return fromLatin1(c); } #endif - static Q_DECL_CONSTEXPR inline QChar fromLatin1(char c) Q_DECL_NOTHROW { return QChar(ushort(uchar(c))); } + static Q_DECL_CONSTEXPR inline QChar fromLatin1(char c) noexcept { return QChar(ushort(uchar(c))); } - Q_DECL_CONSTEXPR inline bool isNull() const Q_DECL_NOTHROW { return ucs == 0; } + Q_DECL_CONSTEXPR inline bool isNull() const noexcept { return ucs == 0; } - inline bool isPrint() const Q_DECL_NOTHROW { return QChar::isPrint(ucs); } - Q_DECL_CONSTEXPR inline bool isSpace() const Q_DECL_NOTHROW { return QChar::isSpace(ucs); } - inline bool isMark() const Q_DECL_NOTHROW { return QChar::isMark(ucs); } - inline bool isPunct() const Q_DECL_NOTHROW { return QChar::isPunct(ucs); } - inline bool isSymbol() const Q_DECL_NOTHROW { return QChar::isSymbol(ucs); } - Q_DECL_CONSTEXPR inline bool isLetter() const Q_DECL_NOTHROW { return QChar::isLetter(ucs); } - Q_DECL_CONSTEXPR inline bool isNumber() const Q_DECL_NOTHROW { return QChar::isNumber(ucs); } - Q_DECL_CONSTEXPR inline bool isLetterOrNumber() const Q_DECL_NOTHROW { return QChar::isLetterOrNumber(ucs); } - Q_DECL_CONSTEXPR inline bool isDigit() const Q_DECL_NOTHROW { return QChar::isDigit(ucs); } - Q_DECL_CONSTEXPR inline bool isLower() const Q_DECL_NOTHROW { return QChar::isLower(ucs); } - Q_DECL_CONSTEXPR inline bool isUpper() const Q_DECL_NOTHROW { return QChar::isUpper(ucs); } - Q_DECL_CONSTEXPR inline bool isTitleCase() const Q_DECL_NOTHROW { return QChar::isTitleCase(ucs); } + inline bool isPrint() const noexcept { return QChar::isPrint(ucs); } + Q_DECL_CONSTEXPR inline bool isSpace() const noexcept { return QChar::isSpace(ucs); } + inline bool isMark() const noexcept { return QChar::isMark(ucs); } + inline bool isPunct() const noexcept { return QChar::isPunct(ucs); } + inline bool isSymbol() const noexcept { return QChar::isSymbol(ucs); } + Q_DECL_CONSTEXPR inline bool isLetter() const noexcept { return QChar::isLetter(ucs); } + Q_DECL_CONSTEXPR inline bool isNumber() const noexcept { return QChar::isNumber(ucs); } + Q_DECL_CONSTEXPR inline bool isLetterOrNumber() const noexcept { return QChar::isLetterOrNumber(ucs); } + Q_DECL_CONSTEXPR inline bool isDigit() const noexcept { return QChar::isDigit(ucs); } + Q_DECL_CONSTEXPR inline bool isLower() const noexcept { return QChar::isLower(ucs); } + Q_DECL_CONSTEXPR inline bool isUpper() const noexcept { return QChar::isUpper(ucs); } + Q_DECL_CONSTEXPR inline bool isTitleCase() const noexcept { return QChar::isTitleCase(ucs); } - Q_DECL_CONSTEXPR inline bool isNonCharacter() const Q_DECL_NOTHROW { return QChar::isNonCharacter(ucs); } - Q_DECL_CONSTEXPR inline bool isHighSurrogate() const Q_DECL_NOTHROW { return QChar::isHighSurrogate(ucs); } - Q_DECL_CONSTEXPR inline bool isLowSurrogate() const Q_DECL_NOTHROW { return QChar::isLowSurrogate(ucs); } - Q_DECL_CONSTEXPR inline bool isSurrogate() const Q_DECL_NOTHROW { return QChar::isSurrogate(ucs); } + Q_DECL_CONSTEXPR inline bool isNonCharacter() const noexcept { return QChar::isNonCharacter(ucs); } + Q_DECL_CONSTEXPR inline bool isHighSurrogate() const noexcept { return QChar::isHighSurrogate(ucs); } + Q_DECL_CONSTEXPR inline bool isLowSurrogate() const noexcept { return QChar::isLowSurrogate(ucs); } + Q_DECL_CONSTEXPR inline bool isSurrogate() const noexcept { return QChar::isSurrogate(ucs); } - Q_DECL_CONSTEXPR inline uchar cell() const Q_DECL_NOTHROW { return uchar(ucs & 0xff); } - Q_DECL_CONSTEXPR inline uchar row() const Q_DECL_NOTHROW { return uchar((ucs>>8)&0xff); } - Q_DECL_RELAXED_CONSTEXPR inline void setCell(uchar acell) Q_DECL_NOTHROW { ucs = ushort((ucs & 0xff00) + acell); } - Q_DECL_RELAXED_CONSTEXPR inline void setRow(uchar arow) Q_DECL_NOTHROW { ucs = ushort((ushort(arow)<<8) + (ucs&0xff)); } + Q_DECL_CONSTEXPR inline uchar cell() const noexcept { return uchar(ucs & 0xff); } + Q_DECL_CONSTEXPR inline uchar row() const noexcept { return uchar((ucs>>8)&0xff); } + Q_DECL_RELAXED_CONSTEXPR inline void setCell(uchar acell) noexcept { ucs = ushort((ucs & 0xff00) + acell); } + Q_DECL_RELAXED_CONSTEXPR inline void setRow(uchar arow) noexcept { ucs = ushort((ushort(arow)<<8) + (ucs&0xff)); } - static Q_DECL_CONSTEXPR inline bool isNonCharacter(uint ucs4) Q_DECL_NOTHROW + static Q_DECL_CONSTEXPR inline bool isNonCharacter(uint ucs4) noexcept { return ucs4 >= 0xfdd0 && (ucs4 <= 0xfdef || (ucs4 & 0xfffe) == 0xfffe); } - static Q_DECL_CONSTEXPR inline bool isHighSurrogate(uint ucs4) Q_DECL_NOTHROW + static Q_DECL_CONSTEXPR inline bool isHighSurrogate(uint ucs4) noexcept { return ((ucs4 & 0xfffffc00) == 0xd800); } - static Q_DECL_CONSTEXPR inline bool isLowSurrogate(uint ucs4) Q_DECL_NOTHROW + static Q_DECL_CONSTEXPR inline bool isLowSurrogate(uint ucs4) noexcept { return ((ucs4 & 0xfffffc00) == 0xdc00); } - static Q_DECL_CONSTEXPR inline bool isSurrogate(uint ucs4) Q_DECL_NOTHROW + static Q_DECL_CONSTEXPR inline bool isSurrogate(uint ucs4) noexcept { return (ucs4 - 0xd800u < 2048u); } - static Q_DECL_CONSTEXPR inline bool requiresSurrogates(uint ucs4) Q_DECL_NOTHROW + static Q_DECL_CONSTEXPR inline bool requiresSurrogates(uint ucs4) noexcept { return (ucs4 >= 0x10000); } - static Q_DECL_CONSTEXPR inline uint surrogateToUcs4(ushort high, ushort low) Q_DECL_NOTHROW + static Q_DECL_CONSTEXPR inline uint surrogateToUcs4(ushort high, ushort low) noexcept { return (uint(high)<<10) + low - 0x35fdc00; } - static Q_DECL_CONSTEXPR inline uint surrogateToUcs4(QChar high, QChar low) Q_DECL_NOTHROW + static Q_DECL_CONSTEXPR inline uint surrogateToUcs4(QChar high, QChar low) noexcept { return surrogateToUcs4(high.ucs, low.ucs); } - static Q_DECL_CONSTEXPR inline ushort highSurrogate(uint ucs4) Q_DECL_NOTHROW + static Q_DECL_CONSTEXPR inline ushort highSurrogate(uint ucs4) noexcept { return ushort((ucs4>>10) + 0xd7c0); } - static Q_DECL_CONSTEXPR inline ushort lowSurrogate(uint ucs4) Q_DECL_NOTHROW + static Q_DECL_CONSTEXPR inline ushort lowSurrogate(uint ucs4) noexcept { return ushort(ucs4%0x400 + 0xdc00); } - static Category QT_FASTCALL category(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION; - static Direction QT_FASTCALL direction(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION; - static JoiningType QT_FASTCALL joiningType(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION; + static Category QT_FASTCALL category(uint ucs4) noexcept Q_DECL_CONST_FUNCTION; + static Direction QT_FASTCALL direction(uint ucs4) noexcept Q_DECL_CONST_FUNCTION; + static JoiningType QT_FASTCALL joiningType(uint ucs4) noexcept Q_DECL_CONST_FUNCTION; #if QT_DEPRECATED_SINCE(5, 3) - QT_DEPRECATED static Joining QT_FASTCALL joining(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION; + QT_DEPRECATED static Joining QT_FASTCALL joining(uint ucs4) noexcept Q_DECL_CONST_FUNCTION; #endif - static unsigned char QT_FASTCALL combiningClass(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION; + static unsigned char QT_FASTCALL combiningClass(uint ucs4) noexcept Q_DECL_CONST_FUNCTION; - static uint QT_FASTCALL mirroredChar(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION; - static bool QT_FASTCALL hasMirrored(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION; + static uint QT_FASTCALL mirroredChar(uint ucs4) noexcept Q_DECL_CONST_FUNCTION; + static bool QT_FASTCALL hasMirrored(uint ucs4) noexcept Q_DECL_CONST_FUNCTION; static QString QT_FASTCALL decomposition(uint ucs4); - static Decomposition QT_FASTCALL decompositionTag(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION; + static Decomposition QT_FASTCALL decompositionTag(uint ucs4) noexcept Q_DECL_CONST_FUNCTION; - static int QT_FASTCALL digitValue(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION; - static uint QT_FASTCALL toLower(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION; - static uint QT_FASTCALL toUpper(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION; - static uint QT_FASTCALL toTitleCase(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION; - static uint QT_FASTCALL toCaseFolded(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION; + static int QT_FASTCALL digitValue(uint ucs4) noexcept Q_DECL_CONST_FUNCTION; + static uint QT_FASTCALL toLower(uint ucs4) noexcept Q_DECL_CONST_FUNCTION; + static uint QT_FASTCALL toUpper(uint ucs4) noexcept Q_DECL_CONST_FUNCTION; + static uint QT_FASTCALL toTitleCase(uint ucs4) noexcept Q_DECL_CONST_FUNCTION; + static uint QT_FASTCALL toCaseFolded(uint ucs4) noexcept Q_DECL_CONST_FUNCTION; - static Script QT_FASTCALL script(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION; + static Script QT_FASTCALL script(uint ucs4) noexcept Q_DECL_CONST_FUNCTION; - static UnicodeVersion QT_FASTCALL unicodeVersion(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION; + static UnicodeVersion QT_FASTCALL unicodeVersion(uint ucs4) noexcept Q_DECL_CONST_FUNCTION; - static UnicodeVersion QT_FASTCALL currentUnicodeVersion() Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION; + static UnicodeVersion QT_FASTCALL currentUnicodeVersion() noexcept Q_DECL_CONST_FUNCTION; - static bool QT_FASTCALL isPrint(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION; - static Q_DECL_CONSTEXPR inline bool isSpace(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION + static bool QT_FASTCALL isPrint(uint ucs4) noexcept Q_DECL_CONST_FUNCTION; + static Q_DECL_CONSTEXPR inline bool isSpace(uint ucs4) noexcept Q_DECL_CONST_FUNCTION { // note that [0x09..0x0d] + 0x85 are exceptional Cc-s and must be handled explicitly return ucs4 == 0x20 || (ucs4 <= 0x0d && ucs4 >= 0x09) || (ucs4 > 127 && (ucs4 == 0x85 || ucs4 == 0xa0 || QChar::isSpace_helper(ucs4))); } - static bool QT_FASTCALL isMark(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION; - static bool QT_FASTCALL isPunct(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION; - static bool QT_FASTCALL isSymbol(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION; - static Q_DECL_CONSTEXPR inline bool isLetter(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION + static bool QT_FASTCALL isMark(uint ucs4) noexcept Q_DECL_CONST_FUNCTION; + static bool QT_FASTCALL isPunct(uint ucs4) noexcept Q_DECL_CONST_FUNCTION; + static bool QT_FASTCALL isSymbol(uint ucs4) noexcept Q_DECL_CONST_FUNCTION; + static Q_DECL_CONSTEXPR inline bool isLetter(uint ucs4) noexcept Q_DECL_CONST_FUNCTION { return (ucs4 >= 'A' && ucs4 <= 'z' && (ucs4 >= 'a' || ucs4 <= 'Z')) || (ucs4 > 127 && QChar::isLetter_helper(ucs4)); } - static Q_DECL_CONSTEXPR inline bool isNumber(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION + static Q_DECL_CONSTEXPR inline bool isNumber(uint ucs4) noexcept Q_DECL_CONST_FUNCTION { return (ucs4 <= '9' && ucs4 >= '0') || (ucs4 > 127 && QChar::isNumber_helper(ucs4)); } - static Q_DECL_CONSTEXPR inline bool isLetterOrNumber(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION + static Q_DECL_CONSTEXPR inline bool isLetterOrNumber(uint ucs4) noexcept Q_DECL_CONST_FUNCTION { return (ucs4 >= 'A' && ucs4 <= 'z' && (ucs4 >= 'a' || ucs4 <= 'Z')) || (ucs4 >= '0' && ucs4 <= '9') || (ucs4 > 127 && QChar::isLetterOrNumber_helper(ucs4)); } - static Q_DECL_CONSTEXPR inline bool isDigit(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION + static Q_DECL_CONSTEXPR inline bool isDigit(uint ucs4) noexcept Q_DECL_CONST_FUNCTION { return (ucs4 <= '9' && ucs4 >= '0') || (ucs4 > 127 && QChar::category(ucs4) == Number_DecimalDigit); } - static Q_DECL_CONSTEXPR inline bool isLower(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION + static Q_DECL_CONSTEXPR inline bool isLower(uint ucs4) noexcept Q_DECL_CONST_FUNCTION { return (ucs4 <= 'z' && ucs4 >= 'a') || (ucs4 > 127 && QChar::category(ucs4) == Letter_Lowercase); } - static Q_DECL_CONSTEXPR inline bool isUpper(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION + static Q_DECL_CONSTEXPR inline bool isUpper(uint ucs4) noexcept Q_DECL_CONST_FUNCTION { return (ucs4 <= 'Z' && ucs4 >= 'A') || (ucs4 > 127 && QChar::category(ucs4) == Letter_Uppercase); } - static Q_DECL_CONSTEXPR inline bool isTitleCase(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION + static Q_DECL_CONSTEXPR inline bool isTitleCase(uint ucs4) noexcept Q_DECL_CONST_FUNCTION { return ucs4 > 127 && QChar::category(ucs4) == Letter_Titlecase; } private: - static bool QT_FASTCALL isSpace_helper(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION; - static bool QT_FASTCALL isLetter_helper(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION; - static bool QT_FASTCALL isNumber_helper(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION; - static bool QT_FASTCALL isLetterOrNumber_helper(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION; + static bool QT_FASTCALL isSpace_helper(uint ucs4) noexcept Q_DECL_CONST_FUNCTION; + static bool QT_FASTCALL isLetter_helper(uint ucs4) noexcept Q_DECL_CONST_FUNCTION; + static bool QT_FASTCALL isNumber_helper(uint ucs4) noexcept Q_DECL_CONST_FUNCTION; + static bool QT_FASTCALL isLetterOrNumber_helper(uint ucs4) noexcept Q_DECL_CONST_FUNCTION; #ifdef QT_NO_CAST_FROM_ASCII - QChar(char c) Q_DECL_NOTHROW; - QChar(uchar c) Q_DECL_NOTHROW; + QChar(char c) noexcept; + QChar(uchar c) noexcept; #endif - friend Q_DECL_CONSTEXPR bool operator==(QChar, QChar) Q_DECL_NOTHROW; - friend Q_DECL_CONSTEXPR bool operator< (QChar, QChar) Q_DECL_NOTHROW; + friend Q_DECL_CONSTEXPR bool operator==(QChar, QChar) noexcept; + friend Q_DECL_CONSTEXPR bool operator< (QChar, QChar) noexcept; ushort ucs; }; Q_DECLARE_TYPEINFO(QChar, Q_MOVABLE_TYPE); -Q_DECL_CONSTEXPR inline bool operator==(QChar c1, QChar c2) Q_DECL_NOTHROW { return c1.ucs == c2.ucs; } -Q_DECL_CONSTEXPR inline bool operator< (QChar c1, QChar c2) Q_DECL_NOTHROW { return c1.ucs < c2.ucs; } +Q_DECL_CONSTEXPR inline bool operator==(QChar c1, QChar c2) noexcept { return c1.ucs == c2.ucs; } +Q_DECL_CONSTEXPR inline bool operator< (QChar c1, QChar c2) noexcept { return c1.ucs < c2.ucs; } -Q_DECL_CONSTEXPR inline bool operator!=(QChar c1, QChar c2) Q_DECL_NOTHROW { return !operator==(c1, c2); } -Q_DECL_CONSTEXPR inline bool operator>=(QChar c1, QChar c2) Q_DECL_NOTHROW { return !operator< (c1, c2); } -Q_DECL_CONSTEXPR inline bool operator> (QChar c1, QChar c2) Q_DECL_NOTHROW { return operator< (c2, c1); } -Q_DECL_CONSTEXPR inline bool operator<=(QChar c1, QChar c2) Q_DECL_NOTHROW { return !operator< (c2, c1); } +Q_DECL_CONSTEXPR inline bool operator!=(QChar c1, QChar c2) noexcept { return !operator==(c1, c2); } +Q_DECL_CONSTEXPR inline bool operator>=(QChar c1, QChar c2) noexcept { return !operator< (c1, c2); } +Q_DECL_CONSTEXPR inline bool operator> (QChar c1, QChar c2) noexcept { return operator< (c2, c1); } +Q_DECL_CONSTEXPR inline bool operator<=(QChar c1, QChar c2) noexcept { return !operator< (c2, c1); } -Q_DECL_CONSTEXPR inline bool operator==(QChar lhs, std::nullptr_t) Q_DECL_NOTHROW { return lhs.isNull(); } -Q_DECL_CONSTEXPR inline bool operator< (QChar, std::nullptr_t) Q_DECL_NOTHROW { return false; } -Q_DECL_CONSTEXPR inline bool operator==(std::nullptr_t, QChar rhs) Q_DECL_NOTHROW { return rhs.isNull(); } -Q_DECL_CONSTEXPR inline bool operator< (std::nullptr_t, QChar rhs) Q_DECL_NOTHROW { return !rhs.isNull(); } +Q_DECL_CONSTEXPR inline bool operator==(QChar lhs, std::nullptr_t) noexcept { return lhs.isNull(); } +Q_DECL_CONSTEXPR inline bool operator< (QChar, std::nullptr_t) noexcept { return false; } +Q_DECL_CONSTEXPR inline bool operator==(std::nullptr_t, QChar rhs) noexcept { return rhs.isNull(); } +Q_DECL_CONSTEXPR inline bool operator< (std::nullptr_t, QChar rhs) noexcept { return !rhs.isNull(); } -Q_DECL_CONSTEXPR inline bool operator!=(QChar lhs, std::nullptr_t) Q_DECL_NOTHROW { return !operator==(lhs, nullptr); } -Q_DECL_CONSTEXPR inline bool operator>=(QChar lhs, std::nullptr_t) Q_DECL_NOTHROW { return !operator< (lhs, nullptr); } -Q_DECL_CONSTEXPR inline bool operator> (QChar lhs, std::nullptr_t) Q_DECL_NOTHROW { return operator< (nullptr, lhs); } -Q_DECL_CONSTEXPR inline bool operator<=(QChar lhs, std::nullptr_t) Q_DECL_NOTHROW { return !operator< (nullptr, lhs); } +Q_DECL_CONSTEXPR inline bool operator!=(QChar lhs, std::nullptr_t) noexcept { return !operator==(lhs, nullptr); } +Q_DECL_CONSTEXPR inline bool operator>=(QChar lhs, std::nullptr_t) noexcept { return !operator< (lhs, nullptr); } +Q_DECL_CONSTEXPR inline bool operator> (QChar lhs, std::nullptr_t) noexcept { return operator< (nullptr, lhs); } +Q_DECL_CONSTEXPR inline bool operator<=(QChar lhs, std::nullptr_t) noexcept { return !operator< (nullptr, lhs); } -Q_DECL_CONSTEXPR inline bool operator!=(std::nullptr_t, QChar rhs) Q_DECL_NOTHROW { return !operator==(nullptr, rhs); } -Q_DECL_CONSTEXPR inline bool operator>=(std::nullptr_t, QChar rhs) Q_DECL_NOTHROW { return !operator< (nullptr, rhs); } -Q_DECL_CONSTEXPR inline bool operator> (std::nullptr_t, QChar rhs) Q_DECL_NOTHROW { return operator< (rhs, nullptr); } -Q_DECL_CONSTEXPR inline bool operator<=(std::nullptr_t, QChar rhs) Q_DECL_NOTHROW { return !operator< (rhs, nullptr); } +Q_DECL_CONSTEXPR inline bool operator!=(std::nullptr_t, QChar rhs) noexcept { return !operator==(nullptr, rhs); } +Q_DECL_CONSTEXPR inline bool operator>=(std::nullptr_t, QChar rhs) noexcept { return !operator< (nullptr, rhs); } +Q_DECL_CONSTEXPR inline bool operator> (std::nullptr_t, QChar rhs) noexcept { return operator< (rhs, nullptr); } +Q_DECL_CONSTEXPR inline bool operator<=(std::nullptr_t, QChar rhs) noexcept { return !operator< (rhs, nullptr); } #ifndef QT_NO_DATASTREAM Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, QChar); diff --git a/src/corelib/tools/qcollator.h b/src/corelib/tools/qcollator.h index 700de739bb..6c76ef038f 100644 --- a/src/corelib/tools/qcollator.h +++ b/src/corelib/tools/qcollator.h @@ -58,10 +58,10 @@ public: ~QCollatorSortKey(); QCollatorSortKey &operator=(const QCollatorSortKey &other); #ifdef Q_COMPILER_RVALUE_REFS - inline QCollatorSortKey &operator=(QCollatorSortKey &&other) Q_DECL_NOTHROW + inline QCollatorSortKey &operator=(QCollatorSortKey &&other) noexcept { swap(other); return *this; } #endif - void swap(QCollatorSortKey &other) Q_DECL_NOTHROW + void swap(QCollatorSortKey &other) noexcept { d.swap(other.d); } int compare(const QCollatorSortKey &key) const; @@ -88,13 +88,13 @@ public: ~QCollator(); QCollator &operator=(const QCollator &); #ifdef Q_COMPILER_RVALUE_REFS - QCollator(QCollator &&other) Q_DECL_NOTHROW + QCollator(QCollator &&other) noexcept : d(other.d) { other.d = nullptr; } - QCollator &operator=(QCollator &&other) Q_DECL_NOTHROW + QCollator &operator=(QCollator &&other) noexcept { swap(other); return *this; } #endif - void swap(QCollator &other) Q_DECL_NOTHROW + void swap(QCollator &other) noexcept { qSwap(d, other.d); } void setLocale(const QLocale &locale); diff --git a/src/corelib/tools/qcommandlineoption.cpp b/src/corelib/tools/qcommandlineoption.cpp index c2b86014ba..aff684fad2 100644 --- a/src/corelib/tools/qcommandlineoption.cpp +++ b/src/corelib/tools/qcommandlineoption.cpp @@ -254,7 +254,7 @@ namespace { typedef QString argument_type; Q_NEVER_INLINE - result_type operator()(const QString &name) const Q_DECL_NOEXCEPT + result_type operator()(const QString &name) const noexcept { if (Q_UNLIKELY(name.isEmpty())) return warn("be empty"); @@ -271,7 +271,7 @@ namespace { } Q_NEVER_INLINE - static bool warn(const char *what) Q_DECL_NOEXCEPT + static bool warn(const char *what) noexcept { qWarning("QCommandLineOption: Option names cannot %s", what); return true; diff --git a/src/corelib/tools/qcommandlineoption.h b/src/corelib/tools/qcommandlineoption.h index 276be042de..643427f6fb 100644 --- a/src/corelib/tools/qcommandlineoption.h +++ b/src/corelib/tools/qcommandlineoption.h @@ -72,10 +72,10 @@ public: QCommandLineOption &operator=(const QCommandLineOption &other); #ifdef Q_COMPILER_RVALUE_REFS - QCommandLineOption &operator=(QCommandLineOption &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QCommandLineOption &operator=(QCommandLineOption &&other) noexcept { swap(other); return *this; } #endif - void swap(QCommandLineOption &other) Q_DECL_NOTHROW + void swap(QCommandLineOption &other) noexcept { qSwap(d, other.d); } QStringList names() const; diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index d06b8a04d2..54e52c4cd1 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -256,7 +256,7 @@ static QString toOffsetString(Qt::DateFormat format, int offset) #if QT_CONFIG(datestring) // Parse offset in [+-]HH[[:]mm] format -static int fromOffsetString(const QStringRef &offsetString, bool *valid) Q_DECL_NOTHROW +static int fromOffsetString(const QStringRef &offsetString, bool *valid) noexcept { *valid = false; @@ -3210,7 +3210,7 @@ QDateTime::QDateTime(const QDate &date, const QTime &time, const QTimeZone &time /*! Constructs a copy of the \a other datetime. */ -QDateTime::QDateTime(const QDateTime &other) Q_DECL_NOTHROW +QDateTime::QDateTime(const QDateTime &other) noexcept : d(other.d) { } @@ -3220,7 +3220,7 @@ QDateTime::QDateTime(const QDateTime &other) Q_DECL_NOTHROW Moves the content of the temporary \a other datetime to this object and leaves \a other in an unspecified (but proper) state. */ -QDateTime::QDateTime(QDateTime &&other) Q_DECL_NOTHROW +QDateTime::QDateTime(QDateTime &&other) noexcept : d(std::move(other.d)) { } @@ -3237,7 +3237,7 @@ QDateTime::~QDateTime() copy. */ -QDateTime &QDateTime::operator=(const QDateTime &other) Q_DECL_NOTHROW +QDateTime &QDateTime::operator=(const QDateTime &other) noexcept { d = other.d; return *this; @@ -4465,7 +4465,7 @@ QDateTime QDateTime::currentDateTimeUtc() return QDateTime(d, t, Qt::UTC); } -qint64 QDateTime::currentMSecsSinceEpoch() Q_DECL_NOTHROW +qint64 QDateTime::currentMSecsSinceEpoch() noexcept { SYSTEMTIME st; memset(&st, 0, sizeof(SYSTEMTIME)); @@ -4476,7 +4476,7 @@ qint64 QDateTime::currentMSecsSinceEpoch() Q_DECL_NOTHROW - julianDayFromDate(1970, 1, 1)) * Q_INT64_C(86400000); } -qint64 QDateTime::currentSecsSinceEpoch() Q_DECL_NOTHROW +qint64 QDateTime::currentSecsSinceEpoch() noexcept { SYSTEMTIME st; memset(&st, 0, sizeof(SYSTEMTIME)); @@ -4508,7 +4508,7 @@ QDateTime QDateTime::currentDateTimeUtc() return fromMSecsSinceEpoch(currentMSecsSinceEpoch(), Qt::UTC); } -qint64 QDateTime::currentMSecsSinceEpoch() Q_DECL_NOTHROW +qint64 QDateTime::currentMSecsSinceEpoch() noexcept { // posix compliant system // we have milliseconds @@ -4517,7 +4517,7 @@ qint64 QDateTime::currentMSecsSinceEpoch() Q_DECL_NOTHROW return qint64(tv.tv_sec) * Q_INT64_C(1000) + tv.tv_usec / 1000; } -qint64 QDateTime::currentSecsSinceEpoch() Q_DECL_NOTHROW +qint64 QDateTime::currentSecsSinceEpoch() noexcept { struct timeval tv; gettimeofday(&tv, 0); @@ -5414,7 +5414,7 @@ uint qHash(const QDateTime &key, uint seed) Returns the hash value for the \a key, using \a seed to seed the calculation. */ -uint qHash(const QDate &key, uint seed) Q_DECL_NOTHROW +uint qHash(const QDate &key, uint seed) noexcept { return qHash(key.toJulianDay(), seed); } @@ -5425,7 +5425,7 @@ uint qHash(const QDate &key, uint seed) Q_DECL_NOTHROW Returns the hash value for the \a key, using \a seed to seed the calculation. */ -uint qHash(const QTime &key, uint seed) Q_DECL_NOTHROW +uint qHash(const QTime &key, uint seed) noexcept { return qHash(key.msecsSinceStartOfDay(), seed); } diff --git a/src/corelib/tools/qdatetime.h b/src/corelib/tools/qdatetime.h index 43271b34ed..144fb9b28a 100644 --- a/src/corelib/tools/qdatetime.h +++ b/src/corelib/tools/qdatetime.h @@ -266,16 +266,16 @@ public: #if QT_CONFIG(timezone) QDateTime(const QDate &date, const QTime &time, const QTimeZone &timeZone); #endif // timezone - QDateTime(const QDateTime &other) Q_DECL_NOTHROW; - QDateTime(QDateTime &&other) Q_DECL_NOTHROW; + QDateTime(const QDateTime &other) noexcept; + QDateTime(QDateTime &&other) noexcept; ~QDateTime(); #ifdef Q_COMPILER_RVALUE_REFS - QDateTime &operator=(QDateTime &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QDateTime &operator=(QDateTime &&other) noexcept { swap(other); return *this; } #endif - QDateTime &operator=(const QDateTime &other) Q_DECL_NOTHROW; + QDateTime &operator=(const QDateTime &other) noexcept; - void swap(QDateTime &other) Q_DECL_NOTHROW { qSwap(d.d, other.d.d); } + void swap(QDateTime &other) noexcept { qSwap(d.d, other.d.d); } bool isNull() const; bool isValid() const; @@ -366,8 +366,8 @@ public: static QDateTime fromSecsSinceEpoch(qint64 secs, const QTimeZone &timeZone); #endif - static qint64 currentMSecsSinceEpoch() Q_DECL_NOTHROW; - static qint64 currentSecsSinceEpoch() Q_DECL_NOTHROW; + static qint64 currentMSecsSinceEpoch() noexcept; + static qint64 currentSecsSinceEpoch() noexcept; #if defined(Q_OS_DARWIN) || defined(Q_QDOC) static QDateTime fromCFDate(CFDateRef date); @@ -410,8 +410,8 @@ Q_CORE_EXPORT QDebug operator<<(QDebug, const QDateTime &); // QDateTime is not noexcept for now -- to be revised once // timezone and calendaring support is added Q_CORE_EXPORT uint qHash(const QDateTime &key, uint seed = 0); -Q_CORE_EXPORT uint qHash(const QDate &key, uint seed = 0) Q_DECL_NOTHROW; -Q_CORE_EXPORT uint qHash(const QTime &key, uint seed = 0) Q_DECL_NOTHROW; +Q_CORE_EXPORT uint qHash(const QDate &key, uint seed = 0) noexcept; +Q_CORE_EXPORT uint qHash(const QTime &key, uint seed = 0) noexcept; QT_END_NAMESPACE diff --git a/src/corelib/tools/qeasingcurve.h b/src/corelib/tools/qeasingcurve.h index 74bde5825a..1791f19199 100644 --- a/src/corelib/tools/qeasingcurve.h +++ b/src/corelib/tools/qeasingcurve.h @@ -81,12 +81,12 @@ public: QEasingCurve &operator=(const QEasingCurve &other) { if ( this != &other ) { QEasingCurve copy(other); swap(copy); } return *this; } #ifdef Q_COMPILER_RVALUE_REFS - QEasingCurve(QEasingCurve &&other) Q_DECL_NOTHROW : d_ptr(other.d_ptr) { other.d_ptr = nullptr; } - QEasingCurve &operator=(QEasingCurve &&other) Q_DECL_NOTHROW + QEasingCurve(QEasingCurve &&other) noexcept : d_ptr(other.d_ptr) { other.d_ptr = nullptr; } + QEasingCurve &operator=(QEasingCurve &&other) noexcept { qSwap(d_ptr, other.d_ptr); return *this; } #endif - void swap(QEasingCurve &other) Q_DECL_NOTHROW { qSwap(d_ptr, other.d_ptr); } + void swap(QEasingCurve &other) noexcept { qSwap(d_ptr, other.d_ptr); } bool operator==(const QEasingCurve &other) const; inline bool operator!=(const QEasingCurve &other) const diff --git a/src/corelib/tools/qhash.cpp b/src/corelib/tools/qhash.cpp index 32e9a4269c..dd22a38be1 100644 --- a/src/corelib/tools/qhash.cpp +++ b/src/corelib/tools/qhash.cpp @@ -197,7 +197,7 @@ static uint crc32(...) } #endif -static inline uint hash(const uchar *p, size_t len, uint seed) Q_DECL_NOTHROW +static inline uint hash(const uchar *p, size_t len, uint seed) noexcept { uint h = seed; @@ -210,12 +210,12 @@ static inline uint hash(const uchar *p, size_t len, uint seed) Q_DECL_NOTHROW return h; } -uint qHashBits(const void *p, size_t len, uint seed) Q_DECL_NOTHROW +uint qHashBits(const void *p, size_t len, uint seed) noexcept { return hash(static_cast(p), int(len), seed); } -static inline uint hash(const QChar *p, size_t len, uint seed) Q_DECL_NOTHROW +static inline uint hash(const QChar *p, size_t len, uint seed) noexcept { uint h = seed; @@ -228,29 +228,29 @@ static inline uint hash(const QChar *p, size_t len, uint seed) Q_DECL_NOTHROW return h; } -uint qHash(const QByteArray &key, uint seed) Q_DECL_NOTHROW +uint qHash(const QByteArray &key, uint seed) noexcept { return hash(reinterpret_cast(key.constData()), size_t(key.size()), seed); } #if QT_STRINGVIEW_LEVEL < 2 -uint qHash(const QString &key, uint seed) Q_DECL_NOTHROW +uint qHash(const QString &key, uint seed) noexcept { return hash(key.unicode(), size_t(key.size()), seed); } -uint qHash(const QStringRef &key, uint seed) Q_DECL_NOTHROW +uint qHash(const QStringRef &key, uint seed) noexcept { return hash(key.unicode(), size_t(key.size()), seed); } #endif -uint qHash(QStringView key, uint seed) Q_DECL_NOTHROW +uint qHash(QStringView key, uint seed) noexcept { return hash(key.data(), key.size(), seed); } -uint qHash(const QBitArray &bitArray, uint seed) Q_DECL_NOTHROW +uint qHash(const QBitArray &bitArray, uint seed) noexcept { int m = bitArray.d.size() - 1; uint result = hash(reinterpret_cast(bitArray.d.constData()), @@ -264,7 +264,7 @@ uint qHash(const QBitArray &bitArray, uint seed) Q_DECL_NOTHROW return result; } -uint qHash(QLatin1String key, uint seed) Q_DECL_NOTHROW +uint qHash(QLatin1String key, uint seed) noexcept { return hash(reinterpret_cast(key.data()), size_t(key.size()), seed); } @@ -398,7 +398,7 @@ void qSetGlobalQHashSeed(int newSeed) This function can hash discontiguous memory by invoking it on each chunk, passing the previous's result in the next call's \a chained argument. */ -uint qt_hash(QStringView key, uint chained) Q_DECL_NOTHROW +uint qt_hash(QStringView key, uint chained) noexcept { auto n = key.size(); auto p = key.utf16(); @@ -938,7 +938,7 @@ void QHashData::checkSanity() Returns the hash value for the \a key, using \a seed to seed the calculation. */ -uint qHash(float key, uint seed) Q_DECL_NOTHROW +uint qHash(float key, uint seed) noexcept { return key != 0.0f ? hash(reinterpret_cast(&key), sizeof(key), seed) : seed ; } @@ -948,7 +948,7 @@ uint qHash(float key, uint seed) Q_DECL_NOTHROW Returns the hash value for the \a key, using \a seed to seed the calculation. */ -uint qHash(double key, uint seed) Q_DECL_NOTHROW +uint qHash(double key, uint seed) noexcept { return key != 0.0 ? hash(reinterpret_cast(&key), sizeof(key), seed) : seed ; } @@ -959,7 +959,7 @@ uint qHash(double key, uint seed) Q_DECL_NOTHROW Returns the hash value for the \a key, using \a seed to seed the calculation. */ -uint qHash(long double key, uint seed) Q_DECL_NOTHROW +uint qHash(long double key, uint seed) noexcept { return key != 0.0L ? hash(reinterpret_cast(&key), sizeof(key), seed) : seed ; } diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h index a586ca5671..9a733180a5 100644 --- a/src/corelib/tools/qhash.h +++ b/src/corelib/tools/qhash.h @@ -240,7 +240,7 @@ class QHash static inline int alignOfNode() { return qMax(sizeof(void*), Q_ALIGNOF(Node)); } public: - inline QHash() Q_DECL_NOTHROW : d(const_cast(&QHashData::shared_null)) { } + inline QHash() noexcept : d(const_cast(&QHashData::shared_null)) { } #ifdef Q_COMPILER_INITIALIZER_LISTS inline QHash(std::initializer_list > list) : d(const_cast(&QHashData::shared_null)) @@ -255,11 +255,11 @@ public: QHash &operator=(const QHash &other); #ifdef Q_COMPILER_RVALUE_REFS - QHash(QHash &&other) Q_DECL_NOTHROW : d(other.d) { other.d = const_cast(&QHashData::shared_null); } - QHash &operator=(QHash &&other) Q_DECL_NOTHROW + QHash(QHash &&other) noexcept : d(other.d) { other.d = const_cast(&QHashData::shared_null); } + QHash &operator=(QHash &&other) noexcept { QHash moved(std::move(other)); swap(moved); return *this; } #endif - void swap(QHash &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + void swap(QHash &other) noexcept { qSwap(d, other.d); } bool operator==(const QHash &other) const; bool operator!=(const QHash &other) const { return !(*this == other); } @@ -473,7 +473,7 @@ public: inline const_key_value_iterator constKeyValueEnd() const { return const_key_value_iterator(end()); } QPair equal_range(const Key &key); - QPair equal_range(const Key &key) const Q_DECL_NOTHROW; + QPair equal_range(const Key &key) const noexcept; iterator erase(iterator it) { return erase(const_iterator(it.i)); } iterator erase(const_iterator it); @@ -512,11 +512,11 @@ private: static void duplicateNode(QHashData::Node *originalNode, void *newNode); - bool isValidIterator(const iterator &it) const Q_DECL_NOTHROW + bool isValidIterator(const iterator &it) const noexcept { return isValidNode(it.i); } - bool isValidIterator(const const_iterator &it) const Q_DECL_NOTHROW + bool isValidIterator(const const_iterator &it) const noexcept { return isValidNode(it.i); } - bool isValidNode(QHashData::Node *node) const Q_DECL_NOTHROW + bool isValidNode(QHashData::Node *node) const noexcept { #if defined(QT_DEBUG) && !defined(Q_HASH_NO_ITERATOR_DEBUG) while (node->next) @@ -993,7 +993,7 @@ QPair::iterator, typename QHash::iterator> QHash< } template -QPair::const_iterator, typename QHash::const_iterator> QHash::equal_range(const Key &akey) const Q_DECL_NOTHROW +QPair::const_iterator, typename QHash::const_iterator> QHash::equal_range(const Key &akey) const noexcept { Node *node = *findNode(akey); const_iterator firstIt = const_iterator(node); @@ -1020,7 +1020,7 @@ template class QMultiHash : public QHash { public: - QMultiHash() Q_DECL_NOTHROW {} + QMultiHash() noexcept {} #ifdef Q_COMPILER_INITIALIZER_LISTS inline QMultiHash(std::initializer_list > list) { @@ -1034,9 +1034,9 @@ public: QMultiHash(const QHash &other) : QHash(other) {} #ifdef Q_COMPILER_RVALUE_REFS - QMultiHash(QHash &&other) Q_DECL_NOTHROW : QHash(std::move(other)) {} + QMultiHash(QHash &&other) noexcept : QHash(std::move(other)) {} #endif - void swap(QMultiHash &other) Q_DECL_NOTHROW { QHash::swap(other); } // prevent QMultiHash<->QHash swaps + void swap(QMultiHash &other) noexcept { QHash::swap(other); } // prevent QMultiHash<->QHash swaps inline typename QHash::iterator replace(const Key &key, const T &value) { return QHash::insert(key, value); } diff --git a/src/corelib/tools/qhashfunctions.h b/src/corelib/tools/qhashfunctions.h index d013c26d66..2d1ff01294 100644 --- a/src/corelib/tools/qhashfunctions.h +++ b/src/corelib/tools/qhashfunctions.h @@ -67,49 +67,49 @@ class QLatin1String; Q_CORE_EXPORT int qGlobalQHashSeed(); Q_CORE_EXPORT void qSetGlobalQHashSeed(int newSeed); -Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qHashBits(const void *p, size_t size, uint seed = 0) Q_DECL_NOTHROW; +Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qHashBits(const void *p, size_t size, uint seed = 0) noexcept; -Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(char key, uint seed = 0) Q_DECL_NOTHROW { return uint(key) ^ seed; } -Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(uchar key, uint seed = 0) Q_DECL_NOTHROW { return uint(key) ^ seed; } -Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(signed char key, uint seed = 0) Q_DECL_NOTHROW { return uint(key) ^ seed; } -Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(ushort key, uint seed = 0) Q_DECL_NOTHROW { return uint(key) ^ seed; } -Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(short key, uint seed = 0) Q_DECL_NOTHROW { return uint(key) ^ seed; } -Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(uint key, uint seed = 0) Q_DECL_NOTHROW { return key ^ seed; } -Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(int key, uint seed = 0) Q_DECL_NOTHROW { return uint(key) ^ seed; } -Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(ulong key, uint seed = 0) Q_DECL_NOTHROW +Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(char key, uint seed = 0) noexcept { return uint(key) ^ seed; } +Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(uchar key, uint seed = 0) noexcept { return uint(key) ^ seed; } +Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(signed char key, uint seed = 0) noexcept { return uint(key) ^ seed; } +Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(ushort key, uint seed = 0) noexcept { return uint(key) ^ seed; } +Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(short key, uint seed = 0) noexcept { return uint(key) ^ seed; } +Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(uint key, uint seed = 0) noexcept { return key ^ seed; } +Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(int key, uint seed = 0) noexcept { return uint(key) ^ seed; } +Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(ulong key, uint seed = 0) noexcept { return (sizeof(ulong) > sizeof(uint)) ? (uint(((key >> (8 * sizeof(uint) - 1)) ^ key) & (~0U)) ^ seed) : (uint(key & (~0U)) ^ seed); } -Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(long key, uint seed = 0) Q_DECL_NOTHROW { return qHash(ulong(key), seed); } -Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(quint64 key, uint seed = 0) Q_DECL_NOTHROW +Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(long key, uint seed = 0) noexcept { return qHash(ulong(key), seed); } +Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(quint64 key, uint seed = 0) noexcept { return uint(((key >> (8 * sizeof(uint) - 1)) ^ key) & (~0U)) ^ seed; } -Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(qint64 key, uint seed = 0) Q_DECL_NOTHROW { return qHash(quint64(key), seed); } -Q_CORE_EXPORT Q_DECL_CONST_FUNCTION uint qHash(float key, uint seed = 0) Q_DECL_NOTHROW; -Q_CORE_EXPORT Q_DECL_CONST_FUNCTION uint qHash(double key, uint seed = 0) Q_DECL_NOTHROW; +Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(qint64 key, uint seed = 0) noexcept { return qHash(quint64(key), seed); } +Q_CORE_EXPORT Q_DECL_CONST_FUNCTION uint qHash(float key, uint seed = 0) noexcept; +Q_CORE_EXPORT Q_DECL_CONST_FUNCTION uint qHash(double key, uint seed = 0) noexcept; #if !defined(Q_OS_DARWIN) || defined(Q_CLANG_QDOC) -Q_CORE_EXPORT Q_DECL_CONST_FUNCTION uint qHash(long double key, uint seed = 0) Q_DECL_NOTHROW; +Q_CORE_EXPORT Q_DECL_CONST_FUNCTION uint qHash(long double key, uint seed = 0) noexcept; #endif -Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(const QChar key, uint seed = 0) Q_DECL_NOTHROW { return qHash(key.unicode(), seed); } -Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qHash(const QByteArray &key, uint seed = 0) Q_DECL_NOTHROW; +Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(const QChar key, uint seed = 0) noexcept { return qHash(key.unicode(), seed); } +Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qHash(const QByteArray &key, uint seed = 0) noexcept; #if QT_STRINGVIEW_LEVEL < 2 -Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qHash(const QString &key, uint seed = 0) Q_DECL_NOTHROW; -Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qHash(const QStringRef &key, uint seed = 0) Q_DECL_NOTHROW; +Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qHash(const QString &key, uint seed = 0) noexcept; +Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qHash(const QStringRef &key, uint seed = 0) noexcept; #endif -Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qHash(QStringView key, uint seed = 0) Q_DECL_NOTHROW; -Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qHash(const QBitArray &key, uint seed = 0) Q_DECL_NOTHROW; -Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qHash(QLatin1String key, uint seed = 0) Q_DECL_NOTHROW; -Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qt_hash(QStringView key, uint chained = 0) Q_DECL_NOTHROW; +Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qHash(QStringView key, uint seed = 0) noexcept; +Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qHash(const QBitArray &key, uint seed = 0) noexcept; +Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qHash(QLatin1String key, uint seed = 0) noexcept; +Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qt_hash(QStringView key, uint chained = 0) noexcept; -Q_DECL_CONST_FUNCTION inline uint qHash(std::nullptr_t, uint seed = 0) Q_DECL_NOTHROW +Q_DECL_CONST_FUNCTION inline uint qHash(std::nullptr_t, uint seed = 0) noexcept { return qHash(reinterpret_cast(nullptr), seed); } -template inline uint qHash(const T *key, uint seed = 0) Q_DECL_NOTHROW +template inline uint qHash(const T *key, uint seed = 0) noexcept { return qHash(reinterpret_cast(key), seed); } diff --git a/src/corelib/tools/qiterator.h b/src/corelib/tools/qiterator.h index 586d26cbad..90921af16e 100644 --- a/src/corelib/tools/qiterator.h +++ b/src/corelib/tools/qiterator.h @@ -197,8 +197,8 @@ public: return std::pair(i.key(), i.value()); } - friend bool operator==(QKeyValueIterator lhs, QKeyValueIterator rhs) Q_DECL_NOEXCEPT { return lhs.i == rhs.i; } - friend bool operator!=(QKeyValueIterator lhs, QKeyValueIterator rhs) Q_DECL_NOEXCEPT { return lhs.i != rhs.i; } + friend bool operator==(QKeyValueIterator lhs, QKeyValueIterator rhs) noexcept { return lhs.i == rhs.i; } + friend bool operator!=(QKeyValueIterator lhs, QKeyValueIterator rhs) noexcept { return lhs.i != rhs.i; } inline QKeyValueIterator &operator++() { ++i; return *this; } inline QKeyValueIterator operator++(int) { return QKeyValueIterator(i++);} diff --git a/src/corelib/tools/qlinkedlist.h b/src/corelib/tools/qlinkedlist.h index 1e6d4df474..91367a74b3 100644 --- a/src/corelib/tools/qlinkedlist.h +++ b/src/corelib/tools/qlinkedlist.h @@ -80,7 +80,7 @@ class QLinkedList union { QLinkedListData *d; QLinkedListNode *e; }; public: - inline QLinkedList() Q_DECL_NOTHROW : d(const_cast(&QLinkedListData::shared_null)) { } + inline QLinkedList() noexcept : d(const_cast(&QLinkedListData::shared_null)) { } inline QLinkedList(const QLinkedList &l) : d(l.d) { d->ref.ref(); if (!d->sharable) detach(); } #if defined(Q_COMPILER_INITIALIZER_LISTS) inline QLinkedList(std::initializer_list list) @@ -92,12 +92,12 @@ public: ~QLinkedList(); QLinkedList &operator=(const QLinkedList &); #ifdef Q_COMPILER_RVALUE_REFS - QLinkedList(QLinkedList &&other) Q_DECL_NOTHROW + QLinkedList(QLinkedList &&other) noexcept : d(other.d) { other.d = const_cast(&QLinkedListData::shared_null); } - QLinkedList &operator=(QLinkedList &&other) Q_DECL_NOTHROW + QLinkedList &operator=(QLinkedList &&other) noexcept { QLinkedList moved(std::move(other)); swap(moved); return *this; } #endif - inline void swap(QLinkedList &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + inline void swap(QLinkedList &other) noexcept { qSwap(d, other.d); } bool operator==(const QLinkedList &l) const; inline bool operator!=(const QLinkedList &l) const { return !(*this == l); } @@ -137,10 +137,10 @@ public: inline iterator() : i(nullptr) {} inline iterator(Node *n) : i(n) {} #if QT_VERSION < QT_VERSION_CHECK(6,0,0) - iterator(const iterator &other) Q_DECL_NOTHROW : i(other.i) {} - iterator &operator=(const iterator &other) Q_DECL_NOTHROW { i = other.i; return *this; } - iterator(iterator &&other) Q_DECL_NOTHROW : i(other.i) {} - iterator &operator=(iterator &&other) Q_DECL_NOTHROW { return *this = other; } + iterator(const iterator &other) noexcept : i(other.i) {} + iterator &operator=(const iterator &other) noexcept { i = other.i; return *this; } + iterator(iterator &&other) noexcept : i(other.i) {} + iterator &operator=(iterator &&other) noexcept { return *this = other; } #endif inline T &operator*() const { return i->t; } inline T *operator->() const { return &i->t; } @@ -176,10 +176,10 @@ public: inline const_iterator(Node *n) : i(n) {} inline const_iterator(iterator ci) : i(ci.i){} #if QT_VERSION < QT_VERSION_CHECK(6,0,0) - const_iterator(const const_iterator &other) Q_DECL_NOTHROW : i(other.i) {} - const_iterator &operator=(const const_iterator &other) Q_DECL_NOTHROW { i = other.i; return *this; } - const_iterator(const_iterator &&other) Q_DECL_NOTHROW : i(other.i) {} - const_iterator &operator=(const_iterator &&other) Q_DECL_NOTHROW { return *this = other; } + const_iterator(const const_iterator &other) noexcept : i(other.i) {} + const_iterator &operator=(const const_iterator &other) noexcept { i = other.i; return *this; } + const_iterator(const_iterator &&other) noexcept : i(other.i) {} + const_iterator &operator=(const_iterator &&other) noexcept { return *this = other; } #endif inline const T &operator*() const { return i->t; } inline const T *operator->() const { return &i->t; } @@ -203,20 +203,20 @@ public: typedef std::reverse_iterator const_reverse_iterator; inline iterator begin() { detach(); return e->n; } - inline const_iterator begin() const Q_DECL_NOTHROW { return e->n; } - inline const_iterator cbegin() const Q_DECL_NOTHROW { return e->n; } - inline const_iterator constBegin() const Q_DECL_NOTHROW { return e->n; } + inline const_iterator begin() const noexcept { return e->n; } + inline const_iterator cbegin() const noexcept { return e->n; } + inline const_iterator constBegin() const noexcept { return e->n; } inline iterator end() { detach(); return e; } - inline const_iterator end() const Q_DECL_NOTHROW { return e; } - inline const_iterator cend() const Q_DECL_NOTHROW { return e; } - inline const_iterator constEnd() const Q_DECL_NOTHROW { return e; } + inline const_iterator end() const noexcept { return e; } + inline const_iterator cend() const noexcept { return e; } + inline const_iterator constEnd() const noexcept { return e; } reverse_iterator rbegin() { return reverse_iterator(end()); } reverse_iterator rend() { return reverse_iterator(begin()); } - const_reverse_iterator rbegin() const Q_DECL_NOTHROW { return const_reverse_iterator(end()); } - const_reverse_iterator rend() const Q_DECL_NOTHROW { return const_reverse_iterator(begin()); } - const_reverse_iterator crbegin() const Q_DECL_NOTHROW { return const_reverse_iterator(end()); } - const_reverse_iterator crend() const Q_DECL_NOTHROW { return const_reverse_iterator(begin()); } + const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); } + const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); } + const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(end()); } + const_reverse_iterator crend() const noexcept { return const_reverse_iterator(begin()); } iterator insert(iterator before, const T &t); iterator erase(iterator pos); diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h index 34577acaa5..3371920ffc 100644 --- a/src/corelib/tools/qlist.h +++ b/src/corelib/tools/qlist.h @@ -111,11 +111,11 @@ struct Q_CORE_EXPORT QListData { void remove(int i); void remove(int i, int n); void move(int from, int to); - inline int size() const Q_DECL_NOTHROW { return d->end - d->begin; } - inline bool isEmpty() const Q_DECL_NOTHROW { return d->end == d->begin; } - inline void **at(int i) const Q_DECL_NOTHROW { return d->array + d->begin + i; } - inline void **begin() const Q_DECL_NOTHROW { return d->array + d->begin; } - inline void **end() const Q_DECL_NOTHROW { return d->array + d->end; } + inline int size() const noexcept { return d->end - d->begin; } + inline bool isEmpty() const noexcept { return d->end == d->begin; } + inline void **at(int i) const noexcept { return d->array + d->begin + i; } + inline void **begin() const noexcept { return d->array + d->begin; } + inline void **end() const noexcept { return d->array + d->end; } }; namespace QtPrivate { @@ -156,17 +156,17 @@ private: union { QListData p; QListData::Data *d; }; public: - inline QList() Q_DECL_NOTHROW : d(const_cast(&QListData::shared_null)) { } + inline QList() noexcept : d(const_cast(&QListData::shared_null)) { } QList(const QList &l); ~QList(); QList &operator=(const QList &l); #ifdef Q_COMPILER_RVALUE_REFS - inline QList(QList &&other) Q_DECL_NOTHROW + inline QList(QList &&other) noexcept : d(other.d) { other.d = const_cast(&QListData::shared_null); } - inline QList &operator=(QList &&other) Q_DECL_NOTHROW + inline QList &operator=(QList &&other) noexcept { QList moved(std::move(other)); swap(moved); return *this; } #endif - inline void swap(QList &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + inline void swap(QList &other) noexcept { qSwap(d, other.d); } #ifdef Q_COMPILER_INITIALIZER_LISTS inline QList(std::initializer_list args) : d(const_cast(&QListData::shared_null)) @@ -175,7 +175,7 @@ public: bool operator==(const QList &l) const; inline bool operator!=(const QList &l) const { return !(*this == l); } - inline int size() const Q_DECL_NOTHROW { return p.size(); } + inline int size() const noexcept { return p.size(); } inline void detach() { if (d->ref.isShared()) detach_helper(); } @@ -198,9 +198,9 @@ public: d->ref.setSharable(sharable); } #endif - inline bool isSharedWith(const QList &other) const Q_DECL_NOTHROW { return d == other.d; } + inline bool isSharedWith(const QList &other) const noexcept { return d == other.d; } - inline bool isEmpty() const Q_DECL_NOTHROW { return p.isEmpty(); } + inline bool isEmpty() const noexcept { return p.isEmpty(); } void clear(); @@ -243,34 +243,34 @@ public: typedef T *pointer; typedef T &reference; - inline iterator() Q_DECL_NOTHROW : i(nullptr) {} - inline iterator(Node *n) Q_DECL_NOTHROW : i(n) {} + inline iterator() noexcept : i(nullptr) {} + inline iterator(Node *n) noexcept : i(n) {} #if QT_VERSION < QT_VERSION_CHECK(6,0,0) // can't remove it in Qt 5, since doing so would make the type trivial, // which changes the way it's passed to functions by value. - inline iterator(const iterator &o) Q_DECL_NOTHROW : i(o.i){} + inline iterator(const iterator &o) noexcept : i(o.i){} #endif inline T &operator*() const { return i->t(); } inline T *operator->() const { return &i->t(); } inline T &operator[](difference_type j) const { return i[j].t(); } - inline bool operator==(const iterator &o) const Q_DECL_NOTHROW { return i == o.i; } - inline bool operator!=(const iterator &o) const Q_DECL_NOTHROW { return i != o.i; } - inline bool operator<(const iterator& other) const Q_DECL_NOTHROW { return i < other.i; } - inline bool operator<=(const iterator& other) const Q_DECL_NOTHROW { return i <= other.i; } - inline bool operator>(const iterator& other) const Q_DECL_NOTHROW { return i > other.i; } - inline bool operator>=(const iterator& other) const Q_DECL_NOTHROW { return i >= other.i; } + inline bool operator==(const iterator &o) const noexcept { return i == o.i; } + inline bool operator!=(const iterator &o) const noexcept { return i != o.i; } + inline bool operator<(const iterator& other) const noexcept { return i < other.i; } + inline bool operator<=(const iterator& other) const noexcept { return i <= other.i; } + inline bool operator>(const iterator& other) const noexcept { return i > other.i; } + inline bool operator>=(const iterator& other) const noexcept { return i >= other.i; } #ifndef QT_STRICT_ITERATORS - inline bool operator==(const const_iterator &o) const Q_DECL_NOTHROW + inline bool operator==(const const_iterator &o) const noexcept { return i == o.i; } - inline bool operator!=(const const_iterator &o) const Q_DECL_NOTHROW + inline bool operator!=(const const_iterator &o) const noexcept { return i != o.i; } - inline bool operator<(const const_iterator& other) const Q_DECL_NOTHROW + inline bool operator<(const const_iterator& other) const noexcept { return i < other.i; } - inline bool operator<=(const const_iterator& other) const Q_DECL_NOTHROW + inline bool operator<=(const const_iterator& other) const noexcept { return i <= other.i; } - inline bool operator>(const const_iterator& other) const Q_DECL_NOTHROW + inline bool operator>(const const_iterator& other) const noexcept { return i > other.i; } - inline bool operator>=(const const_iterator& other) const Q_DECL_NOTHROW + inline bool operator>=(const const_iterator& other) const noexcept { return i >= other.i; } #endif inline iterator &operator++() { ++i; return *this; } @@ -296,27 +296,27 @@ public: typedef const T *pointer; typedef const T &reference; - inline const_iterator() Q_DECL_NOTHROW : i(nullptr) {} - inline const_iterator(Node *n) Q_DECL_NOTHROW : i(n) {} + inline const_iterator() noexcept : i(nullptr) {} + inline const_iterator(Node *n) noexcept : i(n) {} #if QT_VERSION < QT_VERSION_CHECK(6,0,0) // can't remove it in Qt 5, since doing so would make the type trivial, // which changes the way it's passed to functions by value. - inline const_iterator(const const_iterator &o) Q_DECL_NOTHROW : i(o.i) {} + inline const_iterator(const const_iterator &o) noexcept : i(o.i) {} #endif #ifdef QT_STRICT_ITERATORS - inline explicit const_iterator(const iterator &o) Q_DECL_NOTHROW : i(o.i) {} + inline explicit const_iterator(const iterator &o) noexcept : i(o.i) {} #else - inline const_iterator(const iterator &o) Q_DECL_NOTHROW : i(o.i) {} + inline const_iterator(const iterator &o) noexcept : i(o.i) {} #endif inline const T &operator*() const { return i->t(); } inline const T *operator->() const { return &i->t(); } inline const T &operator[](difference_type j) const { return i[j].t(); } - inline bool operator==(const const_iterator &o) const Q_DECL_NOTHROW { return i == o.i; } - inline bool operator!=(const const_iterator &o) const Q_DECL_NOTHROW { return i != o.i; } - inline bool operator<(const const_iterator& other) const Q_DECL_NOTHROW { return i < other.i; } - inline bool operator<=(const const_iterator& other) const Q_DECL_NOTHROW { return i <= other.i; } - inline bool operator>(const const_iterator& other) const Q_DECL_NOTHROW { return i > other.i; } - inline bool operator>=(const const_iterator& other) const Q_DECL_NOTHROW { return i >= other.i; } + inline bool operator==(const const_iterator &o) const noexcept { return i == o.i; } + inline bool operator!=(const const_iterator &o) const noexcept { return i != o.i; } + inline bool operator<(const const_iterator& other) const noexcept { return i < other.i; } + inline bool operator<=(const const_iterator& other) const noexcept { return i <= other.i; } + inline bool operator>(const const_iterator& other) const noexcept { return i > other.i; } + inline bool operator>=(const const_iterator& other) const noexcept { return i >= other.i; } inline const_iterator &operator++() { ++i; return *this; } inline const_iterator operator++(int) { Node *n = i; ++i; return n; } inline const_iterator &operator--() { i--; return *this; } @@ -334,19 +334,19 @@ public: typedef std::reverse_iterator reverse_iterator; typedef std::reverse_iterator const_reverse_iterator; inline iterator begin() { detach(); return reinterpret_cast(p.begin()); } - inline const_iterator begin() const Q_DECL_NOTHROW { return reinterpret_cast(p.begin()); } - inline const_iterator cbegin() const Q_DECL_NOTHROW { return reinterpret_cast(p.begin()); } - inline const_iterator constBegin() const Q_DECL_NOTHROW { return reinterpret_cast(p.begin()); } + inline const_iterator begin() const noexcept { return reinterpret_cast(p.begin()); } + inline const_iterator cbegin() const noexcept { return reinterpret_cast(p.begin()); } + inline const_iterator constBegin() const noexcept { return reinterpret_cast(p.begin()); } inline iterator end() { detach(); return reinterpret_cast(p.end()); } - inline const_iterator end() const Q_DECL_NOTHROW { return reinterpret_cast(p.end()); } - inline const_iterator cend() const Q_DECL_NOTHROW { return reinterpret_cast(p.end()); } - inline const_iterator constEnd() const Q_DECL_NOTHROW { return reinterpret_cast(p.end()); } + inline const_iterator end() const noexcept { return reinterpret_cast(p.end()); } + inline const_iterator cend() const noexcept { return reinterpret_cast(p.end()); } + inline const_iterator constEnd() const noexcept { return reinterpret_cast(p.end()); } reverse_iterator rbegin() { return reverse_iterator(end()); } reverse_iterator rend() { return reverse_iterator(begin()); } - const_reverse_iterator rbegin() const Q_DECL_NOTHROW { return const_reverse_iterator(end()); } - const_reverse_iterator rend() const Q_DECL_NOTHROW { return const_reverse_iterator(begin()); } - const_reverse_iterator crbegin() const Q_DECL_NOTHROW { return const_reverse_iterator(end()); } - const_reverse_iterator crend() const Q_DECL_NOTHROW { return const_reverse_iterator(begin()); } + const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); } + const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); } + const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(end()); } + const_reverse_iterator crend() const noexcept { return const_reverse_iterator(begin()); } iterator insert(iterator before, const T &t); iterator erase(iterator pos); iterator erase(iterator first, iterator last); @@ -423,7 +423,7 @@ private: void node_copy(Node *from, Node *to, Node *src); void node_destruct(Node *from, Node *to); - bool isValidIterator(const iterator &i) const Q_DECL_NOTHROW + bool isValidIterator(const iterator &i) const noexcept { const std::less less = {}; return !less(i.i, cbegin().i) && !less(cend().i, i.i); diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index ebb6c97975..9a3929c4a7 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -94,7 +94,7 @@ QT_BEGIN_INCLUDE_NAMESPACE #include "qlocale_data_p.h" QT_END_INCLUDE_NAMESPACE -QLocale::Language QLocalePrivate::codeToLanguage(QStringView code) Q_DECL_NOTHROW +QLocale::Language QLocalePrivate::codeToLanguage(QStringView code) noexcept { const auto len = code.size(); if (len != 2 && len != 3) @@ -138,7 +138,7 @@ QLocale::Language QLocalePrivate::codeToLanguage(QStringView code) Q_DECL_NOTHRO return QLocale::C; } -QLocale::Script QLocalePrivate::codeToScript(QStringView code) Q_DECL_NOTHROW +QLocale::Script QLocalePrivate::codeToScript(QStringView code) noexcept { const auto len = code.size(); if (len != 4) @@ -158,7 +158,7 @@ QLocale::Script QLocalePrivate::codeToScript(QStringView code) Q_DECL_NOTHROW return QLocale::AnyScript; } -QLocale::Country QLocalePrivate::codeToCountry(QStringView code) Q_DECL_NOTHROW +QLocale::Country QLocalePrivate::codeToCountry(QStringView code) noexcept { const auto len = code.size(); if (len != 2 && len != 3) @@ -982,7 +982,7 @@ bool QLocale::operator!=(const QLocale &other) const Returns the hash value for \a key, using \a seed to seed the calculation. */ -uint qHash(const QLocale &key, uint seed) Q_DECL_NOTHROW +uint qHash(const QLocale &key, uint seed) noexcept { QtPrivate::QHashCombine hash; seed = hash(seed, key.d->m_data); diff --git a/src/corelib/tools/qlocale.h b/src/corelib/tools/qlocale.h index 2b4f131552..cb462db770 100644 --- a/src/corelib/tools/qlocale.h +++ b/src/corelib/tools/qlocale.h @@ -59,7 +59,7 @@ class QTextStreamPrivate; class QLocalePrivate; -Q_CORE_EXPORT uint qHash(const QLocale &key, uint seed = 0) Q_DECL_NOTHROW; +Q_CORE_EXPORT uint qHash(const QLocale &key, uint seed = 0) noexcept; class Q_CORE_EXPORT QLocale { @@ -940,12 +940,12 @@ public: QLocale(Language language, Script script, Country country); QLocale(const QLocale &other); #ifdef Q_COMPILER_RVALUE_REFS - QLocale &operator=(QLocale &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QLocale &operator=(QLocale &&other) noexcept { swap(other); return *this; } #endif QLocale &operator=(const QLocale &other); ~QLocale(); - void swap(QLocale &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + void swap(QLocale &other) noexcept { qSwap(d, other.d); } Language language() const; Script script() const; @@ -1108,7 +1108,7 @@ private: QLocale(QLocalePrivate &dd); friend class QLocalePrivate; friend class QSystemLocale; - friend Q_CORE_EXPORT uint qHash(const QLocale &key, uint seed) Q_DECL_NOTHROW; + friend Q_CORE_EXPORT uint qHash(const QLocale &key, uint seed) noexcept; QSharedDataPointer d; }; diff --git a/src/corelib/tools/qlocale_p.h b/src/corelib/tools/qlocale_p.h index 5edeed1954..de973d5eac 100644 --- a/src/corelib/tools/qlocale_p.h +++ b/src/corelib/tools/qlocale_p.h @@ -365,9 +365,9 @@ public: static QLatin1String languageToCode(QLocale::Language language); static QLatin1String scriptToCode(QLocale::Script script); static QLatin1String countryToCode(QLocale::Country country); - static QLocale::Language codeToLanguage(QStringView code) Q_DECL_NOTHROW; - static QLocale::Script codeToScript(QStringView code) Q_DECL_NOTHROW; - static QLocale::Country codeToCountry(QStringView code) Q_DECL_NOTHROW; + static QLocale::Language codeToLanguage(QStringView code) noexcept; + static QLocale::Script codeToScript(QStringView code) noexcept; + static QLocale::Country codeToCountry(QStringView code) noexcept; static void getLangAndCountry(const QString &name, QLocale::Language &lang, QLocale::Script &script, QLocale::Country &cntry); diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h index 1cf9299e26..103124f4ad 100644 --- a/src/corelib/tools/qmap.h +++ b/src/corelib/tools/qmap.h @@ -100,10 +100,10 @@ struct Q_CORE_EXPORT QMapNodeBase template static typename std::enable_if::isComplex>::type - callDestructorIfNecessary(T &t) Q_DECL_NOTHROW { Q_UNUSED(t); t.~T(); } // Q_UNUSED: silence MSVC unused 't' warning + callDestructorIfNecessary(T &t) noexcept { Q_UNUSED(t); t.~T(); } // Q_UNUSED: silence MSVC unused 't' warning template static typename std::enable_if::isComplex>::type - callDestructorIfNecessary(T &) Q_DECL_NOTHROW {} + callDestructorIfNecessary(T &) noexcept {} }; template @@ -325,7 +325,7 @@ class QMap QMapData *d; public: - inline QMap() Q_DECL_NOTHROW : d(static_cast *>(const_cast(&QMapDataBase::shared_null))) { } + inline QMap() noexcept : d(static_cast *>(const_cast(&QMapDataBase::shared_null))) { } #ifdef Q_COMPILER_INITIALIZER_LISTS inline QMap(std::initializer_list > list) : d(static_cast *>(const_cast(&QMapDataBase::shared_null))) @@ -340,17 +340,17 @@ public: QMap &operator=(const QMap &other); #ifdef Q_COMPILER_RVALUE_REFS - inline QMap(QMap &&other) Q_DECL_NOTHROW + inline QMap(QMap &&other) noexcept : d(other.d) { other.d = static_cast *>( const_cast(&QMapDataBase::shared_null)); } - inline QMap &operator=(QMap &&other) Q_DECL_NOTHROW + inline QMap &operator=(QMap &&other) noexcept { QMap moved(std::move(other)); swap(moved); return *this; } #endif - inline void swap(QMap &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + inline void swap(QMap &other) noexcept { qSwap(d, other.d); } explicit QMap(const typename std::map &other); std::map toStdMap() const; @@ -1187,7 +1187,7 @@ template class QMultiMap : public QMap { public: - QMultiMap() Q_DECL_NOTHROW {} + QMultiMap() noexcept {} #ifdef Q_COMPILER_INITIALIZER_LISTS inline QMultiMap(std::initializer_list > list) { @@ -1197,9 +1197,9 @@ public: #endif QMultiMap(const QMap &other) : QMap(other) {} #ifdef Q_COMPILER_RVALUE_REFS - QMultiMap(QMap &&other) Q_DECL_NOTHROW : QMap(std::move(other)) {} + QMultiMap(QMap &&other) noexcept : QMap(std::move(other)) {} #endif - void swap(QMultiMap &other) Q_DECL_NOTHROW { QMap::swap(other); } + void swap(QMultiMap &other) noexcept { QMap::swap(other); } inline typename QMap::iterator replace(const Key &key, const T &value) { return QMap::insert(key, value); } diff --git a/src/corelib/tools/qmargins.h b/src/corelib/tools/qmargins.h index 0c73235d26..447037daaa 100644 --- a/src/corelib/tools/qmargins.h +++ b/src/corelib/tools/qmargins.h @@ -51,28 +51,28 @@ QT_BEGIN_NAMESPACE class QMargins { public: - Q_DECL_CONSTEXPR QMargins() Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR QMargins(int left, int top, int right, int bottom) Q_DECL_NOTHROW; + Q_DECL_CONSTEXPR QMargins() noexcept; + Q_DECL_CONSTEXPR QMargins(int left, int top, int right, int bottom) noexcept; - Q_DECL_CONSTEXPR bool isNull() const Q_DECL_NOTHROW; + Q_DECL_CONSTEXPR bool isNull() const noexcept; - Q_DECL_CONSTEXPR int left() const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR int top() const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR int right() const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR int bottom() const Q_DECL_NOTHROW; + Q_DECL_CONSTEXPR int left() const noexcept; + Q_DECL_CONSTEXPR int top() const noexcept; + Q_DECL_CONSTEXPR int right() const noexcept; + Q_DECL_CONSTEXPR int bottom() const noexcept; - Q_DECL_RELAXED_CONSTEXPR void setLeft(int left) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR void setTop(int top) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR void setRight(int right) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR void setBottom(int bottom) Q_DECL_NOTHROW; + Q_DECL_RELAXED_CONSTEXPR void setLeft(int left) noexcept; + Q_DECL_RELAXED_CONSTEXPR void setTop(int top) noexcept; + Q_DECL_RELAXED_CONSTEXPR void setRight(int right) noexcept; + Q_DECL_RELAXED_CONSTEXPR void setBottom(int bottom) noexcept; - Q_DECL_RELAXED_CONSTEXPR QMargins &operator+=(const QMargins &margins) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR QMargins &operator-=(const QMargins &margins) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR QMargins &operator+=(int) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR QMargins &operator-=(int) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR QMargins &operator*=(int) Q_DECL_NOTHROW; + Q_DECL_RELAXED_CONSTEXPR QMargins &operator+=(const QMargins &margins) noexcept; + Q_DECL_RELAXED_CONSTEXPR QMargins &operator-=(const QMargins &margins) noexcept; + Q_DECL_RELAXED_CONSTEXPR QMargins &operator+=(int) noexcept; + Q_DECL_RELAXED_CONSTEXPR QMargins &operator-=(int) noexcept; + Q_DECL_RELAXED_CONSTEXPR QMargins &operator*=(int) noexcept; Q_DECL_RELAXED_CONSTEXPR QMargins &operator/=(int); - Q_DECL_RELAXED_CONSTEXPR QMargins &operator*=(qreal) Q_DECL_NOTHROW; + Q_DECL_RELAXED_CONSTEXPR QMargins &operator*=(qreal) noexcept; Q_DECL_RELAXED_CONSTEXPR QMargins &operator/=(qreal); private: @@ -81,8 +81,8 @@ private: int m_right; int m_bottom; - friend Q_DECL_CONSTEXPR inline bool operator==(const QMargins &, const QMargins &) Q_DECL_NOTHROW; - friend Q_DECL_CONSTEXPR inline bool operator!=(const QMargins &, const QMargins &) Q_DECL_NOTHROW; + friend Q_DECL_CONSTEXPR inline bool operator==(const QMargins &, const QMargins &) noexcept; + friend Q_DECL_CONSTEXPR inline bool operator!=(const QMargins &, const QMargins &) noexcept; }; Q_DECLARE_TYPEINFO(QMargins, Q_MOVABLE_TYPE); @@ -99,40 +99,40 @@ Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QMargins &); QMargins inline functions *****************************************************************************/ -Q_DECL_CONSTEXPR inline QMargins::QMargins() Q_DECL_NOTHROW : m_left(0), m_top(0), m_right(0), m_bottom(0) {} +Q_DECL_CONSTEXPR inline QMargins::QMargins() noexcept : m_left(0), m_top(0), m_right(0), m_bottom(0) {} -Q_DECL_CONSTEXPR inline QMargins::QMargins(int aleft, int atop, int aright, int abottom) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QMargins::QMargins(int aleft, int atop, int aright, int abottom) noexcept : m_left(aleft), m_top(atop), m_right(aright), m_bottom(abottom) {} -Q_DECL_CONSTEXPR inline bool QMargins::isNull() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline bool QMargins::isNull() const noexcept { return m_left==0 && m_top==0 && m_right==0 && m_bottom==0; } -Q_DECL_CONSTEXPR inline int QMargins::left() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline int QMargins::left() const noexcept { return m_left; } -Q_DECL_CONSTEXPR inline int QMargins::top() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline int QMargins::top() const noexcept { return m_top; } -Q_DECL_CONSTEXPR inline int QMargins::right() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline int QMargins::right() const noexcept { return m_right; } -Q_DECL_CONSTEXPR inline int QMargins::bottom() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline int QMargins::bottom() const noexcept { return m_bottom; } -Q_DECL_RELAXED_CONSTEXPR inline void QMargins::setLeft(int aleft) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QMargins::setLeft(int aleft) noexcept { m_left = aleft; } -Q_DECL_RELAXED_CONSTEXPR inline void QMargins::setTop(int atop) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QMargins::setTop(int atop) noexcept { m_top = atop; } -Q_DECL_RELAXED_CONSTEXPR inline void QMargins::setRight(int aright) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QMargins::setRight(int aright) noexcept { m_right = aright; } -Q_DECL_RELAXED_CONSTEXPR inline void QMargins::setBottom(int abottom) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QMargins::setBottom(int abottom) noexcept { m_bottom = abottom; } -Q_DECL_CONSTEXPR inline bool operator==(const QMargins &m1, const QMargins &m2) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline bool operator==(const QMargins &m1, const QMargins &m2) noexcept { return m1.m_left == m2.m_left && @@ -141,7 +141,7 @@ Q_DECL_CONSTEXPR inline bool operator==(const QMargins &m1, const QMargins &m2) m1.m_bottom == m2.m_bottom; } -Q_DECL_CONSTEXPR inline bool operator!=(const QMargins &m1, const QMargins &m2) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline bool operator!=(const QMargins &m1, const QMargins &m2) noexcept { return m1.m_left != m2.m_left || @@ -150,55 +150,55 @@ Q_DECL_CONSTEXPR inline bool operator!=(const QMargins &m1, const QMargins &m2) m1.m_bottom != m2.m_bottom; } -Q_DECL_CONSTEXPR inline QMargins operator+(const QMargins &m1, const QMargins &m2) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QMargins operator+(const QMargins &m1, const QMargins &m2) noexcept { return QMargins(m1.left() + m2.left(), m1.top() + m2.top(), m1.right() + m2.right(), m1.bottom() + m2.bottom()); } -Q_DECL_CONSTEXPR inline QMargins operator-(const QMargins &m1, const QMargins &m2) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QMargins operator-(const QMargins &m1, const QMargins &m2) noexcept { return QMargins(m1.left() - m2.left(), m1.top() - m2.top(), m1.right() - m2.right(), m1.bottom() - m2.bottom()); } -Q_DECL_CONSTEXPR inline QMargins operator+(const QMargins &lhs, int rhs) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QMargins operator+(const QMargins &lhs, int rhs) noexcept { return QMargins(lhs.left() + rhs, lhs.top() + rhs, lhs.right() + rhs, lhs.bottom() + rhs); } -Q_DECL_CONSTEXPR inline QMargins operator+(int lhs, const QMargins &rhs) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QMargins operator+(int lhs, const QMargins &rhs) noexcept { return QMargins(rhs.left() + lhs, rhs.top() + lhs, rhs.right() + lhs, rhs.bottom() + lhs); } -Q_DECL_CONSTEXPR inline QMargins operator-(const QMargins &lhs, int rhs) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QMargins operator-(const QMargins &lhs, int rhs) noexcept { return QMargins(lhs.left() - rhs, lhs.top() - rhs, lhs.right() - rhs, lhs.bottom() - rhs); } -Q_DECL_CONSTEXPR inline QMargins operator*(const QMargins &margins, int factor) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QMargins operator*(const QMargins &margins, int factor) noexcept { return QMargins(margins.left() * factor, margins.top() * factor, margins.right() * factor, margins.bottom() * factor); } -Q_DECL_CONSTEXPR inline QMargins operator*(int factor, const QMargins &margins) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QMargins operator*(int factor, const QMargins &margins) noexcept { return QMargins(margins.left() * factor, margins.top() * factor, margins.right() * factor, margins.bottom() * factor); } -Q_DECL_CONSTEXPR inline QMargins operator*(const QMargins &margins, qreal factor) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QMargins operator*(const QMargins &margins, qreal factor) noexcept { return QMargins(qRound(margins.left() * factor), qRound(margins.top() * factor), qRound(margins.right() * factor), qRound(margins.bottom() * factor)); } -Q_DECL_CONSTEXPR inline QMargins operator*(qreal factor, const QMargins &margins) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QMargins operator*(qreal factor, const QMargins &margins) noexcept { return QMargins(qRound(margins.left() * factor), qRound(margins.top() * factor), qRound(margins.right() * factor), qRound(margins.bottom() * factor)); @@ -216,17 +216,17 @@ Q_DECL_CONSTEXPR inline QMargins operator/(const QMargins &margins, qreal diviso qRound(margins.right() / divisor), qRound(margins.bottom() / divisor)); } -Q_DECL_RELAXED_CONSTEXPR inline QMargins &QMargins::operator+=(const QMargins &margins) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline QMargins &QMargins::operator+=(const QMargins &margins) noexcept { return *this = *this + margins; } -Q_DECL_RELAXED_CONSTEXPR inline QMargins &QMargins::operator-=(const QMargins &margins) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline QMargins &QMargins::operator-=(const QMargins &margins) noexcept { return *this = *this - margins; } -Q_DECL_RELAXED_CONSTEXPR inline QMargins &QMargins::operator+=(int margin) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline QMargins &QMargins::operator+=(int margin) noexcept { m_left += margin; m_top += margin; @@ -235,7 +235,7 @@ Q_DECL_RELAXED_CONSTEXPR inline QMargins &QMargins::operator+=(int margin) Q_DEC return *this; } -Q_DECL_RELAXED_CONSTEXPR inline QMargins &QMargins::operator-=(int margin) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline QMargins &QMargins::operator-=(int margin) noexcept { m_left -= margin; m_top -= margin; @@ -244,7 +244,7 @@ Q_DECL_RELAXED_CONSTEXPR inline QMargins &QMargins::operator-=(int margin) Q_DEC return *this; } -Q_DECL_RELAXED_CONSTEXPR inline QMargins &QMargins::operator*=(int factor) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline QMargins &QMargins::operator*=(int factor) noexcept { return *this = *this * factor; } @@ -254,7 +254,7 @@ Q_DECL_RELAXED_CONSTEXPR inline QMargins &QMargins::operator/=(int divisor) return *this = *this / divisor; } -Q_DECL_RELAXED_CONSTEXPR inline QMargins &QMargins::operator*=(qreal factor) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline QMargins &QMargins::operator*=(qreal factor) noexcept { return *this = *this * factor; } @@ -264,12 +264,12 @@ Q_DECL_RELAXED_CONSTEXPR inline QMargins &QMargins::operator/=(qreal divisor) return *this = *this / divisor; } -Q_DECL_CONSTEXPR inline QMargins operator+(const QMargins &margins) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QMargins operator+(const QMargins &margins) noexcept { return margins; } -Q_DECL_CONSTEXPR inline QMargins operator-(const QMargins &margins) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QMargins operator-(const QMargins &margins) noexcept { return QMargins(-margins.left(), -margins.top(), -margins.right(), -margins.bottom()); } @@ -285,30 +285,30 @@ Q_CORE_EXPORT QDebug operator<<(QDebug, const QMargins &); class QMarginsF { public: - Q_DECL_CONSTEXPR QMarginsF() Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR QMarginsF(qreal left, qreal top, qreal right, qreal bottom) Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR QMarginsF(const QMargins &margins) Q_DECL_NOTHROW; + Q_DECL_CONSTEXPR QMarginsF() noexcept; + Q_DECL_CONSTEXPR QMarginsF(qreal left, qreal top, qreal right, qreal bottom) noexcept; + Q_DECL_CONSTEXPR QMarginsF(const QMargins &margins) noexcept; - Q_DECL_CONSTEXPR bool isNull() const Q_DECL_NOTHROW; + Q_DECL_CONSTEXPR bool isNull() const noexcept; - Q_DECL_CONSTEXPR qreal left() const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR qreal top() const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR qreal right() const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR qreal bottom() const Q_DECL_NOTHROW; + Q_DECL_CONSTEXPR qreal left() const noexcept; + Q_DECL_CONSTEXPR qreal top() const noexcept; + Q_DECL_CONSTEXPR qreal right() const noexcept; + Q_DECL_CONSTEXPR qreal bottom() const noexcept; - Q_DECL_RELAXED_CONSTEXPR void setLeft(qreal left) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR void setTop(qreal top) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR void setRight(qreal right) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR void setBottom(qreal bottom) Q_DECL_NOTHROW; + Q_DECL_RELAXED_CONSTEXPR void setLeft(qreal left) noexcept; + Q_DECL_RELAXED_CONSTEXPR void setTop(qreal top) noexcept; + Q_DECL_RELAXED_CONSTEXPR void setRight(qreal right) noexcept; + Q_DECL_RELAXED_CONSTEXPR void setBottom(qreal bottom) noexcept; - Q_DECL_RELAXED_CONSTEXPR QMarginsF &operator+=(const QMarginsF &margins) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR QMarginsF &operator-=(const QMarginsF &margins) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR QMarginsF &operator+=(qreal addend) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR QMarginsF &operator-=(qreal subtrahend) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR QMarginsF &operator*=(qreal factor) Q_DECL_NOTHROW; + Q_DECL_RELAXED_CONSTEXPR QMarginsF &operator+=(const QMarginsF &margins) noexcept; + Q_DECL_RELAXED_CONSTEXPR QMarginsF &operator-=(const QMarginsF &margins) noexcept; + Q_DECL_RELAXED_CONSTEXPR QMarginsF &operator+=(qreal addend) noexcept; + Q_DECL_RELAXED_CONSTEXPR QMarginsF &operator-=(qreal subtrahend) noexcept; + Q_DECL_RELAXED_CONSTEXPR QMarginsF &operator*=(qreal factor) noexcept; Q_DECL_RELAXED_CONSTEXPR QMarginsF &operator/=(qreal divisor); - Q_DECL_CONSTEXPR inline QMargins toMargins() const Q_DECL_NOTHROW; + Q_DECL_CONSTEXPR inline QMargins toMargins() const noexcept; private: qreal m_left; @@ -332,44 +332,44 @@ Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QMarginsF &); QMarginsF inline functions *****************************************************************************/ -Q_DECL_CONSTEXPR inline QMarginsF::QMarginsF() Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QMarginsF::QMarginsF() noexcept : m_left(0), m_top(0), m_right(0), m_bottom(0) {} -Q_DECL_CONSTEXPR inline QMarginsF::QMarginsF(qreal aleft, qreal atop, qreal aright, qreal abottom) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QMarginsF::QMarginsF(qreal aleft, qreal atop, qreal aright, qreal abottom) noexcept : m_left(aleft), m_top(atop), m_right(aright), m_bottom(abottom) {} -Q_DECL_CONSTEXPR inline QMarginsF::QMarginsF(const QMargins &margins) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QMarginsF::QMarginsF(const QMargins &margins) noexcept : m_left(margins.left()), m_top(margins.top()), m_right(margins.right()), m_bottom(margins.bottom()) {} -Q_DECL_CONSTEXPR inline bool QMarginsF::isNull() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline bool QMarginsF::isNull() const noexcept { return qFuzzyIsNull(m_left) && qFuzzyIsNull(m_top) && qFuzzyIsNull(m_right) && qFuzzyIsNull(m_bottom); } -Q_DECL_CONSTEXPR inline qreal QMarginsF::left() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline qreal QMarginsF::left() const noexcept { return m_left; } -Q_DECL_CONSTEXPR inline qreal QMarginsF::top() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline qreal QMarginsF::top() const noexcept { return m_top; } -Q_DECL_CONSTEXPR inline qreal QMarginsF::right() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline qreal QMarginsF::right() const noexcept { return m_right; } -Q_DECL_CONSTEXPR inline qreal QMarginsF::bottom() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline qreal QMarginsF::bottom() const noexcept { return m_bottom; } -Q_DECL_RELAXED_CONSTEXPR inline void QMarginsF::setLeft(qreal aleft) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QMarginsF::setLeft(qreal aleft) noexcept { m_left = aleft; } -Q_DECL_RELAXED_CONSTEXPR inline void QMarginsF::setTop(qreal atop) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QMarginsF::setTop(qreal atop) noexcept { m_top = atop; } -Q_DECL_RELAXED_CONSTEXPR inline void QMarginsF::setRight(qreal aright) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QMarginsF::setRight(qreal aright) noexcept { m_right = aright; } -Q_DECL_RELAXED_CONSTEXPR inline void QMarginsF::setBottom(qreal abottom) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QMarginsF::setBottom(qreal abottom) noexcept { m_bottom = abottom; } -Q_DECL_CONSTEXPR inline bool operator==(const QMarginsF &lhs, const QMarginsF &rhs) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline bool operator==(const QMarginsF &lhs, const QMarginsF &rhs) noexcept { return qFuzzyCompare(lhs.left(), rhs.left()) && qFuzzyCompare(lhs.top(), rhs.top()) @@ -377,48 +377,48 @@ Q_DECL_CONSTEXPR inline bool operator==(const QMarginsF &lhs, const QMarginsF &r && qFuzzyCompare(lhs.bottom(), rhs.bottom()); } -Q_DECL_CONSTEXPR inline bool operator!=(const QMarginsF &lhs, const QMarginsF &rhs) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline bool operator!=(const QMarginsF &lhs, const QMarginsF &rhs) noexcept { return !operator==(lhs, rhs); } -Q_DECL_CONSTEXPR inline QMarginsF operator+(const QMarginsF &lhs, const QMarginsF &rhs) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QMarginsF operator+(const QMarginsF &lhs, const QMarginsF &rhs) noexcept { return QMarginsF(lhs.left() + rhs.left(), lhs.top() + rhs.top(), lhs.right() + rhs.right(), lhs.bottom() + rhs.bottom()); } -Q_DECL_CONSTEXPR inline QMarginsF operator-(const QMarginsF &lhs, const QMarginsF &rhs) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QMarginsF operator-(const QMarginsF &lhs, const QMarginsF &rhs) noexcept { return QMarginsF(lhs.left() - rhs.left(), lhs.top() - rhs.top(), lhs.right() - rhs.right(), lhs.bottom() - rhs.bottom()); } -Q_DECL_CONSTEXPR inline QMarginsF operator+(const QMarginsF &lhs, qreal rhs) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QMarginsF operator+(const QMarginsF &lhs, qreal rhs) noexcept { return QMarginsF(lhs.left() + rhs, lhs.top() + rhs, lhs.right() + rhs, lhs.bottom() + rhs); } -Q_DECL_CONSTEXPR inline QMarginsF operator+(qreal lhs, const QMarginsF &rhs) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QMarginsF operator+(qreal lhs, const QMarginsF &rhs) noexcept { return QMarginsF(rhs.left() + lhs, rhs.top() + lhs, rhs.right() + lhs, rhs.bottom() + lhs); } -Q_DECL_CONSTEXPR inline QMarginsF operator-(const QMarginsF &lhs, qreal rhs) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QMarginsF operator-(const QMarginsF &lhs, qreal rhs) noexcept { return QMarginsF(lhs.left() - rhs, lhs.top() - rhs, lhs.right() - rhs, lhs.bottom() - rhs); } -Q_DECL_CONSTEXPR inline QMarginsF operator*(const QMarginsF &lhs, qreal rhs) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QMarginsF operator*(const QMarginsF &lhs, qreal rhs) noexcept { return QMarginsF(lhs.left() * rhs, lhs.top() * rhs, lhs.right() * rhs, lhs.bottom() * rhs); } -Q_DECL_CONSTEXPR inline QMarginsF operator*(qreal lhs, const QMarginsF &rhs) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QMarginsF operator*(qreal lhs, const QMarginsF &rhs) noexcept { return QMarginsF(rhs.left() * lhs, rhs.top() * lhs, rhs.right() * lhs, rhs.bottom() * lhs); @@ -430,17 +430,17 @@ Q_DECL_CONSTEXPR inline QMarginsF operator/(const QMarginsF &lhs, qreal divisor) lhs.right() / divisor, lhs.bottom() / divisor); } -Q_DECL_RELAXED_CONSTEXPR inline QMarginsF &QMarginsF::operator+=(const QMarginsF &margins) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline QMarginsF &QMarginsF::operator+=(const QMarginsF &margins) noexcept { return *this = *this + margins; } -Q_DECL_RELAXED_CONSTEXPR inline QMarginsF &QMarginsF::operator-=(const QMarginsF &margins) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline QMarginsF &QMarginsF::operator-=(const QMarginsF &margins) noexcept { return *this = *this - margins; } -Q_DECL_RELAXED_CONSTEXPR inline QMarginsF &QMarginsF::operator+=(qreal addend) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline QMarginsF &QMarginsF::operator+=(qreal addend) noexcept { m_left += addend; m_top += addend; @@ -449,7 +449,7 @@ Q_DECL_RELAXED_CONSTEXPR inline QMarginsF &QMarginsF::operator+=(qreal addend) Q return *this; } -Q_DECL_RELAXED_CONSTEXPR inline QMarginsF &QMarginsF::operator-=(qreal subtrahend) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline QMarginsF &QMarginsF::operator-=(qreal subtrahend) noexcept { m_left -= subtrahend; m_top -= subtrahend; @@ -458,7 +458,7 @@ Q_DECL_RELAXED_CONSTEXPR inline QMarginsF &QMarginsF::operator-=(qreal subtrahen return *this; } -Q_DECL_RELAXED_CONSTEXPR inline QMarginsF &QMarginsF::operator*=(qreal factor) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline QMarginsF &QMarginsF::operator*=(qreal factor) noexcept { return *this = *this * factor; } @@ -468,17 +468,17 @@ Q_DECL_RELAXED_CONSTEXPR inline QMarginsF &QMarginsF::operator/=(qreal divisor) return *this = *this / divisor; } -Q_DECL_CONSTEXPR inline QMarginsF operator+(const QMarginsF &margins) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QMarginsF operator+(const QMarginsF &margins) noexcept { return margins; } -Q_DECL_CONSTEXPR inline QMarginsF operator-(const QMarginsF &margins) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QMarginsF operator-(const QMarginsF &margins) noexcept { return QMarginsF(-margins.left(), -margins.top(), -margins.right(), -margins.bottom()); } -Q_DECL_CONSTEXPR inline QMargins QMarginsF::toMargins() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QMargins QMarginsF::toMargins() const noexcept { return QMargins(qRound(m_left), qRound(m_top), qRound(m_right), qRound(m_bottom)); } diff --git a/src/corelib/tools/qpoint.h b/src/corelib/tools/qpoint.h index d7323f7707..34df673b93 100644 --- a/src/corelib/tools/qpoint.h +++ b/src/corelib/tools/qpoint.h @@ -94,7 +94,7 @@ public: friend Q_DECL_CONSTEXPR inline const QPoint operator/(const QPoint &, qreal); #if defined(Q_OS_DARWIN) || defined(Q_QDOC) - Q_REQUIRED_RESULT CGPoint toCGPoint() const Q_DECL_NOTHROW; + Q_REQUIRED_RESULT CGPoint toCGPoint() const noexcept; #endif private: @@ -256,8 +256,8 @@ public: Q_DECL_CONSTEXPR QPoint toPoint() const; #if defined(Q_OS_DARWIN) || defined(Q_QDOC) - Q_REQUIRED_RESULT static QPointF fromCGPoint(CGPoint point) Q_DECL_NOTHROW; - Q_REQUIRED_RESULT CGPoint toCGPoint() const Q_DECL_NOTHROW; + Q_REQUIRED_RESULT static QPointF fromCGPoint(CGPoint point) noexcept; + Q_REQUIRED_RESULT CGPoint toCGPoint() const noexcept; #endif private: diff --git a/src/corelib/tools/qqueue.h b/src/corelib/tools/qqueue.h index b55f210577..16229759ee 100644 --- a/src/corelib/tools/qqueue.h +++ b/src/corelib/tools/qqueue.h @@ -50,7 +50,7 @@ class QQueue : public QList { public: // compiler-generated special member functions are fine! - inline void swap(QQueue &other) Q_DECL_NOTHROW { QList::swap(other); } // prevent QList<->QQueue swaps + inline void swap(QQueue &other) noexcept { QList::swap(other); } // prevent QList<->QQueue swaps #ifndef Q_QDOC // bring in QList::swap(int, int). We cannot say using QList::swap, // because we don't want to make swap(QList&) available. diff --git a/src/corelib/tools/qrect.cpp b/src/corelib/tools/qrect.cpp index 6e51deebea..d622f92530 100644 --- a/src/corelib/tools/qrect.cpp +++ b/src/corelib/tools/qrect.cpp @@ -300,7 +300,7 @@ QT_BEGIN_NAMESPACE \sa isValid(), isEmpty() */ -QRect QRect::normalized() const Q_DECL_NOTHROW +QRect QRect::normalized() const noexcept { QRect r; if (x2 < x1 - 1) { // swap bad x values @@ -820,7 +820,7 @@ QRect QRect::normalized() const Q_DECL_NOTHROW \sa intersects() */ -bool QRect::contains(const QPoint &p, bool proper) const Q_DECL_NOTHROW +bool QRect::contains(const QPoint &p, bool proper) const noexcept { int l, r; if (x2 < x1 - 1) { @@ -884,7 +884,7 @@ bool QRect::contains(const QPoint &p, bool proper) const Q_DECL_NOTHROW rectangle (not on the edge). */ -bool QRect::contains(const QRect &r, bool proper) const Q_DECL_NOTHROW +bool QRect::contains(const QRect &r, bool proper) const noexcept { if (isNull() || r.isNull()) return false; @@ -962,7 +962,7 @@ bool QRect::contains(const QRect &r, bool proper) const Q_DECL_NOTHROW \sa operator|=(), united() */ -QRect QRect::operator|(const QRect &r) const Q_DECL_NOTHROW +QRect QRect::operator|(const QRect &r) const noexcept { if (isNull()) return r; @@ -1033,7 +1033,7 @@ QRect QRect::operator|(const QRect &r) const Q_DECL_NOTHROW \sa operator&=(), intersected() */ -QRect QRect::operator&(const QRect &r) const Q_DECL_NOTHROW +QRect QRect::operator&(const QRect &r) const noexcept { if (isNull() || r.isNull()) return QRect(); @@ -1112,7 +1112,7 @@ QRect QRect::operator&(const QRect &r) const Q_DECL_NOTHROW \sa contains() */ -bool QRect::intersects(const QRect &r) const Q_DECL_NOTHROW +bool QRect::intersects(const QRect &r) const noexcept { if (isNull() || r.isNull()) return false; @@ -1540,7 +1540,7 @@ QDebug operator<<(QDebug dbg, const QRect &r) \sa isValid(), isEmpty() */ -QRectF QRectF::normalized() const Q_DECL_NOTHROW +QRectF QRectF::normalized() const noexcept { QRectF r = *this; if (r.w < 0) { @@ -1964,7 +1964,7 @@ QRectF QRectF::normalized() const Q_DECL_NOTHROW \sa intersects() */ -bool QRectF::contains(const QPointF &p) const Q_DECL_NOTHROW +bool QRectF::contains(const QPointF &p) const noexcept { qreal l = xp; qreal r = xp; @@ -2010,7 +2010,7 @@ bool QRectF::contains(const QPointF &p) const Q_DECL_NOTHROW otherwise returns \c false. */ -bool QRectF::contains(const QRectF &r) const Q_DECL_NOTHROW +bool QRectF::contains(const QRectF &r) const noexcept { qreal l1 = xp; qreal r1 = xp; @@ -2148,7 +2148,7 @@ bool QRectF::contains(const QRectF &r) const Q_DECL_NOTHROW \sa united(), operator|=() */ -QRectF QRectF::operator|(const QRectF &r) const Q_DECL_NOTHROW +QRectF QRectF::operator|(const QRectF &r) const noexcept { if (isNull()) return r; @@ -2217,7 +2217,7 @@ QRectF QRectF::operator|(const QRectF &r) const Q_DECL_NOTHROW \sa operator&=(), intersected() */ -QRectF QRectF::operator&(const QRectF &r) const Q_DECL_NOTHROW +QRectF QRectF::operator&(const QRectF &r) const noexcept { qreal l1 = xp; qreal r1 = xp; @@ -2302,7 +2302,7 @@ QRectF QRectF::operator&(const QRectF &r) const Q_DECL_NOTHROW \sa contains() */ -bool QRectF::intersects(const QRectF &r) const Q_DECL_NOTHROW +bool QRectF::intersects(const QRectF &r) const noexcept { qreal l1 = xp; qreal r1 = xp; @@ -2369,7 +2369,7 @@ bool QRectF::intersects(const QRectF &r) const Q_DECL_NOTHROW \sa toRect() */ -QRect QRectF::toAlignedRect() const Q_DECL_NOTHROW +QRect QRectF::toAlignedRect() const noexcept { int xmin = int(qFloor(xp)); int xmax = int(qCeil(xp + w)); diff --git a/src/corelib/tools/qrect.h b/src/corelib/tools/qrect.h index 3b40055b5a..7aa2312f38 100644 --- a/src/corelib/tools/qrect.h +++ b/src/corelib/tools/qrect.h @@ -57,104 +57,104 @@ QT_BEGIN_NAMESPACE class Q_CORE_EXPORT QRect { public: - Q_DECL_CONSTEXPR QRect() Q_DECL_NOTHROW : x1(0), y1(0), x2(-1), y2(-1) {} - Q_DECL_CONSTEXPR QRect(const QPoint &topleft, const QPoint &bottomright) Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR QRect(const QPoint &topleft, const QSize &size) Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR QRect(int left, int top, int width, int height) Q_DECL_NOTHROW; + Q_DECL_CONSTEXPR QRect() noexcept : x1(0), y1(0), x2(-1), y2(-1) {} + Q_DECL_CONSTEXPR QRect(const QPoint &topleft, const QPoint &bottomright) noexcept; + Q_DECL_CONSTEXPR QRect(const QPoint &topleft, const QSize &size) noexcept; + Q_DECL_CONSTEXPR QRect(int left, int top, int width, int height) noexcept; - Q_DECL_CONSTEXPR inline bool isNull() const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline bool isEmpty() const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline bool isValid() const Q_DECL_NOTHROW; + Q_DECL_CONSTEXPR inline bool isNull() const noexcept; + Q_DECL_CONSTEXPR inline bool isEmpty() const noexcept; + Q_DECL_CONSTEXPR inline bool isValid() const noexcept; - Q_DECL_CONSTEXPR inline int left() const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline int top() const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline int right() const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline int bottom() const Q_DECL_NOTHROW; - Q_REQUIRED_RESULT QRect normalized() const Q_DECL_NOTHROW; + Q_DECL_CONSTEXPR inline int left() const noexcept; + Q_DECL_CONSTEXPR inline int top() const noexcept; + Q_DECL_CONSTEXPR inline int right() const noexcept; + Q_DECL_CONSTEXPR inline int bottom() const noexcept; + Q_REQUIRED_RESULT QRect normalized() const noexcept; - Q_DECL_CONSTEXPR inline int x() const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline int y() const Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void setLeft(int pos) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void setTop(int pos) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void setRight(int pos) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void setBottom(int pos) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void setX(int x) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void setY(int y) Q_DECL_NOTHROW; + Q_DECL_CONSTEXPR inline int x() const noexcept; + Q_DECL_CONSTEXPR inline int y() const noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void setLeft(int pos) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void setTop(int pos) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void setRight(int pos) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void setBottom(int pos) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void setX(int x) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void setY(int y) noexcept; - Q_DECL_RELAXED_CONSTEXPR inline void setTopLeft(const QPoint &p) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void setBottomRight(const QPoint &p) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void setTopRight(const QPoint &p) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void setBottomLeft(const QPoint &p) Q_DECL_NOTHROW; + Q_DECL_RELAXED_CONSTEXPR inline void setTopLeft(const QPoint &p) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void setBottomRight(const QPoint &p) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void setTopRight(const QPoint &p) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void setBottomLeft(const QPoint &p) noexcept; - Q_DECL_CONSTEXPR inline QPoint topLeft() const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline QPoint bottomRight() const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline QPoint topRight() const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline QPoint bottomLeft() const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline QPoint center() const Q_DECL_NOTHROW; + Q_DECL_CONSTEXPR inline QPoint topLeft() const noexcept; + Q_DECL_CONSTEXPR inline QPoint bottomRight() const noexcept; + Q_DECL_CONSTEXPR inline QPoint topRight() const noexcept; + Q_DECL_CONSTEXPR inline QPoint bottomLeft() const noexcept; + Q_DECL_CONSTEXPR inline QPoint center() const noexcept; - Q_DECL_RELAXED_CONSTEXPR inline void moveLeft(int pos) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void moveTop(int pos) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void moveRight(int pos) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void moveBottom(int pos) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void moveTopLeft(const QPoint &p) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void moveBottomRight(const QPoint &p) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void moveTopRight(const QPoint &p) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void moveBottomLeft(const QPoint &p) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void moveCenter(const QPoint &p) Q_DECL_NOTHROW; + Q_DECL_RELAXED_CONSTEXPR inline void moveLeft(int pos) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void moveTop(int pos) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void moveRight(int pos) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void moveBottom(int pos) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void moveTopLeft(const QPoint &p) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void moveBottomRight(const QPoint &p) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void moveTopRight(const QPoint &p) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void moveBottomLeft(const QPoint &p) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void moveCenter(const QPoint &p) noexcept; - Q_DECL_RELAXED_CONSTEXPR inline void translate(int dx, int dy) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void translate(const QPoint &p) Q_DECL_NOTHROW; - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRect translated(int dx, int dy) const Q_DECL_NOTHROW; - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRect translated(const QPoint &p) const Q_DECL_NOTHROW; - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRect transposed() const Q_DECL_NOTHROW; + Q_DECL_RELAXED_CONSTEXPR inline void translate(int dx, int dy) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void translate(const QPoint &p) noexcept; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRect translated(int dx, int dy) const noexcept; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRect translated(const QPoint &p) const noexcept; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRect transposed() const noexcept; - Q_DECL_RELAXED_CONSTEXPR inline void moveTo(int x, int t) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void moveTo(const QPoint &p) Q_DECL_NOTHROW; + Q_DECL_RELAXED_CONSTEXPR inline void moveTo(int x, int t) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void moveTo(const QPoint &p) noexcept; - Q_DECL_RELAXED_CONSTEXPR inline void setRect(int x, int y, int w, int h) Q_DECL_NOTHROW; + Q_DECL_RELAXED_CONSTEXPR inline void setRect(int x, int y, int w, int h) noexcept; Q_DECL_RELAXED_CONSTEXPR inline void getRect(int *x, int *y, int *w, int *h) const; - Q_DECL_RELAXED_CONSTEXPR inline void setCoords(int x1, int y1, int x2, int y2) Q_DECL_NOTHROW; + Q_DECL_RELAXED_CONSTEXPR inline void setCoords(int x1, int y1, int x2, int y2) noexcept; Q_DECL_RELAXED_CONSTEXPR inline void getCoords(int *x1, int *y1, int *x2, int *y2) const; - Q_DECL_RELAXED_CONSTEXPR inline void adjust(int x1, int y1, int x2, int y2) Q_DECL_NOTHROW; - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRect adjusted(int x1, int y1, int x2, int y2) const Q_DECL_NOTHROW; + Q_DECL_RELAXED_CONSTEXPR inline void adjust(int x1, int y1, int x2, int y2) noexcept; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRect adjusted(int x1, int y1, int x2, int y2) const noexcept; - Q_DECL_CONSTEXPR inline QSize size() const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline int width() const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline int height() const Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void setWidth(int w) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void setHeight(int h) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void setSize(const QSize &s) Q_DECL_NOTHROW; + Q_DECL_CONSTEXPR inline QSize size() const noexcept; + Q_DECL_CONSTEXPR inline int width() const noexcept; + Q_DECL_CONSTEXPR inline int height() const noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void setWidth(int w) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void setHeight(int h) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void setSize(const QSize &s) noexcept; - QRect operator|(const QRect &r) const Q_DECL_NOTHROW; - QRect operator&(const QRect &r) const Q_DECL_NOTHROW; - inline QRect& operator|=(const QRect &r) Q_DECL_NOTHROW; - inline QRect& operator&=(const QRect &r) Q_DECL_NOTHROW; + QRect operator|(const QRect &r) const noexcept; + QRect operator&(const QRect &r) const noexcept; + inline QRect& operator|=(const QRect &r) noexcept; + inline QRect& operator&=(const QRect &r) noexcept; - bool contains(const QRect &r, bool proper = false) const Q_DECL_NOTHROW; - bool contains(const QPoint &p, bool proper=false) const Q_DECL_NOTHROW; - inline bool contains(int x, int y) const Q_DECL_NOTHROW; - inline bool contains(int x, int y, bool proper) const Q_DECL_NOTHROW; - Q_REQUIRED_RESULT inline QRect united(const QRect &other) const Q_DECL_NOTHROW; - Q_REQUIRED_RESULT inline QRect intersected(const QRect &other) const Q_DECL_NOTHROW; - bool intersects(const QRect &r) const Q_DECL_NOTHROW; + bool contains(const QRect &r, bool proper = false) const noexcept; + 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; + bool intersects(const QRect &r) const noexcept; - Q_DECL_CONSTEXPR inline QRect marginsAdded(const QMargins &margins) const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline QRect marginsRemoved(const QMargins &margins) const Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline QRect &operator+=(const QMargins &margins) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline QRect &operator-=(const QMargins &margins) Q_DECL_NOTHROW; + Q_DECL_CONSTEXPR inline QRect marginsAdded(const QMargins &margins) const noexcept; + Q_DECL_CONSTEXPR inline QRect marginsRemoved(const QMargins &margins) const noexcept; + Q_DECL_RELAXED_CONSTEXPR inline QRect &operator+=(const QMargins &margins) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline QRect &operator-=(const QMargins &margins) noexcept; #if QT_DEPRECATED_SINCE(5, 0) - Q_REQUIRED_RESULT QT_DEPRECATED QRect unite(const QRect &r) const Q_DECL_NOTHROW { return united(r); } - Q_REQUIRED_RESULT QT_DEPRECATED QRect intersect(const QRect &r) const Q_DECL_NOTHROW { return intersected(r); } + Q_REQUIRED_RESULT QT_DEPRECATED QRect unite(const QRect &r) const noexcept { return united(r); } + Q_REQUIRED_RESULT QT_DEPRECATED QRect intersect(const QRect &r) const noexcept { return intersected(r); } #endif - friend Q_DECL_CONSTEXPR inline bool operator==(const QRect &, const QRect &) Q_DECL_NOTHROW; - friend Q_DECL_CONSTEXPR inline bool operator!=(const QRect &, const QRect &) Q_DECL_NOTHROW; + friend Q_DECL_CONSTEXPR inline bool operator==(const QRect &, const QRect &) noexcept; + friend Q_DECL_CONSTEXPR inline bool operator!=(const QRect &, const QRect &) noexcept; #if defined(Q_OS_DARWIN) || defined(Q_QDOC) - Q_REQUIRED_RESULT CGRect toCGRect() const Q_DECL_NOTHROW; + Q_REQUIRED_RESULT CGRect toCGRect() const noexcept; #endif private: @@ -165,8 +165,8 @@ private: }; Q_DECLARE_TYPEINFO(QRect, Q_MOVABLE_TYPE); -Q_DECL_CONSTEXPR inline bool operator==(const QRect &, const QRect &) Q_DECL_NOTHROW; -Q_DECL_CONSTEXPR inline bool operator!=(const QRect &, const QRect &) Q_DECL_NOTHROW; +Q_DECL_CONSTEXPR inline bool operator==(const QRect &, const QRect &) noexcept; +Q_DECL_CONSTEXPR inline bool operator!=(const QRect &, const QRect &) noexcept; /***************************************************************************** @@ -181,97 +181,97 @@ Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QRect &); QRect inline member functions *****************************************************************************/ -Q_DECL_CONSTEXPR inline QRect::QRect(int aleft, int atop, int awidth, int aheight) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QRect::QRect(int aleft, int atop, int awidth, int aheight) noexcept : x1(aleft), y1(atop), x2(aleft + awidth - 1), y2(atop + aheight - 1) {} -Q_DECL_CONSTEXPR inline QRect::QRect(const QPoint &atopLeft, const QPoint &abottomRight) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QRect::QRect(const QPoint &atopLeft, const QPoint &abottomRight) noexcept : x1(atopLeft.x()), y1(atopLeft.y()), x2(abottomRight.x()), y2(abottomRight.y()) {} -Q_DECL_CONSTEXPR inline QRect::QRect(const QPoint &atopLeft, const QSize &asize) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QRect::QRect(const QPoint &atopLeft, const QSize &asize) noexcept : x1(atopLeft.x()), y1(atopLeft.y()), x2(atopLeft.x()+asize.width() - 1), y2(atopLeft.y()+asize.height() - 1) {} -Q_DECL_CONSTEXPR inline bool QRect::isNull() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline bool QRect::isNull() const noexcept { return x2 == x1 - 1 && y2 == y1 - 1; } -Q_DECL_CONSTEXPR inline bool QRect::isEmpty() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline bool QRect::isEmpty() const noexcept { return x1 > x2 || y1 > y2; } -Q_DECL_CONSTEXPR inline bool QRect::isValid() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline bool QRect::isValid() const noexcept { return x1 <= x2 && y1 <= y2; } -Q_DECL_CONSTEXPR inline int QRect::left() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline int QRect::left() const noexcept { return x1; } -Q_DECL_CONSTEXPR inline int QRect::top() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline int QRect::top() const noexcept { return y1; } -Q_DECL_CONSTEXPR inline int QRect::right() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline int QRect::right() const noexcept { return x2; } -Q_DECL_CONSTEXPR inline int QRect::bottom() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline int QRect::bottom() const noexcept { return y2; } -Q_DECL_CONSTEXPR inline int QRect::x() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline int QRect::x() const noexcept { return x1; } -Q_DECL_CONSTEXPR inline int QRect::y() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline int QRect::y() const noexcept { return y1; } -Q_DECL_RELAXED_CONSTEXPR inline void QRect::setLeft(int pos) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRect::setLeft(int pos) noexcept { x1 = pos; } -Q_DECL_RELAXED_CONSTEXPR inline void QRect::setTop(int pos) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRect::setTop(int pos) noexcept { y1 = pos; } -Q_DECL_RELAXED_CONSTEXPR inline void QRect::setRight(int pos) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRect::setRight(int pos) noexcept { x2 = pos; } -Q_DECL_RELAXED_CONSTEXPR inline void QRect::setBottom(int pos) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRect::setBottom(int pos) noexcept { y2 = pos; } -Q_DECL_RELAXED_CONSTEXPR inline void QRect::setTopLeft(const QPoint &p) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRect::setTopLeft(const QPoint &p) noexcept { x1 = p.x(); y1 = p.y(); } -Q_DECL_RELAXED_CONSTEXPR inline void QRect::setBottomRight(const QPoint &p) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRect::setBottomRight(const QPoint &p) noexcept { x2 = p.x(); y2 = p.y(); } -Q_DECL_RELAXED_CONSTEXPR inline void QRect::setTopRight(const QPoint &p) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRect::setTopRight(const QPoint &p) noexcept { x2 = p.x(); y1 = p.y(); } -Q_DECL_RELAXED_CONSTEXPR inline void QRect::setBottomLeft(const QPoint &p) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRect::setBottomLeft(const QPoint &p) noexcept { x1 = p.x(); y2 = p.y(); } -Q_DECL_RELAXED_CONSTEXPR inline void QRect::setX(int ax) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRect::setX(int ax) noexcept { x1 = ax; } -Q_DECL_RELAXED_CONSTEXPR inline void QRect::setY(int ay) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRect::setY(int ay) noexcept { y1 = ay; } -Q_DECL_CONSTEXPR inline QPoint QRect::topLeft() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QPoint QRect::topLeft() const noexcept { return QPoint(x1, y1); } -Q_DECL_CONSTEXPR inline QPoint QRect::bottomRight() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QPoint QRect::bottomRight() const noexcept { return QPoint(x2, y2); } -Q_DECL_CONSTEXPR inline QPoint QRect::topRight() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QPoint QRect::topRight() const noexcept { return QPoint(x2, y1); } -Q_DECL_CONSTEXPR inline QPoint QRect::bottomLeft() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QPoint QRect::bottomLeft() const noexcept { return QPoint(x1, y2); } -Q_DECL_CONSTEXPR inline QPoint QRect::center() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QPoint QRect::center() const noexcept { return QPoint(int((qint64(x1)+x2)/2), int((qint64(y1)+y2)/2)); } // cast avoids overflow on addition -Q_DECL_CONSTEXPR inline int QRect::width() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline int QRect::width() const noexcept { return x2 - x1 + 1; } -Q_DECL_CONSTEXPR inline int QRect::height() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline int QRect::height() const noexcept { return y2 - y1 + 1; } -Q_DECL_CONSTEXPR inline QSize QRect::size() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QSize QRect::size() const noexcept { return QSize(width(), height()); } -Q_DECL_RELAXED_CONSTEXPR inline void QRect::translate(int dx, int dy) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRect::translate(int dx, int dy) noexcept { x1 += dx; y1 += dy; @@ -279,7 +279,7 @@ Q_DECL_RELAXED_CONSTEXPR inline void QRect::translate(int dx, int dy) Q_DECL_NOT y2 += dy; } -Q_DECL_RELAXED_CONSTEXPR inline void QRect::translate(const QPoint &p) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRect::translate(const QPoint &p) noexcept { x1 += p.x(); y1 += p.y(); @@ -287,16 +287,16 @@ Q_DECL_RELAXED_CONSTEXPR inline void QRect::translate(const QPoint &p) Q_DECL_NO y2 += p.y(); } -Q_DECL_CONSTEXPR inline QRect QRect::translated(int dx, int dy) const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QRect QRect::translated(int dx, int dy) const noexcept { return QRect(QPoint(x1 + dx, y1 + dy), QPoint(x2 + dx, y2 + dy)); } -Q_DECL_CONSTEXPR inline QRect QRect::translated(const QPoint &p) const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QRect QRect::translated(const QPoint &p) const noexcept { return QRect(QPoint(x1 + p.x(), y1 + p.y()), QPoint(x2 + p.x(), y2 + p.y())); } -Q_DECL_CONSTEXPR inline QRect QRect::transposed() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QRect QRect::transposed() const noexcept { return QRect(topLeft(), size().transposed()); } -Q_DECL_RELAXED_CONSTEXPR inline void QRect::moveTo(int ax, int ay) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRect::moveTo(int ax, int ay) noexcept { x2 += ax - x1; y2 += ay - y1; @@ -304,7 +304,7 @@ Q_DECL_RELAXED_CONSTEXPR inline void QRect::moveTo(int ax, int ay) Q_DECL_NOTHRO y1 = ay; } -Q_DECL_RELAXED_CONSTEXPR inline void QRect::moveTo(const QPoint &p) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRect::moveTo(const QPoint &p) noexcept { x2 += p.x() - x1; y2 += p.y() - y1; @@ -312,49 +312,49 @@ Q_DECL_RELAXED_CONSTEXPR inline void QRect::moveTo(const QPoint &p) Q_DECL_NOTHR y1 = p.y(); } -Q_DECL_RELAXED_CONSTEXPR inline void QRect::moveLeft(int pos) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRect::moveLeft(int pos) noexcept { x2 += (pos - x1); x1 = pos; } -Q_DECL_RELAXED_CONSTEXPR inline void QRect::moveTop(int pos) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRect::moveTop(int pos) noexcept { y2 += (pos - y1); y1 = pos; } -Q_DECL_RELAXED_CONSTEXPR inline void QRect::moveRight(int pos) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRect::moveRight(int pos) noexcept { x1 += (pos - x2); x2 = pos; } -Q_DECL_RELAXED_CONSTEXPR inline void QRect::moveBottom(int pos) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRect::moveBottom(int pos) noexcept { y1 += (pos - y2); y2 = pos; } -Q_DECL_RELAXED_CONSTEXPR inline void QRect::moveTopLeft(const QPoint &p) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRect::moveTopLeft(const QPoint &p) noexcept { moveLeft(p.x()); moveTop(p.y()); } -Q_DECL_RELAXED_CONSTEXPR inline void QRect::moveBottomRight(const QPoint &p) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRect::moveBottomRight(const QPoint &p) noexcept { moveRight(p.x()); moveBottom(p.y()); } -Q_DECL_RELAXED_CONSTEXPR inline void QRect::moveTopRight(const QPoint &p) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRect::moveTopRight(const QPoint &p) noexcept { moveRight(p.x()); moveTop(p.y()); } -Q_DECL_RELAXED_CONSTEXPR inline void QRect::moveBottomLeft(const QPoint &p) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRect::moveBottomLeft(const QPoint &p) noexcept { moveLeft(p.x()); moveBottom(p.y()); } -Q_DECL_RELAXED_CONSTEXPR inline void QRect::moveCenter(const QPoint &p) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRect::moveCenter(const QPoint &p) noexcept { int w = x2 - x1; int h = y2 - y1; @@ -372,7 +372,7 @@ Q_DECL_RELAXED_CONSTEXPR inline void QRect::getRect(int *ax, int *ay, int *aw, i *ah = y2 - y1 + 1; } -Q_DECL_RELAXED_CONSTEXPR inline void QRect::setRect(int ax, int ay, int aw, int ah) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRect::setRect(int ax, int ay, int aw, int ah) noexcept { x1 = ax; y1 = ay; @@ -388,7 +388,7 @@ Q_DECL_RELAXED_CONSTEXPR inline void QRect::getCoords(int *xp1, int *yp1, int *x *yp2 = y2; } -Q_DECL_RELAXED_CONSTEXPR inline void QRect::setCoords(int xp1, int yp1, int xp2, int yp2) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRect::setCoords(int xp1, int yp1, int xp2, int yp2) noexcept { x1 = xp1; y1 = yp1; @@ -396,10 +396,10 @@ Q_DECL_RELAXED_CONSTEXPR inline void QRect::setCoords(int xp1, int yp1, int xp2, y2 = yp2; } -Q_DECL_CONSTEXPR inline QRect QRect::adjusted(int xp1, int yp1, int xp2, int yp2) const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QRect QRect::adjusted(int xp1, int yp1, int xp2, int yp2) const noexcept { return QRect(QPoint(x1 + xp1, y1 + yp1), QPoint(x2 + xp2, y2 + yp2)); } -Q_DECL_RELAXED_CONSTEXPR inline void QRect::adjust(int dx1, int dy1, int dx2, int dy2) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRect::adjust(int dx1, int dy1, int dx2, int dy2) noexcept { x1 += dx1; y1 += dy1; @@ -407,97 +407,97 @@ Q_DECL_RELAXED_CONSTEXPR inline void QRect::adjust(int dx1, int dy1, int dx2, in y2 += dy2; } -Q_DECL_RELAXED_CONSTEXPR inline void QRect::setWidth(int w) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRect::setWidth(int w) noexcept { x2 = (x1 + w - 1); } -Q_DECL_RELAXED_CONSTEXPR inline void QRect::setHeight(int h) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRect::setHeight(int h) noexcept { y2 = (y1 + h - 1); } -Q_DECL_RELAXED_CONSTEXPR inline void QRect::setSize(const QSize &s) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRect::setSize(const QSize &s) noexcept { x2 = (s.width() + x1 - 1); y2 = (s.height() + y1 - 1); } -inline bool QRect::contains(int ax, int ay, bool aproper) const Q_DECL_NOTHROW +inline bool QRect::contains(int ax, int ay, bool aproper) const noexcept { return contains(QPoint(ax, ay), aproper); } -inline bool QRect::contains(int ax, int ay) const Q_DECL_NOTHROW +inline bool QRect::contains(int ax, int ay) const noexcept { return contains(QPoint(ax, ay), false); } -inline QRect& QRect::operator|=(const QRect &r) Q_DECL_NOTHROW +inline QRect& QRect::operator|=(const QRect &r) noexcept { *this = *this | r; return *this; } -inline QRect& QRect::operator&=(const QRect &r) Q_DECL_NOTHROW +inline QRect& QRect::operator&=(const QRect &r) noexcept { *this = *this & r; return *this; } -inline QRect QRect::intersected(const QRect &other) const Q_DECL_NOTHROW +inline QRect QRect::intersected(const QRect &other) const noexcept { return *this & other; } -inline QRect QRect::united(const QRect &r) const Q_DECL_NOTHROW +inline QRect QRect::united(const QRect &r) const noexcept { return *this | r; } -Q_DECL_CONSTEXPR inline bool operator==(const QRect &r1, const QRect &r2) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline bool operator==(const QRect &r1, const QRect &r2) noexcept { return r1.x1==r2.x1 && r1.x2==r2.x2 && r1.y1==r2.y1 && r1.y2==r2.y2; } -Q_DECL_CONSTEXPR inline bool operator!=(const QRect &r1, const QRect &r2) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline bool operator!=(const QRect &r1, const QRect &r2) noexcept { return r1.x1!=r2.x1 || r1.x2!=r2.x2 || r1.y1!=r2.y1 || r1.y2!=r2.y2; } -Q_DECL_CONSTEXPR inline QRect operator+(const QRect &rectangle, const QMargins &margins) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QRect operator+(const QRect &rectangle, const QMargins &margins) noexcept { return QRect(QPoint(rectangle.left() - margins.left(), rectangle.top() - margins.top()), QPoint(rectangle.right() + margins.right(), rectangle.bottom() + margins.bottom())); } -Q_DECL_CONSTEXPR inline QRect operator+(const QMargins &margins, const QRect &rectangle) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QRect operator+(const QMargins &margins, const QRect &rectangle) noexcept { return QRect(QPoint(rectangle.left() - margins.left(), rectangle.top() - margins.top()), QPoint(rectangle.right() + margins.right(), rectangle.bottom() + margins.bottom())); } -Q_DECL_CONSTEXPR inline QRect operator-(const QRect &lhs, const QMargins &rhs) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QRect operator-(const QRect &lhs, const QMargins &rhs) noexcept { return QRect(QPoint(lhs.left() + rhs.left(), lhs.top() + rhs.top()), QPoint(lhs.right() - rhs.right(), lhs.bottom() - rhs.bottom())); } -Q_DECL_CONSTEXPR inline QRect QRect::marginsAdded(const QMargins &margins) const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QRect QRect::marginsAdded(const QMargins &margins) const noexcept { return QRect(QPoint(x1 - margins.left(), y1 - margins.top()), QPoint(x2 + margins.right(), y2 + margins.bottom())); } -Q_DECL_CONSTEXPR inline QRect QRect::marginsRemoved(const QMargins &margins) const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QRect QRect::marginsRemoved(const QMargins &margins) const noexcept { return QRect(QPoint(x1 + margins.left(), y1 + margins.top()), QPoint(x2 - margins.right(), y2 - margins.bottom())); } -Q_DECL_RELAXED_CONSTEXPR inline QRect &QRect::operator+=(const QMargins &margins) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline QRect &QRect::operator+=(const QMargins &margins) noexcept { *this = marginsAdded(margins); return *this; } -Q_DECL_RELAXED_CONSTEXPR inline QRect &QRect::operator-=(const QMargins &margins) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline QRect &QRect::operator-=(const QMargins &margins) noexcept { *this = marginsRemoved(margins); return *this; @@ -511,110 +511,110 @@ Q_CORE_EXPORT QDebug operator<<(QDebug, const QRect &); class Q_CORE_EXPORT QRectF { public: - Q_DECL_CONSTEXPR QRectF() Q_DECL_NOTHROW : xp(0.), yp(0.), w(0.), h(0.) {} - Q_DECL_CONSTEXPR QRectF(const QPointF &topleft, const QSizeF &size) Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR QRectF(const QPointF &topleft, const QPointF &bottomRight) Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR QRectF(qreal left, qreal top, qreal width, qreal height) Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR QRectF(const QRect &rect) Q_DECL_NOTHROW; + Q_DECL_CONSTEXPR QRectF() noexcept : xp(0.), yp(0.), w(0.), h(0.) {} + Q_DECL_CONSTEXPR QRectF(const QPointF &topleft, const QSizeF &size) noexcept; + Q_DECL_CONSTEXPR QRectF(const QPointF &topleft, const QPointF &bottomRight) noexcept; + Q_DECL_CONSTEXPR QRectF(qreal left, qreal top, qreal width, qreal height) noexcept; + Q_DECL_CONSTEXPR QRectF(const QRect &rect) noexcept; - Q_DECL_CONSTEXPR inline bool isNull() const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline bool isEmpty() const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline bool isValid() const Q_DECL_NOTHROW; - Q_REQUIRED_RESULT QRectF normalized() const Q_DECL_NOTHROW; + Q_DECL_CONSTEXPR inline bool isNull() const noexcept; + Q_DECL_CONSTEXPR inline bool isEmpty() const noexcept; + Q_DECL_CONSTEXPR inline bool isValid() const noexcept; + Q_REQUIRED_RESULT QRectF normalized() const noexcept; - Q_DECL_CONSTEXPR inline qreal left() const Q_DECL_NOTHROW { return xp; } - Q_DECL_CONSTEXPR inline qreal top() const Q_DECL_NOTHROW { return yp; } - Q_DECL_CONSTEXPR inline qreal right() const Q_DECL_NOTHROW { return xp + w; } - Q_DECL_CONSTEXPR inline qreal bottom() const Q_DECL_NOTHROW { return yp + h; } + Q_DECL_CONSTEXPR inline qreal left() const noexcept { return xp; } + Q_DECL_CONSTEXPR inline qreal top() const noexcept { return yp; } + Q_DECL_CONSTEXPR inline qreal right() const noexcept { return xp + w; } + Q_DECL_CONSTEXPR inline qreal bottom() const noexcept { return yp + h; } - Q_DECL_CONSTEXPR inline qreal x() const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline qreal y() const Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void setLeft(qreal pos) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void setTop(qreal pos) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void setRight(qreal pos) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void setBottom(qreal pos) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void setX(qreal pos) Q_DECL_NOTHROW { setLeft(pos); } - Q_DECL_RELAXED_CONSTEXPR inline void setY(qreal pos) Q_DECL_NOTHROW { setTop(pos); } + Q_DECL_CONSTEXPR inline qreal x() const noexcept; + Q_DECL_CONSTEXPR inline qreal y() const noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void setLeft(qreal pos) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void setTop(qreal pos) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void setRight(qreal pos) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void setBottom(qreal pos) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void setX(qreal pos) noexcept { setLeft(pos); } + Q_DECL_RELAXED_CONSTEXPR inline void setY(qreal pos) noexcept { setTop(pos); } - Q_DECL_CONSTEXPR inline QPointF topLeft() const Q_DECL_NOTHROW { return QPointF(xp, yp); } - Q_DECL_CONSTEXPR inline QPointF bottomRight() const Q_DECL_NOTHROW { return QPointF(xp+w, yp+h); } - Q_DECL_CONSTEXPR inline QPointF topRight() const Q_DECL_NOTHROW { return QPointF(xp+w, yp); } - Q_DECL_CONSTEXPR inline QPointF bottomLeft() const Q_DECL_NOTHROW { return QPointF(xp, yp+h); } - Q_DECL_CONSTEXPR inline QPointF center() const Q_DECL_NOTHROW; + Q_DECL_CONSTEXPR inline QPointF topLeft() const noexcept { return QPointF(xp, yp); } + Q_DECL_CONSTEXPR inline QPointF bottomRight() const noexcept { return QPointF(xp+w, yp+h); } + Q_DECL_CONSTEXPR inline QPointF topRight() const noexcept { return QPointF(xp+w, yp); } + Q_DECL_CONSTEXPR inline QPointF bottomLeft() const noexcept { return QPointF(xp, yp+h); } + Q_DECL_CONSTEXPR inline QPointF center() const noexcept; - Q_DECL_RELAXED_CONSTEXPR inline void setTopLeft(const QPointF &p) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void setBottomRight(const QPointF &p) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void setTopRight(const QPointF &p) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void setBottomLeft(const QPointF &p) Q_DECL_NOTHROW; + Q_DECL_RELAXED_CONSTEXPR inline void setTopLeft(const QPointF &p) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void setBottomRight(const QPointF &p) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void setTopRight(const QPointF &p) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void setBottomLeft(const QPointF &p) noexcept; - Q_DECL_RELAXED_CONSTEXPR inline void moveLeft(qreal pos) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void moveTop(qreal pos) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void moveRight(qreal pos) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void moveBottom(qreal pos) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void moveTopLeft(const QPointF &p) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void moveBottomRight(const QPointF &p) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void moveTopRight(const QPointF &p) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void moveBottomLeft(const QPointF &p) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void moveCenter(const QPointF &p) Q_DECL_NOTHROW; + Q_DECL_RELAXED_CONSTEXPR inline void moveLeft(qreal pos) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void moveTop(qreal pos) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void moveRight(qreal pos) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void moveBottom(qreal pos) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void moveTopLeft(const QPointF &p) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void moveBottomRight(const QPointF &p) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void moveTopRight(const QPointF &p) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void moveBottomLeft(const QPointF &p) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void moveCenter(const QPointF &p) noexcept; - Q_DECL_RELAXED_CONSTEXPR inline void translate(qreal dx, qreal dy) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void translate(const QPointF &p) Q_DECL_NOTHROW; + Q_DECL_RELAXED_CONSTEXPR inline void translate(qreal dx, qreal dy) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void translate(const QPointF &p) noexcept; - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRectF translated(qreal dx, qreal dy) const Q_DECL_NOTHROW; - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRectF translated(const QPointF &p) const Q_DECL_NOTHROW; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRectF translated(qreal dx, qreal dy) const noexcept; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRectF translated(const QPointF &p) const noexcept; - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRectF transposed() const Q_DECL_NOTHROW; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRectF transposed() const noexcept; - Q_DECL_RELAXED_CONSTEXPR inline void moveTo(qreal x, qreal y) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void moveTo(const QPointF &p) Q_DECL_NOTHROW; + Q_DECL_RELAXED_CONSTEXPR inline void moveTo(qreal x, qreal y) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void moveTo(const QPointF &p) noexcept; - Q_DECL_RELAXED_CONSTEXPR inline void setRect(qreal x, qreal y, qreal w, qreal h) Q_DECL_NOTHROW; + Q_DECL_RELAXED_CONSTEXPR inline void setRect(qreal x, qreal y, qreal w, qreal h) noexcept; Q_DECL_RELAXED_CONSTEXPR inline void getRect(qreal *x, qreal *y, qreal *w, qreal *h) const; - Q_DECL_RELAXED_CONSTEXPR inline void setCoords(qreal x1, qreal y1, qreal x2, qreal y2) Q_DECL_NOTHROW; + Q_DECL_RELAXED_CONSTEXPR inline void setCoords(qreal x1, qreal y1, qreal x2, qreal y2) noexcept; Q_DECL_RELAXED_CONSTEXPR inline void getCoords(qreal *x1, qreal *y1, qreal *x2, qreal *y2) const; - Q_DECL_RELAXED_CONSTEXPR inline void adjust(qreal x1, qreal y1, qreal x2, qreal y2) Q_DECL_NOTHROW; - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRectF adjusted(qreal x1, qreal y1, qreal x2, qreal y2) const Q_DECL_NOTHROW; + Q_DECL_RELAXED_CONSTEXPR inline void adjust(qreal x1, qreal y1, qreal x2, qreal y2) noexcept; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRectF adjusted(qreal x1, qreal y1, qreal x2, qreal y2) const noexcept; - Q_DECL_CONSTEXPR inline QSizeF size() const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline qreal width() const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline qreal height() const Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void setWidth(qreal w) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void setHeight(qreal h) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void setSize(const QSizeF &s) Q_DECL_NOTHROW; + Q_DECL_CONSTEXPR inline QSizeF size() const noexcept; + Q_DECL_CONSTEXPR inline qreal width() const noexcept; + Q_DECL_CONSTEXPR inline qreal height() const noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void setWidth(qreal w) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void setHeight(qreal h) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void setSize(const QSizeF &s) noexcept; - QRectF operator|(const QRectF &r) const Q_DECL_NOTHROW; - QRectF operator&(const QRectF &r) const Q_DECL_NOTHROW; - inline QRectF& operator|=(const QRectF &r) Q_DECL_NOTHROW; - inline QRectF& operator&=(const QRectF &r) Q_DECL_NOTHROW; + QRectF operator|(const QRectF &r) const noexcept; + QRectF operator&(const QRectF &r) const noexcept; + inline QRectF& operator|=(const QRectF &r) noexcept; + inline QRectF& operator&=(const QRectF &r) noexcept; - bool contains(const QRectF &r) const Q_DECL_NOTHROW; - bool contains(const QPointF &p) const Q_DECL_NOTHROW; - inline bool contains(qreal x, qreal y) const Q_DECL_NOTHROW; - Q_REQUIRED_RESULT inline QRectF united(const QRectF &other) const Q_DECL_NOTHROW; - Q_REQUIRED_RESULT inline QRectF intersected(const QRectF &other) const Q_DECL_NOTHROW; - bool intersects(const QRectF &r) const Q_DECL_NOTHROW; + 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; + bool intersects(const QRectF &r) const noexcept; - Q_DECL_CONSTEXPR inline QRectF marginsAdded(const QMarginsF &margins) const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline QRectF marginsRemoved(const QMarginsF &margins) const Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline QRectF &operator+=(const QMarginsF &margins) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline QRectF &operator-=(const QMarginsF &margins) Q_DECL_NOTHROW; + Q_DECL_CONSTEXPR inline QRectF marginsAdded(const QMarginsF &margins) const noexcept; + Q_DECL_CONSTEXPR inline QRectF marginsRemoved(const QMarginsF &margins) const noexcept; + Q_DECL_RELAXED_CONSTEXPR inline QRectF &operator+=(const QMarginsF &margins) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline QRectF &operator-=(const QMarginsF &margins) noexcept; #if QT_DEPRECATED_SINCE(5, 0) - Q_REQUIRED_RESULT QT_DEPRECATED QRectF unite(const QRectF &r) const Q_DECL_NOTHROW { return united(r); } - Q_REQUIRED_RESULT QT_DEPRECATED QRectF intersect(const QRectF &r) const Q_DECL_NOTHROW { return intersected(r); } + Q_REQUIRED_RESULT QT_DEPRECATED QRectF unite(const QRectF &r) const noexcept { return united(r); } + Q_REQUIRED_RESULT QT_DEPRECATED QRectF intersect(const QRectF &r) const noexcept { return intersected(r); } #endif - friend Q_DECL_CONSTEXPR inline bool operator==(const QRectF &, const QRectF &) Q_DECL_NOTHROW; - friend Q_DECL_CONSTEXPR inline bool operator!=(const QRectF &, const QRectF &) Q_DECL_NOTHROW; + friend Q_DECL_CONSTEXPR inline bool operator==(const QRectF &, const QRectF &) noexcept; + friend Q_DECL_CONSTEXPR inline bool operator!=(const QRectF &, const QRectF &) noexcept; - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRect toRect() const Q_DECL_NOTHROW; - Q_REQUIRED_RESULT QRect toAlignedRect() const Q_DECL_NOTHROW; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRect toRect() const noexcept; + Q_REQUIRED_RESULT QRect toAlignedRect() const noexcept; #if defined(Q_OS_DARWIN) || defined(Q_QDOC) - Q_REQUIRED_RESULT static QRectF fromCGRect(CGRect rect) Q_DECL_NOTHROW; - Q_REQUIRED_RESULT CGRect toCGRect() const Q_DECL_NOTHROW; + Q_REQUIRED_RESULT static QRectF fromCGRect(CGRect rect) noexcept; + Q_REQUIRED_RESULT CGRect toCGRect() const noexcept; #endif private: @@ -625,8 +625,8 @@ private: }; Q_DECLARE_TYPEINFO(QRectF, Q_MOVABLE_TYPE); -Q_DECL_CONSTEXPR inline bool operator==(const QRectF &, const QRectF &) Q_DECL_NOTHROW; -Q_DECL_CONSTEXPR inline bool operator!=(const QRectF &, const QRectF &) Q_DECL_NOTHROW; +Q_DECL_CONSTEXPR inline bool operator==(const QRectF &, const QRectF &) noexcept; +Q_DECL_CONSTEXPR inline bool operator!=(const QRectF &, const QRectF &) noexcept; /***************************************************************************** @@ -641,23 +641,23 @@ Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QRectF &); QRectF inline member functions *****************************************************************************/ -Q_DECL_CONSTEXPR inline QRectF::QRectF(qreal aleft, qreal atop, qreal awidth, qreal aheight) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QRectF::QRectF(qreal aleft, qreal atop, qreal awidth, qreal aheight) noexcept : xp(aleft), yp(atop), w(awidth), h(aheight) { } -Q_DECL_CONSTEXPR inline QRectF::QRectF(const QPointF &atopLeft, const QSizeF &asize) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QRectF::QRectF(const QPointF &atopLeft, const QSizeF &asize) noexcept : xp(atopLeft.x()), yp(atopLeft.y()), w(asize.width()), h(asize.height()) { } -Q_DECL_CONSTEXPR inline QRectF::QRectF(const QPointF &atopLeft, const QPointF &abottomRight) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QRectF::QRectF(const QPointF &atopLeft, const QPointF &abottomRight) noexcept : xp(atopLeft.x()), yp(atopLeft.y()), w(abottomRight.x() - atopLeft.x()), h(abottomRight.y() - atopLeft.y()) { } -Q_DECL_CONSTEXPR inline QRectF::QRectF(const QRect &r) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QRectF::QRectF(const QRect &r) noexcept : xp(r.x()), yp(r.y()), w(r.width()), h(r.height()) { } @@ -666,117 +666,117 @@ QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wfloat-equal") QT_WARNING_DISABLE_GCC("-Wfloat-equal") -Q_DECL_CONSTEXPR inline bool QRectF::isNull() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline bool QRectF::isNull() const noexcept { return w == 0. && h == 0.; } -Q_DECL_CONSTEXPR inline bool QRectF::isEmpty() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline bool QRectF::isEmpty() const noexcept { return w <= 0. || h <= 0.; } QT_WARNING_POP -Q_DECL_CONSTEXPR inline bool QRectF::isValid() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline bool QRectF::isValid() const noexcept { return w > 0. && h > 0.; } -Q_DECL_CONSTEXPR inline qreal QRectF::x() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline qreal QRectF::x() const noexcept { return xp; } -Q_DECL_CONSTEXPR inline qreal QRectF::y() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline qreal QRectF::y() const noexcept { return yp; } -Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setLeft(qreal pos) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setLeft(qreal pos) noexcept { qreal diff = pos - xp; xp += diff; w -= diff; } -Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setRight(qreal pos) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setRight(qreal pos) noexcept { w = pos - xp; } -Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setTop(qreal pos) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setTop(qreal pos) noexcept { qreal diff = pos - yp; yp += diff; h -= diff; } -Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setBottom(qreal pos) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setBottom(qreal pos) noexcept { h = pos - yp; } -Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setTopLeft(const QPointF &p) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setTopLeft(const QPointF &p) noexcept { setLeft(p.x()); setTop(p.y()); } -Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setTopRight(const QPointF &p) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setTopRight(const QPointF &p) noexcept { setRight(p.x()); setTop(p.y()); } -Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setBottomLeft(const QPointF &p) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setBottomLeft(const QPointF &p) noexcept { setLeft(p.x()); setBottom(p.y()); } -Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setBottomRight(const QPointF &p) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setBottomRight(const QPointF &p) noexcept { setRight(p.x()); setBottom(p.y()); } -Q_DECL_CONSTEXPR inline QPointF QRectF::center() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QPointF QRectF::center() const noexcept { return QPointF(xp + w/2, yp + h/2); } -Q_DECL_RELAXED_CONSTEXPR inline void QRectF::moveLeft(qreal pos) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRectF::moveLeft(qreal pos) noexcept { xp = pos; } -Q_DECL_RELAXED_CONSTEXPR inline void QRectF::moveTop(qreal pos) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRectF::moveTop(qreal pos) noexcept { yp = pos; } -Q_DECL_RELAXED_CONSTEXPR inline void QRectF::moveRight(qreal pos) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRectF::moveRight(qreal pos) noexcept { xp = pos - w; } -Q_DECL_RELAXED_CONSTEXPR inline void QRectF::moveBottom(qreal pos) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRectF::moveBottom(qreal pos) noexcept { yp = pos - h; } -Q_DECL_RELAXED_CONSTEXPR inline void QRectF::moveTopLeft(const QPointF &p) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRectF::moveTopLeft(const QPointF &p) noexcept { moveLeft(p.x()); moveTop(p.y()); } -Q_DECL_RELAXED_CONSTEXPR inline void QRectF::moveTopRight(const QPointF &p) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRectF::moveTopRight(const QPointF &p) noexcept { moveRight(p.x()); moveTop(p.y()); } -Q_DECL_RELAXED_CONSTEXPR inline void QRectF::moveBottomLeft(const QPointF &p) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRectF::moveBottomLeft(const QPointF &p) noexcept { moveLeft(p.x()); moveBottom(p.y()); } -Q_DECL_RELAXED_CONSTEXPR inline void QRectF::moveBottomRight(const QPointF &p) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRectF::moveBottomRight(const QPointF &p) noexcept { moveRight(p.x()); moveBottom(p.y()); } -Q_DECL_RELAXED_CONSTEXPR inline void QRectF::moveCenter(const QPointF &p) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRectF::moveCenter(const QPointF &p) noexcept { xp = p.x() - w/2; yp = p.y() - h/2; } -Q_DECL_CONSTEXPR inline qreal QRectF::width() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline qreal QRectF::width() const noexcept { return w; } -Q_DECL_CONSTEXPR inline qreal QRectF::height() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline qreal QRectF::height() const noexcept { return h; } -Q_DECL_CONSTEXPR inline QSizeF QRectF::size() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QSizeF QRectF::size() const noexcept { return QSizeF(w, h); } -Q_DECL_RELAXED_CONSTEXPR inline void QRectF::translate(qreal dx, qreal dy) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRectF::translate(qreal dx, qreal dy) noexcept { xp += dx; yp += dy; } -Q_DECL_RELAXED_CONSTEXPR inline void QRectF::translate(const QPointF &p) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRectF::translate(const QPointF &p) noexcept { xp += p.x(); yp += p.y(); } -Q_DECL_RELAXED_CONSTEXPR inline void QRectF::moveTo(qreal ax, qreal ay) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRectF::moveTo(qreal ax, qreal ay) noexcept { xp = ax; yp = ay; } -Q_DECL_RELAXED_CONSTEXPR inline void QRectF::moveTo(const QPointF &p) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRectF::moveTo(const QPointF &p) noexcept { xp = p.x(); yp = p.y(); } -Q_DECL_CONSTEXPR inline QRectF QRectF::translated(qreal dx, qreal dy) const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QRectF QRectF::translated(qreal dx, qreal dy) const noexcept { return QRectF(xp + dx, yp + dy, w, h); } -Q_DECL_CONSTEXPR inline QRectF QRectF::translated(const QPointF &p) const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QRectF QRectF::translated(const QPointF &p) const noexcept { return QRectF(xp + p.x(), yp + p.y(), w, h); } -Q_DECL_CONSTEXPR inline QRectF QRectF::transposed() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QRectF QRectF::transposed() const noexcept { return QRectF(topLeft(), size().transposed()); } Q_DECL_RELAXED_CONSTEXPR inline void QRectF::getRect(qreal *ax, qreal *ay, qreal *aaw, qreal *aah) const @@ -787,7 +787,7 @@ Q_DECL_RELAXED_CONSTEXPR inline void QRectF::getRect(qreal *ax, qreal *ay, qreal *aah = this->h; } -Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setRect(qreal ax, qreal ay, qreal aaw, qreal aah) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setRect(qreal ax, qreal ay, qreal aaw, qreal aah) noexcept { this->xp = ax; this->yp = ay; @@ -803,7 +803,7 @@ Q_DECL_RELAXED_CONSTEXPR inline void QRectF::getCoords(qreal *xp1, qreal *yp1, q *yp2 = yp + h; } -Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setCoords(qreal xp1, qreal yp1, qreal xp2, qreal yp2) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setCoords(qreal xp1, qreal yp1, qreal xp2, qreal yp2) noexcept { xp = xp1; yp = yp1; @@ -811,105 +811,105 @@ Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setCoords(qreal xp1, qreal yp1, qre h = yp2 - yp1; } -Q_DECL_RELAXED_CONSTEXPR inline void QRectF::adjust(qreal xp1, qreal yp1, qreal xp2, qreal yp2) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRectF::adjust(qreal xp1, qreal yp1, qreal xp2, qreal yp2) noexcept { xp += xp1; yp += yp1; w += xp2 - xp1; h += yp2 - yp1; } -Q_DECL_CONSTEXPR inline QRectF QRectF::adjusted(qreal xp1, qreal yp1, qreal xp2, qreal yp2) const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QRectF QRectF::adjusted(qreal xp1, qreal yp1, qreal xp2, qreal yp2) const noexcept { return QRectF(xp + xp1, yp + yp1, w + xp2 - xp1, h + yp2 - yp1); } -Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setWidth(qreal aw) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setWidth(qreal aw) noexcept { this->w = aw; } -Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setHeight(qreal ah) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setHeight(qreal ah) noexcept { this->h = ah; } -Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setSize(const QSizeF &s) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setSize(const QSizeF &s) noexcept { w = s.width(); h = s.height(); } -inline bool QRectF::contains(qreal ax, qreal ay) const Q_DECL_NOTHROW +inline bool QRectF::contains(qreal ax, qreal ay) const noexcept { return contains(QPointF(ax, ay)); } -inline QRectF& QRectF::operator|=(const QRectF &r) Q_DECL_NOTHROW +inline QRectF& QRectF::operator|=(const QRectF &r) noexcept { *this = *this | r; return *this; } -inline QRectF& QRectF::operator&=(const QRectF &r) Q_DECL_NOTHROW +inline QRectF& QRectF::operator&=(const QRectF &r) noexcept { *this = *this & r; return *this; } -inline QRectF QRectF::intersected(const QRectF &r) const Q_DECL_NOTHROW +inline QRectF QRectF::intersected(const QRectF &r) const noexcept { return *this & r; } -inline QRectF QRectF::united(const QRectF &r) const Q_DECL_NOTHROW +inline QRectF QRectF::united(const QRectF &r) const noexcept { return *this | r; } -Q_DECL_CONSTEXPR inline bool operator==(const QRectF &r1, const QRectF &r2) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline bool operator==(const QRectF &r1, const QRectF &r2) noexcept { return qFuzzyCompare(r1.xp, r2.xp) && qFuzzyCompare(r1.yp, r2.yp) && qFuzzyCompare(r1.w, r2.w) && qFuzzyCompare(r1.h, r2.h); } -Q_DECL_CONSTEXPR inline bool operator!=(const QRectF &r1, const QRectF &r2) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline bool operator!=(const QRectF &r1, const QRectF &r2) noexcept { return !qFuzzyCompare(r1.xp, r2.xp) || !qFuzzyCompare(r1.yp, r2.yp) || !qFuzzyCompare(r1.w, r2.w) || !qFuzzyCompare(r1.h, r2.h); } -Q_DECL_CONSTEXPR inline QRect QRectF::toRect() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QRect QRectF::toRect() const noexcept { return QRect(QPoint(qRound(xp), qRound(yp)), QPoint(qRound(xp + w) - 1, qRound(yp + h) - 1)); } -Q_DECL_CONSTEXPR inline QRectF operator+(const QRectF &lhs, const QMarginsF &rhs) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QRectF operator+(const QRectF &lhs, const QMarginsF &rhs) noexcept { return QRectF(QPointF(lhs.left() - rhs.left(), lhs.top() - rhs.top()), QSizeF(lhs.width() + rhs.left() + rhs.right(), lhs.height() + rhs.top() + rhs.bottom())); } -Q_DECL_CONSTEXPR inline QRectF operator+(const QMarginsF &lhs, const QRectF &rhs) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QRectF operator+(const QMarginsF &lhs, const QRectF &rhs) noexcept { return QRectF(QPointF(rhs.left() - lhs.left(), rhs.top() - lhs.top()), QSizeF(rhs.width() + lhs.left() + lhs.right(), rhs.height() + lhs.top() + lhs.bottom())); } -Q_DECL_CONSTEXPR inline QRectF operator-(const QRectF &lhs, const QMarginsF &rhs) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QRectF operator-(const QRectF &lhs, const QMarginsF &rhs) noexcept { return QRectF(QPointF(lhs.left() + rhs.left(), lhs.top() + rhs.top()), QSizeF(lhs.width() - rhs.left() - rhs.right(), lhs.height() - rhs.top() - rhs.bottom())); } -Q_DECL_CONSTEXPR inline QRectF QRectF::marginsAdded(const QMarginsF &margins) const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QRectF QRectF::marginsAdded(const QMarginsF &margins) const noexcept { return QRectF(QPointF(xp - margins.left(), yp - margins.top()), QSizeF(w + margins.left() + margins.right(), h + margins.top() + margins.bottom())); } -Q_DECL_CONSTEXPR inline QRectF QRectF::marginsRemoved(const QMarginsF &margins) const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QRectF QRectF::marginsRemoved(const QMarginsF &margins) const noexcept { return QRectF(QPointF(xp + margins.left(), yp + margins.top()), QSizeF(w - margins.left() - margins.right(), h - margins.top() - margins.bottom())); } -Q_DECL_RELAXED_CONSTEXPR inline QRectF &QRectF::operator+=(const QMarginsF &margins) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline QRectF &QRectF::operator+=(const QMarginsF &margins) noexcept { *this = marginsAdded(margins); return *this; } -Q_DECL_RELAXED_CONSTEXPR inline QRectF &QRectF::operator-=(const QMarginsF &margins) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline QRectF &QRectF::operator-=(const QMarginsF &margins) noexcept { *this = marginsRemoved(margins); return *this; diff --git a/src/corelib/tools/qrefcount.h b/src/corelib/tools/qrefcount.h index 9586c3a79a..71adb41f28 100644 --- a/src/corelib/tools/qrefcount.h +++ b/src/corelib/tools/qrefcount.h @@ -51,7 +51,7 @@ namespace QtPrivate class RefCount { public: - inline bool ref() Q_DECL_NOTHROW { + inline bool ref() noexcept { int count = atomic.load(); #if !defined(QT_NO_UNSHARABLE_CONTAINERS) if (count == 0) // !isSharable @@ -62,7 +62,7 @@ public: return true; } - inline bool deref() Q_DECL_NOTHROW { + inline bool deref() noexcept { int count = atomic.load(); #if !defined(QT_NO_UNSHARABLE_CONTAINERS) if (count == 0) // !isSharable @@ -74,7 +74,7 @@ public: } #if !defined(QT_NO_UNSHARABLE_CONTAINERS) - bool setSharable(bool sharable) Q_DECL_NOTHROW + bool setSharable(bool sharable) noexcept { Q_ASSERT(!isShared()); if (sharable) @@ -83,27 +83,27 @@ public: return atomic.testAndSetRelaxed(1, 0); } - bool isSharable() const Q_DECL_NOTHROW + bool isSharable() const noexcept { // Sharable === Shared ownership. return atomic.load() != 0; } #endif - bool isStatic() const Q_DECL_NOTHROW + bool isStatic() const noexcept { // Persistent object, never deleted return atomic.load() == -1; } - bool isShared() const Q_DECL_NOTHROW + bool isShared() const noexcept { int count = atomic.load(); return (count != 1) && (count != 0); } - void initializeOwned() Q_DECL_NOTHROW { atomic.store(1); } - void initializeUnsharable() Q_DECL_NOTHROW { atomic.store(0); } + void initializeOwned() noexcept { atomic.store(1); } + void initializeUnsharable() noexcept { atomic.store(0); } QBasicAtomicInt atomic; }; diff --git a/src/corelib/tools/qregexp.cpp b/src/corelib/tools/qregexp.cpp index 589eb74520..d970843dea 100644 --- a/src/corelib/tools/qregexp.cpp +++ b/src/corelib/tools/qregexp.cpp @@ -890,7 +890,7 @@ static bool operator==(const QRegExpEngineKey &key1, const QRegExpEngineKey &key && key1.cs == key2.cs; } -static uint qHash(const QRegExpEngineKey &key, uint seed = 0) Q_DECL_NOTHROW +static uint qHash(const QRegExpEngineKey &key, uint seed = 0) noexcept { QtPrivate::QHashCombine hash; seed = hash(seed, key.pattern); @@ -4046,7 +4046,7 @@ bool QRegExp::operator==(const QRegExp &rx) const Returns the hash value for \a key, using \a seed to seed the calculation. */ -uint qHash(const QRegExp &key, uint seed) Q_DECL_NOTHROW +uint qHash(const QRegExp &key, uint seed) noexcept { QtPrivate::QHashCombine hash; seed = hash(seed, key.priv->engineKey); diff --git a/src/corelib/tools/qregexp.h b/src/corelib/tools/qregexp.h index b3fa242168..c043a06496 100644 --- a/src/corelib/tools/qregexp.h +++ b/src/corelib/tools/qregexp.h @@ -53,7 +53,7 @@ struct QRegExpPrivate; class QStringList; class QRegExp; -Q_CORE_EXPORT uint qHash(const QRegExp &key, uint seed = 0) Q_DECL_NOTHROW; +Q_CORE_EXPORT uint qHash(const QRegExp &key, uint seed = 0) noexcept; class Q_CORE_EXPORT QRegExp { @@ -74,9 +74,9 @@ public: ~QRegExp(); QRegExp &operator=(const QRegExp &rx); #ifdef Q_COMPILER_RVALUE_REFS - QRegExp &operator=(QRegExp &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QRegExp &operator=(QRegExp &&other) noexcept { swap(other); return *this; } #endif - void swap(QRegExp &other) Q_DECL_NOTHROW { qSwap(priv, other.priv); } + void swap(QRegExp &other) noexcept { qSwap(priv, other.priv); } bool operator==(const QRegExp &rx) const; inline bool operator!=(const QRegExp &rx) const { return !operator==(rx); } @@ -112,7 +112,7 @@ public: static QString escape(const QString &str); - friend Q_CORE_EXPORT uint qHash(const QRegExp &key, uint seed) Q_DECL_NOTHROW; + friend Q_CORE_EXPORT uint qHash(const QRegExp &key, uint seed) noexcept; private: QRegExpPrivate *priv; diff --git a/src/corelib/tools/qregularexpression.cpp b/src/corelib/tools/qregularexpression.cpp index bdaa2d3243..ca1a866842 100644 --- a/src/corelib/tools/qregularexpression.cpp +++ b/src/corelib/tools/qregularexpression.cpp @@ -1810,7 +1810,7 @@ bool QRegularExpression::operator==(const QRegularExpression &re) const Returns the hash value for \a key, using \a seed to seed the calculation. */ -uint qHash(const QRegularExpression &key, uint seed) Q_DECL_NOTHROW +uint qHash(const QRegularExpression &key, uint seed) noexcept { QtPrivate::QHashCombine hash; seed = hash(seed, key.d->pattern); diff --git a/src/corelib/tools/qregularexpression.h b/src/corelib/tools/qregularexpression.h index f9e7029550..f16b7e91be 100644 --- a/src/corelib/tools/qregularexpression.h +++ b/src/corelib/tools/qregularexpression.h @@ -59,7 +59,7 @@ class QRegularExpressionMatchIterator; struct QRegularExpressionPrivate; class QRegularExpression; -Q_CORE_EXPORT uint qHash(const QRegularExpression &key, uint seed = 0) Q_DECL_NOTHROW; +Q_CORE_EXPORT uint qHash(const QRegularExpression &key, uint seed = 0) noexcept; class Q_CORE_EXPORT QRegularExpression { @@ -88,11 +88,11 @@ public: QRegularExpression &operator=(const QRegularExpression &re); #ifdef Q_COMPILER_RVALUE_REFS - QRegularExpression &operator=(QRegularExpression &&re) Q_DECL_NOTHROW + QRegularExpression &operator=(QRegularExpression &&re) noexcept { d.swap(re.d); return *this; } #endif - void swap(QRegularExpression &other) Q_DECL_NOTHROW { d.swap(other.d); } + void swap(QRegularExpression &other) noexcept { d.swap(other.d); } QString pattern() const; void setPattern(const QString &pattern); @@ -157,7 +157,7 @@ private: friend class QRegularExpressionMatch; friend struct QRegularExpressionMatchPrivate; friend class QRegularExpressionMatchIterator; - friend Q_CORE_EXPORT uint qHash(const QRegularExpression &key, uint seed) Q_DECL_NOTHROW; + friend Q_CORE_EXPORT uint qHash(const QRegularExpression &key, uint seed) noexcept; QRegularExpression(QRegularExpressionPrivate &dd); QExplicitlySharedDataPointer d; @@ -188,10 +188,10 @@ public: QRegularExpressionMatch &operator=(const QRegularExpressionMatch &match); #ifdef Q_COMPILER_RVALUE_REFS - QRegularExpressionMatch &operator=(QRegularExpressionMatch &&match) Q_DECL_NOTHROW + QRegularExpressionMatch &operator=(QRegularExpressionMatch &&match) noexcept { d.swap(match.d); return *this; } #endif - void swap(QRegularExpressionMatch &other) Q_DECL_NOTHROW { d.swap(other.d); } + void swap(QRegularExpressionMatch &other) noexcept { d.swap(other.d); } QRegularExpression regularExpression() const; QRegularExpression::MatchType matchType() const; @@ -258,10 +258,10 @@ public: QRegularExpressionMatchIterator(const QRegularExpressionMatchIterator &iterator); QRegularExpressionMatchIterator &operator=(const QRegularExpressionMatchIterator &iterator); #ifdef Q_COMPILER_RVALUE_REFS - QRegularExpressionMatchIterator &operator=(QRegularExpressionMatchIterator &&iterator) Q_DECL_NOTHROW + QRegularExpressionMatchIterator &operator=(QRegularExpressionMatchIterator &&iterator) noexcept { d.swap(iterator.d); return *this; } #endif - void swap(QRegularExpressionMatchIterator &other) Q_DECL_NOTHROW { d.swap(other.d); } + void swap(QRegularExpressionMatchIterator &other) noexcept { d.swap(other.d); } bool isValid() const; diff --git a/src/corelib/tools/qringbuffer_p.h b/src/corelib/tools/qringbuffer_p.h index 76ab4a5b62..838cb31697 100644 --- a/src/corelib/tools/qringbuffer_p.h +++ b/src/corelib/tools/qringbuffer_p.h @@ -65,11 +65,11 @@ class QRingChunk { public: // initialization and cleanup - inline QRingChunk() Q_DECL_NOTHROW : + inline QRingChunk() noexcept : headOffset(0), tailOffset(0) { } - inline QRingChunk(const QRingChunk &other) Q_DECL_NOTHROW : + inline QRingChunk(const QRingChunk &other) noexcept : chunk(other.chunk), headOffset(other.headOffset), tailOffset(other.tailOffset) { } @@ -77,30 +77,30 @@ public: chunk(alloc, Qt::Uninitialized), headOffset(0), tailOffset(0) { } - explicit inline QRingChunk(const QByteArray &qba) Q_DECL_NOTHROW : + explicit inline QRingChunk(const QByteArray &qba) noexcept : chunk(qba), headOffset(0), tailOffset(qba.size()) { } - inline QRingChunk &operator=(const QRingChunk &other) Q_DECL_NOTHROW + inline QRingChunk &operator=(const QRingChunk &other) noexcept { chunk = other.chunk; headOffset = other.headOffset; tailOffset = other.tailOffset; return *this; } - inline QRingChunk(QRingChunk &&other) Q_DECL_NOTHROW : + inline QRingChunk(QRingChunk &&other) noexcept : chunk(other.chunk), headOffset(other.headOffset), tailOffset(other.tailOffset) { other.headOffset = other.tailOffset = 0; } - inline QRingChunk &operator=(QRingChunk &&other) Q_DECL_NOTHROW + inline QRingChunk &operator=(QRingChunk &&other) noexcept { swap(other); return *this; } - inline void swap(QRingChunk &other) Q_DECL_NOTHROW + inline void swap(QRingChunk &other) noexcept { chunk.swap(other.chunk); qSwap(headOffset, other.headOffset); diff --git a/src/corelib/tools/qscopedpointer.h b/src/corelib/tools/qscopedpointer.h index 2a4083466b..756e0aec79 100644 --- a/src/corelib/tools/qscopedpointer.h +++ b/src/corelib/tools/qscopedpointer.h @@ -97,7 +97,7 @@ class QScopedPointer { typedef T *QScopedPointer:: *RestrictedBool; public: - explicit QScopedPointer(T *p = nullptr) Q_DECL_NOTHROW : d(p) + explicit QScopedPointer(T *p = nullptr) noexcept : d(p) { } @@ -113,12 +113,12 @@ public: return *d; } - T *operator->() const Q_DECL_NOTHROW + T *operator->() const noexcept { return d; } - bool operator!() const Q_DECL_NOTHROW + bool operator!() const noexcept { return !d; } @@ -129,23 +129,23 @@ public: return isNull() ? nullptr : &QScopedPointer::d; } #else - operator RestrictedBool() const Q_DECL_NOTHROW + operator RestrictedBool() const noexcept { return isNull() ? nullptr : &QScopedPointer::d; } #endif - T *data() const Q_DECL_NOTHROW + T *data() const noexcept { return d; } - T *get() const Q_DECL_NOTHROW + T *get() const noexcept { return d; } - bool isNull() const Q_DECL_NOTHROW + bool isNull() const noexcept { return !d; } @@ -159,14 +159,14 @@ public: Cleanup::cleanup(oldD); } - T *take() Q_DECL_NOTHROW + T *take() noexcept { T *oldD = d; d = nullptr; return oldD; } - void swap(QScopedPointer &other) Q_DECL_NOTHROW + void swap(QScopedPointer &other) noexcept { qSwap(d, other.d); } @@ -181,43 +181,43 @@ private: }; template -inline bool operator==(const QScopedPointer &lhs, const QScopedPointer &rhs) Q_DECL_NOTHROW +inline bool operator==(const QScopedPointer &lhs, const QScopedPointer &rhs) noexcept { return lhs.data() == rhs.data(); } template -inline bool operator!=(const QScopedPointer &lhs, const QScopedPointer &rhs) Q_DECL_NOTHROW +inline bool operator!=(const QScopedPointer &lhs, const QScopedPointer &rhs) noexcept { return lhs.data() != rhs.data(); } template -inline bool operator==(const QScopedPointer &lhs, std::nullptr_t) Q_DECL_NOTHROW +inline bool operator==(const QScopedPointer &lhs, std::nullptr_t) noexcept { return lhs.isNull(); } template -inline bool operator==(std::nullptr_t, const QScopedPointer &rhs) Q_DECL_NOTHROW +inline bool operator==(std::nullptr_t, const QScopedPointer &rhs) noexcept { return rhs.isNull(); } template -inline bool operator!=(const QScopedPointer &lhs, std::nullptr_t) Q_DECL_NOTHROW +inline bool operator!=(const QScopedPointer &lhs, std::nullptr_t) noexcept { return !lhs.isNull(); } template -inline bool operator!=(std::nullptr_t, const QScopedPointer &rhs) Q_DECL_NOTHROW +inline bool operator!=(std::nullptr_t, const QScopedPointer &rhs) noexcept { return !rhs.isNull(); } template -inline void swap(QScopedPointer &p1, QScopedPointer &p2) Q_DECL_NOTHROW +inline void swap(QScopedPointer &p1, QScopedPointer &p2) noexcept { p1.swap(p2); } template > @@ -244,7 +244,7 @@ public: return this->d[i]; } - void swap(QScopedArrayPointer &other) Q_DECL_NOTHROW // prevent QScopedPointer <->QScopedArrayPointer swaps + void swap(QScopedArrayPointer &other) noexcept // prevent QScopedPointer <->QScopedArrayPointer swaps { QScopedPointer::swap(other); } private: @@ -263,7 +263,7 @@ private: }; template -inline void swap(QScopedArrayPointer &lhs, QScopedArrayPointer &rhs) Q_DECL_NOTHROW +inline void swap(QScopedArrayPointer &lhs, QScopedArrayPointer &rhs) noexcept { lhs.swap(rhs); } QT_END_NAMESPACE diff --git a/src/corelib/tools/qscopeguard.h b/src/corelib/tools/qscopeguard.h index 0f61996eb6..41d0a6af68 100644 --- a/src/corelib/tools/qscopeguard.h +++ b/src/corelib/tools/qscopeguard.h @@ -58,7 +58,7 @@ Q_REQUIRED_RESULT QScopeGuard { public: - QScopeGuard(QScopeGuard &&other) Q_DECL_NOEXCEPT + QScopeGuard(QScopeGuard &&other) noexcept : m_func(std::move(other.m_func)) , m_invoke(other.m_invoke) { @@ -71,13 +71,13 @@ public: m_func(); } - void dismiss() Q_DECL_NOEXCEPT + void dismiss() noexcept { m_invoke = false; } private: - explicit QScopeGuard(F f) Q_DECL_NOEXCEPT + explicit QScopeGuard(F f) noexcept : m_func(std::move(f)) { } diff --git a/src/corelib/tools/qset.h b/src/corelib/tools/qset.h index 6640c8486d..d7fbc12b99 100644 --- a/src/corelib/tools/qset.h +++ b/src/corelib/tools/qset.h @@ -56,7 +56,7 @@ class QSet typedef QHash Hash; public: - inline QSet() Q_DECL_NOTHROW {} + inline QSet() noexcept {} #ifdef Q_COMPILER_INITIALIZER_LISTS inline QSet(std::initializer_list list) { @@ -68,7 +68,7 @@ public: // compiler-generated copy/move ctor/assignment operators are fine! // compiler-generated destructor is fine! - inline void swap(QSet &other) Q_DECL_NOTHROW { q_hash.swap(other.q_hash); } + inline void swap(QSet &other) noexcept { q_hash.swap(other.q_hash); } inline bool operator==(const QSet &other) const { return q_hash == other.q_hash; } @@ -176,20 +176,20 @@ public: typedef std::reverse_iterator const_reverse_iterator; inline iterator begin() { return q_hash.begin(); } - inline const_iterator begin() const Q_DECL_NOTHROW { return q_hash.begin(); } - inline const_iterator cbegin() const Q_DECL_NOTHROW { return q_hash.begin(); } - inline const_iterator constBegin() const Q_DECL_NOTHROW { return q_hash.constBegin(); } + inline const_iterator begin() const noexcept { return q_hash.begin(); } + inline const_iterator cbegin() const noexcept { return q_hash.begin(); } + inline const_iterator constBegin() const noexcept { return q_hash.constBegin(); } inline iterator end() { return q_hash.end(); } - inline const_iterator end() const Q_DECL_NOTHROW { return q_hash.end(); } - inline const_iterator cend() const Q_DECL_NOTHROW { return q_hash.end(); } - inline const_iterator constEnd() const Q_DECL_NOTHROW { return q_hash.constEnd(); } + inline const_iterator end() const noexcept { return q_hash.end(); } + inline const_iterator cend() const noexcept { return q_hash.end(); } + inline const_iterator constEnd() const noexcept { return q_hash.constEnd(); } reverse_iterator rbegin() { return reverse_iterator(end()); } reverse_iterator rend() { return reverse_iterator(begin()); } - const_reverse_iterator rbegin() const Q_DECL_NOTHROW { return const_reverse_iterator(end()); } - const_reverse_iterator rend() const Q_DECL_NOTHROW { return const_reverse_iterator(begin()); } - const_reverse_iterator crbegin() const Q_DECL_NOTHROW { return const_reverse_iterator(end()); } - const_reverse_iterator crend() const Q_DECL_NOTHROW { return const_reverse_iterator(begin()); } + const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); } + const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); } + const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(end()); } + const_reverse_iterator crend() const noexcept { return const_reverse_iterator(begin()); } iterator erase(iterator i) { return erase(m2c(i)); } @@ -252,14 +252,14 @@ public: private: Hash q_hash; - static const_iterator m2c(iterator it) Q_DECL_NOTHROW + static const_iterator m2c(iterator it) noexcept { return const_iterator(typename Hash::const_iterator(it.i.i)); } bool isValidIterator(const iterator &i) const { return q_hash.isValidIterator(reinterpret_cast(i)); } - bool isValidIterator(const const_iterator &i) const Q_DECL_NOTHROW + bool isValidIterator(const const_iterator &i) const noexcept { return q_hash.isValidIterator(reinterpret_cast(i)); } diff --git a/src/corelib/tools/qshareddata.h b/src/corelib/tools/qshareddata.h index 6930cb96a5..cbaa1aa3c4 100644 --- a/src/corelib/tools/qshareddata.h +++ b/src/corelib/tools/qshareddata.h @@ -88,7 +88,7 @@ public: inline QSharedDataPointer() { d = nullptr; } inline ~QSharedDataPointer() { if (d && !d->ref.deref()) delete d; } - explicit QSharedDataPointer(T *data) Q_DECL_NOTHROW; + explicit QSharedDataPointer(T *data) noexcept; inline QSharedDataPointer(const QSharedDataPointer &o) : d(o.d) { if (d) d->ref.ref(); } inline QSharedDataPointer & operator=(const QSharedDataPointer &o) { if (o.d != d) { @@ -113,8 +113,8 @@ public: return *this; } #ifdef Q_COMPILER_RVALUE_REFS - QSharedDataPointer(QSharedDataPointer &&o) Q_DECL_NOTHROW : d(o.d) { o.d = nullptr; } - inline QSharedDataPointer &operator=(QSharedDataPointer &&other) Q_DECL_NOTHROW + QSharedDataPointer(QSharedDataPointer &&o) noexcept : d(o.d) { o.d = nullptr; } + inline QSharedDataPointer &operator=(QSharedDataPointer &&other) noexcept { QSharedDataPointer moved(std::move(other)); swap(moved); @@ -124,7 +124,7 @@ public: inline bool operator!() const { return !d; } - inline void swap(QSharedDataPointer &other) Q_DECL_NOTHROW + inline void swap(QSharedDataPointer &other) noexcept { qSwap(d, other.d); } protected: @@ -181,7 +181,7 @@ public: inline QExplicitlySharedDataPointer() { d = nullptr; } inline ~QExplicitlySharedDataPointer() { if (d && !d->ref.deref()) delete d; } - explicit QExplicitlySharedDataPointer(T *data) Q_DECL_NOTHROW; + explicit QExplicitlySharedDataPointer(T *data) noexcept; inline QExplicitlySharedDataPointer(const QExplicitlySharedDataPointer &o) : d(o.d) { if (d) d->ref.ref(); } template @@ -219,8 +219,8 @@ public: return *this; } #ifdef Q_COMPILER_RVALUE_REFS - inline QExplicitlySharedDataPointer(QExplicitlySharedDataPointer &&o) Q_DECL_NOTHROW : d(o.d) { o.d = nullptr; } - inline QExplicitlySharedDataPointer &operator=(QExplicitlySharedDataPointer &&other) Q_DECL_NOTHROW + inline QExplicitlySharedDataPointer(QExplicitlySharedDataPointer &&o) noexcept : d(o.d) { o.d = nullptr; } + inline QExplicitlySharedDataPointer &operator=(QExplicitlySharedDataPointer &&other) noexcept { QExplicitlySharedDataPointer moved(std::move(other)); swap(moved); @@ -230,7 +230,7 @@ public: inline bool operator!() const { return !d; } - inline void swap(QExplicitlySharedDataPointer &other) Q_DECL_NOTHROW + inline void swap(QExplicitlySharedDataPointer &other) noexcept { qSwap(d, other.d); } protected: @@ -243,7 +243,7 @@ private: }; template -Q_INLINE_TEMPLATE QSharedDataPointer::QSharedDataPointer(T *adata) Q_DECL_NOTHROW +Q_INLINE_TEMPLATE QSharedDataPointer::QSharedDataPointer(T *adata) noexcept : d(adata) { if (d) d->ref.ref(); } @@ -280,7 +280,7 @@ Q_OUTOFLINE_TEMPLATE void QExplicitlySharedDataPointer::detach_helper() } template -Q_INLINE_TEMPLATE QExplicitlySharedDataPointer::QExplicitlySharedDataPointer(T *adata) Q_DECL_NOTHROW +Q_INLINE_TEMPLATE QExplicitlySharedDataPointer::QExplicitlySharedDataPointer(T *adata) noexcept : d(adata) { if (d) d->ref.ref(); } @@ -317,12 +317,12 @@ namespace std { QT_BEGIN_NAMESPACE template -Q_INLINE_TEMPLATE uint qHash(const QSharedDataPointer &ptr, uint seed = 0) Q_DECL_NOTHROW +Q_INLINE_TEMPLATE uint qHash(const QSharedDataPointer &ptr, uint seed = 0) noexcept { return qHash(ptr.data(), seed); } template -Q_INLINE_TEMPLATE uint qHash(const QExplicitlySharedDataPointer &ptr, uint seed = 0) Q_DECL_NOTHROW +Q_INLINE_TEMPLATE uint qHash(const QExplicitlySharedDataPointer &ptr, uint seed = 0) noexcept { return qHash(ptr.data(), seed); } diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h index bccf8c5740..81d8dcd839 100644 --- a/src/corelib/tools/qsharedpointer_impl.h +++ b/src/corelib/tools/qsharedpointer_impl.h @@ -303,18 +303,18 @@ public: typedef const value_type &const_reference; typedef qptrdiff difference_type; - T *data() const Q_DECL_NOTHROW { return value; } - T *get() const Q_DECL_NOTHROW { return value; } - bool isNull() const Q_DECL_NOTHROW { return !data(); } - operator RestrictedBool() const Q_DECL_NOTHROW { return isNull() ? nullptr : &QSharedPointer::value; } - bool operator !() const Q_DECL_NOTHROW { return isNull(); } + T *data() const noexcept { return value; } + T *get() const noexcept { return value; } + bool isNull() const noexcept { return !data(); } + operator RestrictedBool() const noexcept { return isNull() ? nullptr : &QSharedPointer::value; } + bool operator !() const noexcept { return isNull(); } T &operator*() const { return *data(); } - T *operator->() const Q_DECL_NOTHROW { return data(); } + T *operator->() const noexcept { return data(); } - Q_DECL_CONSTEXPR QSharedPointer() Q_DECL_NOTHROW : value(nullptr), d(nullptr) { } + Q_DECL_CONSTEXPR QSharedPointer() noexcept : value(nullptr), d(nullptr) { } ~QSharedPointer() { deref(); } - Q_DECL_CONSTEXPR QSharedPointer(std::nullptr_t) Q_DECL_NOTHROW : value(nullptr), d(nullptr) { } + Q_DECL_CONSTEXPR QSharedPointer(std::nullptr_t) noexcept : value(nullptr), d(nullptr) { } template inline explicit QSharedPointer(X *ptr) : value(ptr) // noexcept @@ -327,22 +327,22 @@ public: template QSharedPointer(std::nullptr_t, Deleter) : value(nullptr), d(nullptr) { } - QSharedPointer(const QSharedPointer &other) Q_DECL_NOTHROW : value(other.value), d(other.d) + QSharedPointer(const QSharedPointer &other) noexcept : value(other.value), d(other.d) { if (d) ref(); } - QSharedPointer &operator=(const QSharedPointer &other) Q_DECL_NOTHROW + QSharedPointer &operator=(const QSharedPointer &other) noexcept { QSharedPointer copy(other); swap(copy); return *this; } #ifdef Q_COMPILER_RVALUE_REFS - QSharedPointer(QSharedPointer &&other) Q_DECL_NOTHROW + QSharedPointer(QSharedPointer &&other) noexcept : value(other.value), d(other.d) { other.d = nullptr; other.value = nullptr; } - QSharedPointer &operator=(QSharedPointer &&other) Q_DECL_NOTHROW + QSharedPointer &operator=(QSharedPointer &&other) noexcept { QSharedPointer moved(std::move(other)); swap(moved); @@ -350,7 +350,7 @@ public: } template - QSharedPointer(QSharedPointer &&other) Q_DECL_NOTHROW + QSharedPointer(QSharedPointer &&other) noexcept : value(other.value), d(other.d) { other.d = nullptr; @@ -358,7 +358,7 @@ public: } template - QSharedPointer &operator=(QSharedPointer &&other) Q_DECL_NOTHROW + QSharedPointer &operator=(QSharedPointer &&other) noexcept { QSharedPointer moved(std::move(other)); swap(moved); @@ -368,7 +368,7 @@ public: #endif template - QSharedPointer(const QSharedPointer &other) Q_DECL_NOTHROW : value(other.value), d(other.d) + QSharedPointer(const QSharedPointer &other) noexcept : value(other.value), d(other.d) { if (d) ref(); } template @@ -456,9 +456,9 @@ public: private: explicit QSharedPointer(Qt::Initialization) {} - void deref() Q_DECL_NOTHROW + void deref() noexcept { deref(d); } - static void deref(Data *dd) Q_DECL_NOTHROW + static void deref(Data *dd) noexcept { if (!dd) return; if (!dd->strongref.deref()) { @@ -499,7 +499,7 @@ private: enableSharedFromThis(ptr); } - void internalSwap(QSharedPointer &other) Q_DECL_NOTHROW + void internalSwap(QSharedPointer &other) noexcept { qSwap(d, other.d); qSwap(this->value, other.value); @@ -512,7 +512,7 @@ public: template friend class QWeakPointer; template friend QSharedPointer QtSharedPointer::copyAndSetPointer(X * ptr, const QSharedPointer &src); #endif - void ref() const Q_DECL_NOTHROW { d->weakref.ref(); d->strongref.ref(); } + void ref() const noexcept { d->weakref.ref(); d->strongref.ref(); } inline void internalSet(Data *o, T *actual) { @@ -563,12 +563,12 @@ public: typedef const value_type &const_reference; typedef qptrdiff difference_type; - bool isNull() const Q_DECL_NOTHROW { return d == nullptr || d->strongref.load() == 0 || value == nullptr; } - operator RestrictedBool() const Q_DECL_NOTHROW { return isNull() ? nullptr : &QWeakPointer::value; } - bool operator !() const Q_DECL_NOTHROW { return isNull(); } - T *data() const Q_DECL_NOTHROW { return d == nullptr || d->strongref.load() == 0 ? nullptr : value; } + bool isNull() const noexcept { return d == nullptr || d->strongref.load() == 0 || value == nullptr; } + operator RestrictedBool() const noexcept { return isNull() ? nullptr : &QWeakPointer::value; } + bool operator !() const noexcept { return isNull(); } + T *data() const noexcept { return d == nullptr || d->strongref.load() == 0 ? nullptr : value; } - inline QWeakPointer() Q_DECL_NOTHROW : d(nullptr), value(nullptr) { } + inline QWeakPointer() noexcept : d(nullptr), value(nullptr) { } inline ~QWeakPointer() { if (d && !d->weakref.deref()) delete d; } #ifndef QT_NO_QOBJECT @@ -586,26 +586,26 @@ public: { return *this = QWeakPointer(ptr); } #endif - QWeakPointer(const QWeakPointer &other) Q_DECL_NOTHROW : d(other.d), value(other.value) + QWeakPointer(const QWeakPointer &other) noexcept : d(other.d), value(other.value) { if (d) d->weakref.ref(); } #ifdef Q_COMPILER_RVALUE_REFS - QWeakPointer(QWeakPointer &&other) Q_DECL_NOTHROW + QWeakPointer(QWeakPointer &&other) noexcept : d(other.d), value(other.value) { other.d = nullptr; other.value = nullptr; } - QWeakPointer &operator=(QWeakPointer &&other) Q_DECL_NOTHROW + QWeakPointer &operator=(QWeakPointer &&other) noexcept { QWeakPointer moved(std::move(other)); swap(moved); return *this; } #endif - QWeakPointer &operator=(const QWeakPointer &other) Q_DECL_NOTHROW + QWeakPointer &operator=(const QWeakPointer &other) noexcept { QWeakPointer copy(other); swap(copy); return *this; } - void swap(QWeakPointer &other) Q_DECL_NOTHROW + void swap(QWeakPointer &other) noexcept { qSwap(this->d, other.d); qSwap(this->value, other.value); @@ -633,11 +633,11 @@ public: } template - bool operator==(const QWeakPointer &o) const Q_DECL_NOTHROW + bool operator==(const QWeakPointer &o) const noexcept { return d == o.d && value == static_cast(o.value); } template - bool operator!=(const QWeakPointer &o) const Q_DECL_NOTHROW + bool operator!=(const QWeakPointer &o) const noexcept { return !(*this == o); } template @@ -653,11 +653,11 @@ public: } template - bool operator==(const QSharedPointer &o) const Q_DECL_NOTHROW + bool operator==(const QSharedPointer &o) const noexcept { return d == o.d; } template - bool operator!=(const QSharedPointer &o) const Q_DECL_NOTHROW + bool operator!=(const QSharedPointer &o) const noexcept { return !(*this == o); } inline void clear() { *this = QWeakPointer(); } @@ -739,92 +739,92 @@ public: // operator== and operator!= // template -bool operator==(const QSharedPointer &ptr1, const QSharedPointer &ptr2) Q_DECL_NOTHROW +bool operator==(const QSharedPointer &ptr1, const QSharedPointer &ptr2) noexcept { return ptr1.data() == ptr2.data(); } template -bool operator!=(const QSharedPointer &ptr1, const QSharedPointer &ptr2) Q_DECL_NOTHROW +bool operator!=(const QSharedPointer &ptr1, const QSharedPointer &ptr2) noexcept { return ptr1.data() != ptr2.data(); } template -bool operator==(const QSharedPointer &ptr1, const X *ptr2) Q_DECL_NOTHROW +bool operator==(const QSharedPointer &ptr1, const X *ptr2) noexcept { return ptr1.data() == ptr2; } template -bool operator==(const T *ptr1, const QSharedPointer &ptr2) Q_DECL_NOTHROW +bool operator==(const T *ptr1, const QSharedPointer &ptr2) noexcept { return ptr1 == ptr2.data(); } template -bool operator!=(const QSharedPointer &ptr1, const X *ptr2) Q_DECL_NOTHROW +bool operator!=(const QSharedPointer &ptr1, const X *ptr2) noexcept { return !(ptr1 == ptr2); } template -bool operator!=(const T *ptr1, const QSharedPointer &ptr2) Q_DECL_NOTHROW +bool operator!=(const T *ptr1, const QSharedPointer &ptr2) noexcept { return !(ptr2 == ptr1); } template -bool operator==(const QSharedPointer &ptr1, const QWeakPointer &ptr2) Q_DECL_NOTHROW +bool operator==(const QSharedPointer &ptr1, const QWeakPointer &ptr2) noexcept { return ptr2 == ptr1; } template -bool operator!=(const QSharedPointer &ptr1, const QWeakPointer &ptr2) Q_DECL_NOTHROW +bool operator!=(const QSharedPointer &ptr1, const QWeakPointer &ptr2) noexcept { return ptr2 != ptr1; } template -inline bool operator==(const QSharedPointer &lhs, std::nullptr_t) Q_DECL_NOTHROW +inline bool operator==(const QSharedPointer &lhs, std::nullptr_t) noexcept { return lhs.isNull(); } template -inline bool operator!=(const QSharedPointer &lhs, std::nullptr_t) Q_DECL_NOTHROW +inline bool operator!=(const QSharedPointer &lhs, std::nullptr_t) noexcept { return !lhs.isNull(); } template -inline bool operator==(std::nullptr_t, const QSharedPointer &rhs) Q_DECL_NOTHROW +inline bool operator==(std::nullptr_t, const QSharedPointer &rhs) noexcept { return rhs.isNull(); } template -inline bool operator!=(std::nullptr_t, const QSharedPointer &rhs) Q_DECL_NOTHROW +inline bool operator!=(std::nullptr_t, const QSharedPointer &rhs) noexcept { return !rhs.isNull(); } template -inline bool operator==(const QWeakPointer &lhs, std::nullptr_t) Q_DECL_NOTHROW +inline bool operator==(const QWeakPointer &lhs, std::nullptr_t) noexcept { return lhs.isNull(); } template -inline bool operator!=(const QWeakPointer &lhs, std::nullptr_t) Q_DECL_NOTHROW +inline bool operator!=(const QWeakPointer &lhs, std::nullptr_t) noexcept { return !lhs.isNull(); } template -inline bool operator==(std::nullptr_t, const QWeakPointer &rhs) Q_DECL_NOTHROW +inline bool operator==(std::nullptr_t, const QWeakPointer &rhs) noexcept { return rhs.isNull(); } template -inline bool operator!=(std::nullptr_t, const QWeakPointer &rhs) Q_DECL_NOTHROW +inline bool operator!=(std::nullptr_t, const QWeakPointer &rhs) noexcept { return !rhs.isNull(); } diff --git a/src/corelib/tools/qsize.cpp b/src/corelib/tools/qsize.cpp index 3e97947ad2..fe508ad459 100644 --- a/src/corelib/tools/qsize.cpp +++ b/src/corelib/tools/qsize.cpp @@ -163,7 +163,7 @@ QT_BEGIN_NAMESPACE \sa setWidth(), setHeight(), transposed() */ -void QSize::transpose() Q_DECL_NOTHROW +void QSize::transpose() noexcept { qSwap(wd, ht); } @@ -222,7 +222,7 @@ void QSize::transpose() Q_DECL_NOTHROW Return a size scaled to a rectangle with the given size \a s, according to the specified \a mode. */ -QSize QSize::scaled(const QSize &s, Qt::AspectRatioMode mode) const Q_DECL_NOTHROW +QSize QSize::scaled(const QSize &s, Qt::AspectRatioMode mode) const noexcept { if (mode == Qt::IgnoreAspectRatio || wd == 0 || ht == 0) { return s; @@ -594,7 +594,7 @@ QDebug operator<<(QDebug dbg, const QSize &s) \sa setWidth(), setHeight(), transposed() */ -void QSizeF::transpose() Q_DECL_NOTHROW +void QSizeF::transpose() noexcept { qSwap(wd, ht); } @@ -653,7 +653,7 @@ void QSizeF::transpose() Q_DECL_NOTHROW Returns a size scaled to a rectangle with the given size \a s, according to the specified \a mode. */ -QSizeF QSizeF::scaled(const QSizeF &s, Qt::AspectRatioMode mode) const Q_DECL_NOTHROW +QSizeF QSizeF::scaled(const QSizeF &s, Qt::AspectRatioMode mode) const noexcept { if (mode == Qt::IgnoreAspectRatio || qIsNull(wd) || qIsNull(ht)) { return s; diff --git a/src/corelib/tools/qsize.h b/src/corelib/tools/qsize.h index bb29dca7c4..4114609856 100644 --- a/src/corelib/tools/qsize.h +++ b/src/corelib/tools/qsize.h @@ -52,46 +52,46 @@ QT_BEGIN_NAMESPACE class Q_CORE_EXPORT QSize { public: - Q_DECL_CONSTEXPR QSize() Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR QSize(int w, int h) Q_DECL_NOTHROW; + Q_DECL_CONSTEXPR QSize() noexcept; + Q_DECL_CONSTEXPR QSize(int w, int h) noexcept; - Q_DECL_CONSTEXPR inline bool isNull() const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline bool isEmpty() const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline bool isValid() const Q_DECL_NOTHROW; + Q_DECL_CONSTEXPR inline bool isNull() const noexcept; + Q_DECL_CONSTEXPR inline bool isEmpty() const noexcept; + Q_DECL_CONSTEXPR inline bool isValid() const noexcept; - Q_DECL_CONSTEXPR inline int width() const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline int height() const Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void setWidth(int w) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void setHeight(int h) Q_DECL_NOTHROW; - void transpose() Q_DECL_NOTHROW; - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QSize transposed() const Q_DECL_NOTHROW; + Q_DECL_CONSTEXPR inline int width() const noexcept; + Q_DECL_CONSTEXPR inline int height() const noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void setWidth(int w) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void setHeight(int h) noexcept; + void transpose() noexcept; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QSize transposed() const noexcept; - inline void scale(int w, int h, Qt::AspectRatioMode mode) Q_DECL_NOTHROW; - inline void scale(const QSize &s, Qt::AspectRatioMode mode) Q_DECL_NOTHROW; - Q_REQUIRED_RESULT QSize scaled(int w, int h, Qt::AspectRatioMode mode) const Q_DECL_NOTHROW; - Q_REQUIRED_RESULT QSize scaled(const QSize &s, Qt::AspectRatioMode mode) const Q_DECL_NOTHROW; + 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; - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QSize expandedTo(const QSize &) const Q_DECL_NOTHROW; - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QSize boundedTo(const QSize &) const Q_DECL_NOTHROW; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QSize expandedTo(const QSize &) const noexcept; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QSize boundedTo(const QSize &) const noexcept; - Q_DECL_RELAXED_CONSTEXPR inline int &rwidth() Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline int &rheight() Q_DECL_NOTHROW; + Q_DECL_RELAXED_CONSTEXPR inline int &rwidth() noexcept; + Q_DECL_RELAXED_CONSTEXPR inline int &rheight() noexcept; - Q_DECL_RELAXED_CONSTEXPR inline QSize &operator+=(const QSize &) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline QSize &operator-=(const QSize &) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline QSize &operator*=(qreal c) Q_DECL_NOTHROW; + Q_DECL_RELAXED_CONSTEXPR inline QSize &operator+=(const QSize &) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline QSize &operator-=(const QSize &) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline QSize &operator*=(qreal c) noexcept; inline QSize &operator/=(qreal c); - friend inline Q_DECL_CONSTEXPR bool operator==(const QSize &, const QSize &) Q_DECL_NOTHROW; - friend inline Q_DECL_CONSTEXPR bool operator!=(const QSize &, const QSize &) Q_DECL_NOTHROW; - friend inline Q_DECL_CONSTEXPR const QSize operator+(const QSize &, const QSize &) Q_DECL_NOTHROW; - friend inline Q_DECL_CONSTEXPR const QSize operator-(const QSize &, const QSize &) Q_DECL_NOTHROW; - friend inline Q_DECL_CONSTEXPR const QSize operator*(const QSize &, qreal) Q_DECL_NOTHROW; - friend inline Q_DECL_CONSTEXPR const QSize operator*(qreal, const QSize &) Q_DECL_NOTHROW; + friend inline Q_DECL_CONSTEXPR bool operator==(const QSize &, const QSize &) noexcept; + friend inline Q_DECL_CONSTEXPR bool operator!=(const QSize &, const QSize &) noexcept; + friend inline Q_DECL_CONSTEXPR const QSize operator+(const QSize &, const QSize &) noexcept; + friend inline Q_DECL_CONSTEXPR const QSize operator-(const QSize &, const QSize &) noexcept; + friend inline Q_DECL_CONSTEXPR const QSize operator*(const QSize &, qreal) noexcept; + friend inline Q_DECL_CONSTEXPR const QSize operator*(qreal, const QSize &) noexcept; friend inline const QSize operator/(const QSize &, qreal); #if defined(Q_OS_DARWIN) || defined(Q_QDOC) - Q_REQUIRED_RESULT CGSize toCGSize() const Q_DECL_NOTHROW; + Q_REQUIRED_RESULT CGSize toCGSize() const noexcept; #endif private: @@ -114,74 +114,74 @@ Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QSize &); QSize inline functions *****************************************************************************/ -Q_DECL_CONSTEXPR inline QSize::QSize() Q_DECL_NOTHROW : wd(-1), ht(-1) {} +Q_DECL_CONSTEXPR inline QSize::QSize() noexcept : wd(-1), ht(-1) {} -Q_DECL_CONSTEXPR inline QSize::QSize(int w, int h) Q_DECL_NOTHROW : wd(w), ht(h) {} +Q_DECL_CONSTEXPR inline QSize::QSize(int w, int h) noexcept : wd(w), ht(h) {} -Q_DECL_CONSTEXPR inline bool QSize::isNull() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline bool QSize::isNull() const noexcept { return wd==0 && ht==0; } -Q_DECL_CONSTEXPR inline bool QSize::isEmpty() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline bool QSize::isEmpty() const noexcept { return wd<1 || ht<1; } -Q_DECL_CONSTEXPR inline bool QSize::isValid() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline bool QSize::isValid() const noexcept { return wd>=0 && ht>=0; } -Q_DECL_CONSTEXPR inline int QSize::width() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline int QSize::width() const noexcept { return wd; } -Q_DECL_CONSTEXPR inline int QSize::height() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline int QSize::height() const noexcept { return ht; } -Q_DECL_RELAXED_CONSTEXPR inline void QSize::setWidth(int w) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QSize::setWidth(int w) noexcept { wd = w; } -Q_DECL_RELAXED_CONSTEXPR inline void QSize::setHeight(int h) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QSize::setHeight(int h) noexcept { ht = h; } -Q_DECL_CONSTEXPR inline QSize QSize::transposed() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QSize QSize::transposed() const noexcept { return QSize(ht, wd); } -inline void QSize::scale(int w, int h, Qt::AspectRatioMode mode) Q_DECL_NOTHROW +inline void QSize::scale(int w, int h, Qt::AspectRatioMode mode) noexcept { scale(QSize(w, h), mode); } -inline void QSize::scale(const QSize &s, Qt::AspectRatioMode mode) Q_DECL_NOTHROW +inline void QSize::scale(const QSize &s, Qt::AspectRatioMode mode) noexcept { *this = scaled(s, mode); } -inline QSize QSize::scaled(int w, int h, Qt::AspectRatioMode mode) const Q_DECL_NOTHROW +inline QSize QSize::scaled(int w, int h, Qt::AspectRatioMode mode) const noexcept { return scaled(QSize(w, h), mode); } -Q_DECL_RELAXED_CONSTEXPR inline int &QSize::rwidth() Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline int &QSize::rwidth() noexcept { return wd; } -Q_DECL_RELAXED_CONSTEXPR inline int &QSize::rheight() Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline int &QSize::rheight() noexcept { return ht; } -Q_DECL_RELAXED_CONSTEXPR inline QSize &QSize::operator+=(const QSize &s) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline QSize &QSize::operator+=(const QSize &s) noexcept { wd+=s.wd; ht+=s.ht; return *this; } -Q_DECL_RELAXED_CONSTEXPR inline QSize &QSize::operator-=(const QSize &s) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline QSize &QSize::operator-=(const QSize &s) noexcept { wd-=s.wd; ht-=s.ht; return *this; } -Q_DECL_RELAXED_CONSTEXPR inline QSize &QSize::operator*=(qreal c) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline QSize &QSize::operator*=(qreal c) noexcept { wd = qRound(wd*c); ht = qRound(ht*c); return *this; } -Q_DECL_CONSTEXPR inline bool operator==(const QSize &s1, const QSize &s2) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline bool operator==(const QSize &s1, const QSize &s2) noexcept { return s1.wd == s2.wd && s1.ht == s2.ht; } -Q_DECL_CONSTEXPR inline bool operator!=(const QSize &s1, const QSize &s2) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline bool operator!=(const QSize &s1, const QSize &s2) noexcept { return s1.wd != s2.wd || s1.ht != s2.ht; } -Q_DECL_CONSTEXPR inline const QSize operator+(const QSize & s1, const QSize & s2) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline const QSize operator+(const QSize & s1, const QSize & s2) noexcept { return QSize(s1.wd+s2.wd, s1.ht+s2.ht); } -Q_DECL_CONSTEXPR inline const QSize operator-(const QSize &s1, const QSize &s2) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline const QSize operator-(const QSize &s1, const QSize &s2) noexcept { return QSize(s1.wd-s2.wd, s1.ht-s2.ht); } -Q_DECL_CONSTEXPR inline const QSize operator*(const QSize &s, qreal c) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline const QSize operator*(const QSize &s, qreal c) noexcept { return QSize(qRound(s.wd*c), qRound(s.ht*c)); } -Q_DECL_CONSTEXPR inline const QSize operator*(qreal c, const QSize &s) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline const QSize operator*(qreal c, const QSize &s) noexcept { return QSize(qRound(s.wd*c), qRound(s.ht*c)); } inline QSize &QSize::operator/=(qreal c) @@ -197,12 +197,12 @@ inline const QSize operator/(const QSize &s, qreal c) return QSize(qRound(s.wd/c), qRound(s.ht/c)); } -Q_DECL_CONSTEXPR inline QSize QSize::expandedTo(const QSize & otherSize) const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QSize QSize::expandedTo(const QSize & otherSize) const noexcept { return QSize(qMax(wd,otherSize.wd), qMax(ht,otherSize.ht)); } -Q_DECL_CONSTEXPR inline QSize QSize::boundedTo(const QSize & otherSize) const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QSize QSize::boundedTo(const QSize & otherSize) const noexcept { return QSize(qMin(wd,otherSize.wd), qMin(ht,otherSize.ht)); } @@ -215,50 +215,50 @@ Q_CORE_EXPORT QDebug operator<<(QDebug, const QSize &); class Q_CORE_EXPORT QSizeF { public: - Q_DECL_CONSTEXPR QSizeF() Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR QSizeF(const QSize &sz) Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR QSizeF(qreal w, qreal h) Q_DECL_NOTHROW; + Q_DECL_CONSTEXPR QSizeF() noexcept; + Q_DECL_CONSTEXPR QSizeF(const QSize &sz) noexcept; + Q_DECL_CONSTEXPR QSizeF(qreal w, qreal h) noexcept; - inline bool isNull() const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline bool isEmpty() const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline bool isValid() const Q_DECL_NOTHROW; + inline bool isNull() const noexcept; + Q_DECL_CONSTEXPR inline bool isEmpty() const noexcept; + Q_DECL_CONSTEXPR inline bool isValid() const noexcept; - Q_DECL_CONSTEXPR inline qreal width() const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline qreal height() const Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void setWidth(qreal w) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void setHeight(qreal h) Q_DECL_NOTHROW; - void transpose() Q_DECL_NOTHROW; - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QSizeF transposed() const Q_DECL_NOTHROW; + Q_DECL_CONSTEXPR inline qreal width() const noexcept; + Q_DECL_CONSTEXPR inline qreal height() const noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void setWidth(qreal w) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void setHeight(qreal h) noexcept; + void transpose() noexcept; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QSizeF transposed() const noexcept; - inline void scale(qreal w, qreal h, Qt::AspectRatioMode mode) Q_DECL_NOTHROW; - inline void scale(const QSizeF &s, Qt::AspectRatioMode mode) Q_DECL_NOTHROW; - Q_REQUIRED_RESULT QSizeF scaled(qreal w, qreal h, Qt::AspectRatioMode mode) const Q_DECL_NOTHROW; - Q_REQUIRED_RESULT QSizeF scaled(const QSizeF &s, Qt::AspectRatioMode mode) const Q_DECL_NOTHROW; + 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; - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QSizeF expandedTo(const QSizeF &) const Q_DECL_NOTHROW; - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QSizeF boundedTo(const QSizeF &) const Q_DECL_NOTHROW; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QSizeF expandedTo(const QSizeF &) const noexcept; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QSizeF boundedTo(const QSizeF &) const noexcept; - Q_DECL_RELAXED_CONSTEXPR inline qreal &rwidth() Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline qreal &rheight() Q_DECL_NOTHROW; + Q_DECL_RELAXED_CONSTEXPR inline qreal &rwidth() noexcept; + Q_DECL_RELAXED_CONSTEXPR inline qreal &rheight() noexcept; - Q_DECL_RELAXED_CONSTEXPR inline QSizeF &operator+=(const QSizeF &) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline QSizeF &operator-=(const QSizeF &) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline QSizeF &operator*=(qreal c) Q_DECL_NOTHROW; + Q_DECL_RELAXED_CONSTEXPR inline QSizeF &operator+=(const QSizeF &) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline QSizeF &operator-=(const QSizeF &) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline QSizeF &operator*=(qreal c) noexcept; inline QSizeF &operator/=(qreal c); - friend Q_DECL_CONSTEXPR inline bool operator==(const QSizeF &, const QSizeF &) Q_DECL_NOTHROW; - friend Q_DECL_CONSTEXPR inline bool operator!=(const QSizeF &, const QSizeF &) Q_DECL_NOTHROW; - friend Q_DECL_CONSTEXPR inline const QSizeF operator+(const QSizeF &, const QSizeF &) Q_DECL_NOTHROW; - friend Q_DECL_CONSTEXPR inline const QSizeF operator-(const QSizeF &, const QSizeF &) Q_DECL_NOTHROW; - friend Q_DECL_CONSTEXPR inline const QSizeF operator*(const QSizeF &, qreal) Q_DECL_NOTHROW; - friend Q_DECL_CONSTEXPR inline const QSizeF operator*(qreal, const QSizeF &) Q_DECL_NOTHROW; + friend Q_DECL_CONSTEXPR inline bool operator==(const QSizeF &, const QSizeF &) noexcept; + friend Q_DECL_CONSTEXPR inline bool operator!=(const QSizeF &, const QSizeF &) noexcept; + friend Q_DECL_CONSTEXPR inline const QSizeF operator+(const QSizeF &, const QSizeF &) noexcept; + friend Q_DECL_CONSTEXPR inline const QSizeF operator-(const QSizeF &, const QSizeF &) noexcept; + friend Q_DECL_CONSTEXPR inline const QSizeF operator*(const QSizeF &, qreal) noexcept; + friend Q_DECL_CONSTEXPR inline const QSizeF operator*(qreal, const QSizeF &) noexcept; friend inline const QSizeF operator/(const QSizeF &, qreal); - Q_DECL_CONSTEXPR inline QSize toSize() const Q_DECL_NOTHROW; + Q_DECL_CONSTEXPR inline QSize toSize() const noexcept; #if defined(Q_OS_DARWIN) || defined(Q_QDOC) - Q_REQUIRED_RESULT static QSizeF fromCGSize(CGSize size) Q_DECL_NOTHROW; - Q_REQUIRED_RESULT CGSize toCGSize() const Q_DECL_NOTHROW; + Q_REQUIRED_RESULT static QSizeF fromCGSize(CGSize size) noexcept; + Q_REQUIRED_RESULT CGSize toCGSize() const noexcept; #endif private: @@ -282,76 +282,76 @@ Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QSizeF &); QSizeF inline functions *****************************************************************************/ -Q_DECL_CONSTEXPR inline QSizeF::QSizeF() Q_DECL_NOTHROW : wd(-1.), ht(-1.) {} +Q_DECL_CONSTEXPR inline QSizeF::QSizeF() noexcept : wd(-1.), ht(-1.) {} -Q_DECL_CONSTEXPR inline QSizeF::QSizeF(const QSize &sz) Q_DECL_NOTHROW : wd(sz.width()), ht(sz.height()) {} +Q_DECL_CONSTEXPR inline QSizeF::QSizeF(const QSize &sz) noexcept : wd(sz.width()), ht(sz.height()) {} -Q_DECL_CONSTEXPR inline QSizeF::QSizeF(qreal w, qreal h) Q_DECL_NOTHROW : wd(w), ht(h) {} +Q_DECL_CONSTEXPR inline QSizeF::QSizeF(qreal w, qreal h) noexcept : wd(w), ht(h) {} -inline bool QSizeF::isNull() const Q_DECL_NOTHROW +inline bool QSizeF::isNull() const noexcept { return qIsNull(wd) && qIsNull(ht); } -Q_DECL_CONSTEXPR inline bool QSizeF::isEmpty() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline bool QSizeF::isEmpty() const noexcept { return wd <= 0. || ht <= 0.; } -Q_DECL_CONSTEXPR inline bool QSizeF::isValid() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline bool QSizeF::isValid() const noexcept { return wd >= 0. && ht >= 0.; } -Q_DECL_CONSTEXPR inline qreal QSizeF::width() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline qreal QSizeF::width() const noexcept { return wd; } -Q_DECL_CONSTEXPR inline qreal QSizeF::height() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline qreal QSizeF::height() const noexcept { return ht; } -Q_DECL_RELAXED_CONSTEXPR inline void QSizeF::setWidth(qreal w) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QSizeF::setWidth(qreal w) noexcept { wd = w; } -Q_DECL_RELAXED_CONSTEXPR inline void QSizeF::setHeight(qreal h) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QSizeF::setHeight(qreal h) noexcept { ht = h; } -Q_DECL_CONSTEXPR inline QSizeF QSizeF::transposed() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QSizeF QSizeF::transposed() const noexcept { return QSizeF(ht, wd); } -inline void QSizeF::scale(qreal w, qreal h, Qt::AspectRatioMode mode) Q_DECL_NOTHROW +inline void QSizeF::scale(qreal w, qreal h, Qt::AspectRatioMode mode) noexcept { scale(QSizeF(w, h), mode); } -inline void QSizeF::scale(const QSizeF &s, Qt::AspectRatioMode mode) Q_DECL_NOTHROW +inline void QSizeF::scale(const QSizeF &s, Qt::AspectRatioMode mode) noexcept { *this = scaled(s, mode); } -inline QSizeF QSizeF::scaled(qreal w, qreal h, Qt::AspectRatioMode mode) const Q_DECL_NOTHROW +inline QSizeF QSizeF::scaled(qreal w, qreal h, Qt::AspectRatioMode mode) const noexcept { return scaled(QSizeF(w, h), mode); } -Q_DECL_RELAXED_CONSTEXPR inline qreal &QSizeF::rwidth() Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline qreal &QSizeF::rwidth() noexcept { return wd; } -Q_DECL_RELAXED_CONSTEXPR inline qreal &QSizeF::rheight() Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline qreal &QSizeF::rheight() noexcept { return ht; } -Q_DECL_RELAXED_CONSTEXPR inline QSizeF &QSizeF::operator+=(const QSizeF &s) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline QSizeF &QSizeF::operator+=(const QSizeF &s) noexcept { wd += s.wd; ht += s.ht; return *this; } -Q_DECL_RELAXED_CONSTEXPR inline QSizeF &QSizeF::operator-=(const QSizeF &s) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline QSizeF &QSizeF::operator-=(const QSizeF &s) noexcept { wd -= s.wd; ht -= s.ht; return *this; } -Q_DECL_RELAXED_CONSTEXPR inline QSizeF &QSizeF::operator*=(qreal c) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline QSizeF &QSizeF::operator*=(qreal c) noexcept { wd *= c; ht *= c; return *this; } -Q_DECL_CONSTEXPR inline bool operator==(const QSizeF &s1, const QSizeF &s2) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline bool operator==(const QSizeF &s1, const QSizeF &s2) noexcept { return qFuzzyCompare(s1.wd, s2.wd) && qFuzzyCompare(s1.ht, s2.ht); } -Q_DECL_CONSTEXPR inline bool operator!=(const QSizeF &s1, const QSizeF &s2) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline bool operator!=(const QSizeF &s1, const QSizeF &s2) noexcept { return !qFuzzyCompare(s1.wd, s2.wd) || !qFuzzyCompare(s1.ht, s2.ht); } -Q_DECL_CONSTEXPR inline const QSizeF operator+(const QSizeF & s1, const QSizeF & s2) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline const QSizeF operator+(const QSizeF & s1, const QSizeF & s2) noexcept { return QSizeF(s1.wd+s2.wd, s1.ht+s2.ht); } -Q_DECL_CONSTEXPR inline const QSizeF operator-(const QSizeF &s1, const QSizeF &s2) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline const QSizeF operator-(const QSizeF &s1, const QSizeF &s2) noexcept { return QSizeF(s1.wd-s2.wd, s1.ht-s2.ht); } -Q_DECL_CONSTEXPR inline const QSizeF operator*(const QSizeF &s, qreal c) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline const QSizeF operator*(const QSizeF &s, qreal c) noexcept { return QSizeF(s.wd*c, s.ht*c); } -Q_DECL_CONSTEXPR inline const QSizeF operator*(qreal c, const QSizeF &s) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline const QSizeF operator*(qreal c, const QSizeF &s) noexcept { return QSizeF(s.wd*c, s.ht*c); } inline QSizeF &QSizeF::operator/=(qreal c) @@ -367,17 +367,17 @@ inline const QSizeF operator/(const QSizeF &s, qreal c) return QSizeF(s.wd/c, s.ht/c); } -Q_DECL_CONSTEXPR inline QSizeF QSizeF::expandedTo(const QSizeF & otherSize) const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QSizeF QSizeF::expandedTo(const QSizeF & otherSize) const noexcept { return QSizeF(qMax(wd,otherSize.wd), qMax(ht,otherSize.ht)); } -Q_DECL_CONSTEXPR inline QSizeF QSizeF::boundedTo(const QSizeF & otherSize) const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QSizeF QSizeF::boundedTo(const QSizeF & otherSize) const noexcept { return QSizeF(qMin(wd,otherSize.wd), qMin(ht,otherSize.ht)); } -Q_DECL_CONSTEXPR inline QSize QSizeF::toSize() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QSize QSizeF::toSize() const noexcept { return QSize(qRound(wd), qRound(ht)); } diff --git a/src/corelib/tools/qstack.h b/src/corelib/tools/qstack.h index bf04935b50..e59212aa2a 100644 --- a/src/corelib/tools/qstack.h +++ b/src/corelib/tools/qstack.h @@ -50,7 +50,7 @@ class QStack : public QVector { public: // compiler-generated special member functions are fine! - inline void swap(QStack &other) Q_DECL_NOTHROW { QVector::swap(other); } // prevent QVector<->QStack swaps + inline void swap(QStack &other) noexcept { QVector::swap(other); } // prevent QVector<->QStack swaps inline void push(const T &t) { QVector::append(t); } T pop(); T &top(); diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 65519d1f98..74debd8cfa 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -155,7 +155,7 @@ static inline bool qt_ends_with(QStringView haystack, QStringView needle, Qt::Ca static inline bool qt_ends_with(QStringView haystack, QLatin1String needle, Qt::CaseSensitivity cs); static inline bool qt_ends_with(QStringView haystack, QChar needle, Qt::CaseSensitivity cs); -qsizetype QtPrivate::qustrlen(const ushort *str) Q_DECL_NOTHROW +qsizetype QtPrivate::qustrlen(const ushort *str) noexcept { qsizetype result = 0; @@ -453,7 +453,7 @@ static Q_ALWAYS_INLINE __m128i mm_load8_zero_extend(const void *ptr) // Note: ptr on output may be off by one and point to a preceding US-ASCII // character. Usually harmless. -bool qt_is_ascii(const char *&ptr, const char *end) Q_DECL_NOTHROW +bool qt_is_ascii(const char *&ptr, const char *end) noexcept { #if defined(__SSE2__) // Testing for the high bit can be done efficiently with just PMOVMSKB @@ -509,7 +509,7 @@ bool qt_is_ascii(const char *&ptr, const char *end) Q_DECL_NOTHROW return true; } -bool QtPrivate::isAscii(QLatin1String s) Q_DECL_NOTHROW +bool QtPrivate::isAscii(QLatin1String s) noexcept { const char *ptr = s.begin(); const char *end = s.end(); @@ -536,7 +536,7 @@ static bool isAscii(const QChar *&ptr, const QChar *end) return true; } -bool QtPrivate::isAscii(QStringView s) Q_DECL_NOTHROW +bool QtPrivate::isAscii(QStringView s) noexcept { const QChar *ptr = s.begin(); const QChar *end = s.end(); @@ -544,7 +544,7 @@ bool QtPrivate::isAscii(QStringView s) Q_DECL_NOTHROW return isAscii(ptr, end); } -bool QtPrivate::isLatin1(QStringView s) Q_DECL_NOTHROW +bool QtPrivate::isLatin1(QStringView s) noexcept { const QChar *ptr = s.begin(); const QChar *end = s.end(); @@ -584,7 +584,7 @@ bool QtPrivate::isLatin1(QStringView s) Q_DECL_NOTHROW } // conversion between Latin 1 and UTF-16 -void qt_from_latin1(ushort *dst, const char *str, size_t size) Q_DECL_NOTHROW +void qt_from_latin1(ushort *dst, const char *str, size_t size) noexcept { /* SIMD: * Unpacking with SSE has been shown to improve performance on recent CPUs @@ -1141,7 +1141,7 @@ static int ucstrncmp(const QChar *a, const uchar *c, size_t l) } template -Q_DECL_CONSTEXPR int lencmp(Number lhs, Number rhs) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR int lencmp(Number lhs, Number rhs) noexcept { return lhs == rhs ? 0 : lhs > rhs ? 1 : @@ -1165,7 +1165,7 @@ static int ucstrcmp(const QChar *a, size_t alen, const char *b, size_t blen) return cmp ? cmp : lencmp(alen, blen); } -static int qt_compare_strings(QStringView lhs, QStringView rhs, Qt::CaseSensitivity cs) Q_DECL_NOTHROW +static int qt_compare_strings(QStringView lhs, QStringView rhs, Qt::CaseSensitivity cs) noexcept { if (cs == Qt::CaseSensitive) return ucstrcmp(lhs.begin(), lhs.size(), rhs.begin(), rhs.size()); @@ -1173,7 +1173,7 @@ static int qt_compare_strings(QStringView lhs, QStringView rhs, Qt::CaseSensitiv return ucstricmp(lhs.begin(), lhs.end(), rhs.begin(), rhs.end()); } -static int qt_compare_strings(QStringView lhs, QLatin1String rhs, Qt::CaseSensitivity cs) Q_DECL_NOTHROW +static int qt_compare_strings(QStringView lhs, QLatin1String rhs, Qt::CaseSensitivity cs) noexcept { if (cs == Qt::CaseSensitive) return ucstrcmp(lhs.begin(), lhs.size(), rhs.begin(), rhs.size()); @@ -1181,12 +1181,12 @@ static int qt_compare_strings(QStringView lhs, QLatin1String rhs, Qt::CaseSensit return ucstricmp(lhs.begin(), lhs.end(), rhs.begin(), rhs.end()); } -static int qt_compare_strings(QLatin1String lhs, QStringView rhs, Qt::CaseSensitivity cs) Q_DECL_NOTHROW +static int qt_compare_strings(QLatin1String lhs, QStringView rhs, Qt::CaseSensitivity cs) noexcept { return -qt_compare_strings(rhs, lhs, cs); } -static int qt_compare_strings(QLatin1String lhs, QLatin1String rhs, Qt::CaseSensitivity cs) Q_DECL_NOTHROW +static int qt_compare_strings(QLatin1String lhs, QLatin1String rhs, Qt::CaseSensitivity cs) noexcept { if (cs == Qt::CaseInsensitive) return qstrnicmp(lhs.data(), lhs.size(), rhs.data(), rhs.size()); @@ -1211,7 +1211,7 @@ static int qt_compare_strings(QLatin1String lhs, QLatin1String rhs, Qt::CaseSens of the characters and is very fast, but is not what a human would expect. Consider sorting user-visible strings with QString::localeAwareCompare(). */ -int QtPrivate::compareStrings(QStringView lhs, QStringView rhs, Qt::CaseSensitivity cs) Q_DECL_NOTHROW +int QtPrivate::compareStrings(QStringView lhs, QStringView rhs, Qt::CaseSensitivity cs) noexcept { return qt_compare_strings(lhs, rhs, cs); } @@ -1231,7 +1231,7 @@ int QtPrivate::compareStrings(QStringView lhs, QStringView rhs, Qt::CaseSensitiv of the characters and is very fast, but is not what a human would expect. Consider sorting user-visible strings with QString::localeAwareCompare(). */ -int QtPrivate::compareStrings(QStringView lhs, QLatin1String rhs, Qt::CaseSensitivity cs) Q_DECL_NOTHROW +int QtPrivate::compareStrings(QStringView lhs, QLatin1String rhs, Qt::CaseSensitivity cs) noexcept { return qt_compare_strings(lhs, rhs, cs); } @@ -1251,7 +1251,7 @@ int QtPrivate::compareStrings(QStringView lhs, QLatin1String rhs, Qt::CaseSensit of the characters and is very fast, but is not what a human would expect. Consider sorting user-visible strings with QString::localeAwareCompare(). */ -int QtPrivate::compareStrings(QLatin1String lhs, QStringView rhs, Qt::CaseSensitivity cs) Q_DECL_NOTHROW +int QtPrivate::compareStrings(QLatin1String lhs, QStringView rhs, Qt::CaseSensitivity cs) noexcept { return qt_compare_strings(lhs, rhs, cs); } @@ -1271,7 +1271,7 @@ int QtPrivate::compareStrings(QLatin1String lhs, QStringView rhs, Qt::CaseSensit of the characters and is very fast, but is not what a human would expect. Consider sorting user-visible strings with QString::localeAwareCompare(). */ -int QtPrivate::compareStrings(QLatin1String lhs, QLatin1String rhs, Qt::CaseSensitivity cs) Q_DECL_NOTHROW +int QtPrivate::compareStrings(QLatin1String lhs, QLatin1String rhs, Qt::CaseSensitivity cs) noexcept { return qt_compare_strings(lhs, rhs, cs); } @@ -2367,7 +2367,7 @@ void QString::expand(int i) string. */ -QString &QString::operator=(const QString &other) Q_DECL_NOTHROW +QString &QString::operator=(const QString &other) noexcept { other.d->ref.ref(); if (!d->ref.deref()) @@ -3353,7 +3353,7 @@ QString &QString::replace(QChar c, QLatin1String after, Qt::CaseSensitivity cs) expect. Consider sorting user-interface strings with localeAwareCompare(). */ -bool operator==(const QString &s1, const QString &s2) Q_DECL_NOTHROW +bool operator==(const QString &s1, const QString &s2) noexcept { if (s1.d->size != s2.d->size) return false; @@ -3366,7 +3366,7 @@ bool operator==(const QString &s1, const QString &s2) Q_DECL_NOTHROW Returns \c true if this string is equal to \a other; otherwise returns \c false. */ -bool QString::operator==(QLatin1String other) const Q_DECL_NOTHROW +bool QString::operator==(QLatin1String other) const noexcept { if (d->size != other.size()) return false; @@ -3418,7 +3418,7 @@ bool QString::operator==(QLatin1String other) const Q_DECL_NOTHROW expect. Consider sorting user-interface strings using the QString::localeAwareCompare() function. */ -bool operator<(const QString &s1, const QString &s2) Q_DECL_NOTHROW +bool operator<(const QString &s1, const QString &s2) noexcept { return qt_compare_strings(s1, s2, Qt::CaseSensitive) < 0; } @@ -3429,7 +3429,7 @@ bool operator<(const QString &s1, const QString &s2) Q_DECL_NOTHROW Returns \c true if this string is lexically less than the parameter string called \a other; otherwise returns \c false. */ -bool QString::operator<(QLatin1String other) const Q_DECL_NOTHROW +bool QString::operator<(QLatin1String other) const noexcept { return qt_compare_strings(*this, other, Qt::CaseSensitive) < 0; } @@ -3538,7 +3538,7 @@ bool QString::operator<(QLatin1String other) const Q_DECL_NOTHROW Returns \c true if this string is lexically greater than the parameter string \a other; otherwise returns \c false. */ -bool QString::operator>(QLatin1String other) const Q_DECL_NOTHROW +bool QString::operator>(QLatin1String other) const noexcept { return qt_compare_strings(*this, other, Qt::CaseSensitive) > 0; } @@ -5668,7 +5668,7 @@ QString QString::simplified_helper(QString &str) namespace { template - StringView qt_trimmed(StringView s) Q_DECL_NOTHROW + StringView qt_trimmed(StringView s) noexcept { auto begin = s.begin(); auto end = s.end(); @@ -5692,12 +5692,12 @@ namespace { \sa QString::trimmed(), QStringView::trimmed(), QLatin1String::trimmed() */ -QStringView QtPrivate::trimmed(QStringView s) Q_DECL_NOTHROW +QStringView QtPrivate::trimmed(QStringView s) noexcept { return qt_trimmed(s); } -QLatin1String QtPrivate::trimmed(QLatin1String s) Q_DECL_NOTHROW +QLatin1String QtPrivate::trimmed(QLatin1String s) noexcept { return qt_trimmed(s); } @@ -6235,7 +6235,7 @@ QString& QString::fill(QChar ch, int size) Same as compare(*this, \a other, \a cs). */ -int QString::compare(const QString &other, Qt::CaseSensitivity cs) const Q_DECL_NOTHROW +int QString::compare(const QString &other, Qt::CaseSensitivity cs) const noexcept { return qt_compare_strings(*this, other, cs); } @@ -6246,7 +6246,7 @@ int QString::compare(const QString &other, Qt::CaseSensitivity cs) const Q_DECL_ \since 4.5 */ int QString::compare_helper(const QChar *data1, int length1, const QChar *data2, int length2, - Qt::CaseSensitivity cs) Q_DECL_NOTHROW + Qt::CaseSensitivity cs) noexcept { Q_ASSERT(length1 >= 0); Q_ASSERT(length2 >= 0); @@ -6261,7 +6261,7 @@ int QString::compare_helper(const QChar *data1, int length1, const QChar *data2, Same as compare(*this, \a other, \a cs). */ -int QString::compare(QLatin1String other, Qt::CaseSensitivity cs) const Q_DECL_NOTHROW +int QString::compare(QLatin1String other, Qt::CaseSensitivity cs) const noexcept { return qt_compare_strings(*this, other, cs); } @@ -6307,7 +6307,7 @@ int QString::compare_helper(const QChar *data1, int length1, const char *data2, \since 4.5 */ int QString::compare_helper(const QChar *data1, int length1, QLatin1String s2, - Qt::CaseSensitivity cs) Q_DECL_NOTHROW + Qt::CaseSensitivity cs) noexcept { Q_ASSERT(length1 >= 0); Q_ASSERT(data1 || length1 == 0); @@ -6801,7 +6801,7 @@ static void append_utf8(QString &qs, const char *cs, int len) qs.resize(newEnd - qs.constData()); } -static uint parse_flag_characters(const char * &c) Q_DECL_NOTHROW +static uint parse_flag_characters(const char * &c) noexcept { uint flags = QLocaleData::ZeroPadExponent; while (true) { @@ -6838,7 +6838,7 @@ static int parse_field_width(const char * &c) enum LengthMod { lm_none, lm_hh, lm_h, lm_l, lm_ll, lm_L, lm_j, lm_z, lm_t }; -static inline bool can_consume(const char * &c, char ch) Q_DECL_NOTHROW +static inline bool can_consume(const char * &c, char ch) noexcept { if (*c == ch) { ++c; @@ -6847,7 +6847,7 @@ static inline bool can_consume(const char * &c, char ch) Q_DECL_NOTHROW return false; } -static LengthMod parse_length_modifier(const char * &c) Q_DECL_NOTHROW +static LengthMod parse_length_modifier(const char * &c) noexcept { switch (*c++) { case 'h': return can_consume(c, 'h') ? lm_hh : lm_h; @@ -8810,7 +8810,7 @@ namespace { struct Part { Part() : stringRef(), number(0) {} - Part(const QString &s, int pos, int len, int num = -1) Q_DECL_NOTHROW + Part(const QString &s, int pos, int len, int num = -1) noexcept : stringRef(&s, pos, len), number(num) {} QStringRef stringRef; @@ -10379,7 +10379,7 @@ QString QStringRef::toString() const { Returns \c true if string reference \a s1 is lexically equal to string reference \a s2; otherwise returns \c false. */ -bool operator==(const QStringRef &s1,const QStringRef &s2) Q_DECL_NOTHROW +bool operator==(const QStringRef &s1,const QStringRef &s2) noexcept { return s1.size() == s2.size() && qt_compare_strings(s1, s2, Qt::CaseSensitive) == 0; } @@ -10389,7 +10389,7 @@ bool operator==(const QStringRef &s1,const QStringRef &s2) Q_DECL_NOTHROW Returns \c true if string \a s1 is lexically equal to string reference \a s2; otherwise returns \c false. */ -bool operator==(const QString &s1,const QStringRef &s2) Q_DECL_NOTHROW +bool operator==(const QString &s1,const QStringRef &s2) noexcept { return s1.size() == s2.size() && qt_compare_strings(s1, s2, Qt::CaseSensitive) == 0; } @@ -10399,7 +10399,7 @@ bool operator==(const QString &s1,const QStringRef &s2) Q_DECL_NOTHROW Returns \c true if string \a s1 is lexically equal to string reference \a s2; otherwise returns \c false. */ -bool operator==(QLatin1String s1, const QStringRef &s2) Q_DECL_NOTHROW +bool operator==(QLatin1String s1, const QStringRef &s2) noexcept { if (s1.size() != s2.size()) return false; @@ -10418,7 +10418,7 @@ bool operator==(QLatin1String s1, const QStringRef &s2) Q_DECL_NOTHROW expect. Consider sorting user-interface strings using the QString::localeAwareCompare() function. */ -bool operator<(const QStringRef &s1,const QStringRef &s2) Q_DECL_NOTHROW +bool operator<(const QStringRef &s1,const QStringRef &s2) noexcept { return qt_compare_strings(s1, s2, Qt::CaseSensitive) < 0; } @@ -11553,7 +11553,7 @@ static inline qsizetype qt_string_count(QStringView haystack, QChar ch, } template -bool qt_starts_with_impl(Haystack haystack, Needle needle, Qt::CaseSensitivity cs) Q_DECL_NOTHROW +bool qt_starts_with_impl(Haystack haystack, Needle needle, Qt::CaseSensitivity cs) noexcept { if (haystack.isNull()) return needle.isNull(); // historical behavior, consider changing in ### Qt 6. @@ -11605,28 +11605,28 @@ static inline bool qt_starts_with(QStringView haystack, QChar needle, Qt::CaseSe \sa QtPrivate::endsWith(), QString::endsWith(), QStringView::endsWith(), QLatin1String::endsWith() */ -bool QtPrivate::startsWith(QStringView haystack, QStringView needle, Qt::CaseSensitivity cs) Q_DECL_NOTHROW +bool QtPrivate::startsWith(QStringView haystack, QStringView needle, Qt::CaseSensitivity cs) noexcept { return qt_starts_with_impl(haystack, needle, cs); } -bool QtPrivate::startsWith(QStringView haystack, QLatin1String needle, Qt::CaseSensitivity cs) Q_DECL_NOTHROW +bool QtPrivate::startsWith(QStringView haystack, QLatin1String needle, Qt::CaseSensitivity cs) noexcept { return qt_starts_with_impl(haystack, needle, cs); } -bool QtPrivate::startsWith(QLatin1String haystack, QStringView needle, Qt::CaseSensitivity cs) Q_DECL_NOTHROW +bool QtPrivate::startsWith(QLatin1String haystack, QStringView needle, Qt::CaseSensitivity cs) noexcept { return qt_starts_with_impl(haystack, needle, cs); } -bool QtPrivate::startsWith(QLatin1String haystack, QLatin1String needle, Qt::CaseSensitivity cs) Q_DECL_NOTHROW +bool QtPrivate::startsWith(QLatin1String haystack, QLatin1String needle, Qt::CaseSensitivity cs) noexcept { return qt_starts_with_impl(haystack, needle, cs); } template -bool qt_ends_with_impl(Haystack haystack, Needle needle, Qt::CaseSensitivity cs) Q_DECL_NOTHROW +bool qt_ends_with_impl(Haystack haystack, Needle needle, Qt::CaseSensitivity cs) noexcept { if (haystack.isNull()) return needle.isNull(); // historical behavior, consider changing in ### Qt 6. @@ -11678,22 +11678,22 @@ static inline bool qt_ends_with(QStringView haystack, QChar needle, Qt::CaseSens \sa QtPrivate::startsWith(), QString::endsWith(), QStringView::endsWith(), QLatin1String::endsWith() */ -bool QtPrivate::endsWith(QStringView haystack, QStringView needle, Qt::CaseSensitivity cs) Q_DECL_NOTHROW +bool QtPrivate::endsWith(QStringView haystack, QStringView needle, Qt::CaseSensitivity cs) noexcept { return qt_ends_with_impl(haystack, needle, cs); } -bool QtPrivate::endsWith(QStringView haystack, QLatin1String needle, Qt::CaseSensitivity cs) Q_DECL_NOTHROW +bool QtPrivate::endsWith(QStringView haystack, QLatin1String needle, Qt::CaseSensitivity cs) noexcept { return qt_ends_with_impl(haystack, needle, cs); } -bool QtPrivate::endsWith(QLatin1String haystack, QStringView needle, Qt::CaseSensitivity cs) Q_DECL_NOTHROW +bool QtPrivate::endsWith(QLatin1String haystack, QStringView needle, Qt::CaseSensitivity cs) noexcept { return qt_ends_with_impl(haystack, needle, cs); } -bool QtPrivate::endsWith(QLatin1String haystack, QLatin1String needle, Qt::CaseSensitivity cs) Q_DECL_NOTHROW +bool QtPrivate::endsWith(QLatin1String haystack, QLatin1String needle, Qt::CaseSensitivity cs) noexcept { return qt_ends_with_impl(haystack, needle, cs); } @@ -11707,7 +11707,7 @@ bool QtPrivate::endsWith(QLatin1String haystack, QLatin1String needle, Qt::CaseS position \a from. Returns -1 if \a ch could not be found. */ -qsizetype QtPrivate::findChar(QStringView str, QChar ch, qsizetype from, Qt::CaseSensitivity cs) Q_DECL_NOTHROW +qsizetype QtPrivate::findChar(QStringView str, QChar ch, qsizetype from, Qt::CaseSensitivity cs) noexcept { if (from < 0) from = qMax(from + str.size(), qsizetype(0)); @@ -11731,7 +11731,7 @@ qsizetype QtPrivate::findChar(QStringView str, QChar ch, qsizetype from, Qt::Cas return -1; } -qsizetype QtPrivate::findString(QStringView haystack0, qsizetype from, QStringView needle0, Qt::CaseSensitivity cs) Q_DECL_NOTHROW +qsizetype QtPrivate::findString(QStringView haystack0, qsizetype from, QStringView needle0, Qt::CaseSensitivity cs) noexcept { const qsizetype l = haystack0.size(); const qsizetype sl = needle0.size(); @@ -11806,7 +11806,7 @@ qsizetype QtPrivate::findString(QStringView haystack0, qsizetype from, QStringVi return -1; } -qsizetype QtPrivate::findString(QStringView haystack, qsizetype from, QLatin1String needle, Qt::CaseSensitivity cs) Q_DECL_NOTHROW +qsizetype QtPrivate::findString(QStringView haystack, qsizetype from, QLatin1String needle, Qt::CaseSensitivity cs) noexcept { if (haystack.size() < needle.size()) return -1; @@ -12271,7 +12271,7 @@ QString QString::toHtmlEscaped() const /*! \internal */ -void QAbstractConcatenable::appendLatin1To(const char *a, int len, QChar *out) Q_DECL_NOTHROW +void QAbstractConcatenable::appendLatin1To(const char *a, int len, QChar *out) noexcept { qt_from_latin1(reinterpret_cast(out), a, uint(len)); } diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index e9a205dfdf..a526a6537a 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -91,19 +91,19 @@ template class QVector; class QLatin1String { public: - Q_DECL_CONSTEXPR inline QLatin1String() Q_DECL_NOTHROW : m_size(0), m_data(nullptr) {} - Q_DECL_CONSTEXPR inline explicit QLatin1String(const char *s) Q_DECL_NOTHROW : m_size(s ? int(strlen(s)) : 0), m_data(s) {} + Q_DECL_CONSTEXPR inline QLatin1String() noexcept : m_size(0), m_data(nullptr) {} + Q_DECL_CONSTEXPR inline explicit QLatin1String(const char *s) noexcept : m_size(s ? int(strlen(s)) : 0), m_data(s) {} Q_DECL_CONSTEXPR explicit QLatin1String(const char *f, const char *l) : QLatin1String(f, int(l - f)) {} - Q_DECL_CONSTEXPR inline explicit QLatin1String(const char *s, int sz) Q_DECL_NOTHROW : m_size(sz), m_data(s) {} - inline explicit QLatin1String(const QByteArray &s) Q_DECL_NOTHROW : m_size(int(qstrnlen(s.constData(), s.size()))), m_data(s.constData()) {} + Q_DECL_CONSTEXPR inline explicit QLatin1String(const char *s, int sz) noexcept : m_size(sz), m_data(s) {} + inline explicit QLatin1String(const QByteArray &s) noexcept : m_size(int(qstrnlen(s.constData(), s.size()))), m_data(s.constData()) {} - Q_DECL_CONSTEXPR const char *latin1() const Q_DECL_NOTHROW { return m_data; } - Q_DECL_CONSTEXPR int size() const Q_DECL_NOTHROW { return m_size; } - Q_DECL_CONSTEXPR const char *data() const Q_DECL_NOTHROW { return m_data; } + Q_DECL_CONSTEXPR const char *latin1() const noexcept { return m_data; } + Q_DECL_CONSTEXPR int size() const noexcept { return m_size; } + Q_DECL_CONSTEXPR const char *data() const noexcept { return m_data; } - Q_DECL_CONSTEXPR bool isNull() const Q_DECL_NOTHROW { return !data(); } - Q_DECL_CONSTEXPR bool isEmpty() const Q_DECL_NOTHROW { return !size(); } + Q_DECL_CONSTEXPR bool isNull() const noexcept { return !data(); } + Q_DECL_CONSTEXPR bool isEmpty() const noexcept { return !size(); } Q_DECL_CONSTEXPR QLatin1Char at(int i) const { return Q_ASSERT(i >= 0), Q_ASSERT(i < size()), QLatin1Char(m_data[i]); } @@ -112,22 +112,22 @@ public: Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QLatin1Char front() const { return at(0); } Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QLatin1Char back() const { return at(size() - 1); } - Q_REQUIRED_RESULT bool startsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_DECL_NOTHROW + Q_REQUIRED_RESULT bool startsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept { return QtPrivate::startsWith(*this, s, cs); } - Q_REQUIRED_RESULT bool startsWith(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_DECL_NOTHROW + Q_REQUIRED_RESULT bool startsWith(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept { return QtPrivate::startsWith(*this, s, cs); } - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR bool startsWith(QChar c) const Q_DECL_NOTHROW + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR bool startsWith(QChar c) const noexcept { return !isEmpty() && front() == c; } - Q_REQUIRED_RESULT inline bool startsWith(QChar c, Qt::CaseSensitivity cs) const Q_DECL_NOTHROW + Q_REQUIRED_RESULT inline bool startsWith(QChar c, Qt::CaseSensitivity cs) const noexcept { return QtPrivate::startsWith(*this, QStringView(&c, 1), cs); } - Q_REQUIRED_RESULT bool endsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_DECL_NOTHROW + Q_REQUIRED_RESULT bool endsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept { return QtPrivate::endsWith(*this, s, cs); } - Q_REQUIRED_RESULT bool endsWith(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_DECL_NOTHROW + Q_REQUIRED_RESULT bool endsWith(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept { return QtPrivate::endsWith(*this, s, cs); } - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR bool endsWith(QChar c) const Q_DECL_NOTHROW + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR bool endsWith(QChar c) const noexcept { return !isEmpty() && back() == c; } - Q_REQUIRED_RESULT inline bool endsWith(QChar c, Qt::CaseSensitivity cs) const Q_DECL_NOTHROW + Q_REQUIRED_RESULT inline bool endsWith(QChar c, Qt::CaseSensitivity cs) const noexcept { return QtPrivate::endsWith(*this, QStringView(&c, 1), cs); } using value_type = const char; @@ -138,18 +138,18 @@ public: using difference_type = int; // violates Container concept requirements using size_type = int; // violates Container concept requirements - Q_DECL_CONSTEXPR const_iterator begin() const Q_DECL_NOTHROW { return data(); } - Q_DECL_CONSTEXPR const_iterator cbegin() const Q_DECL_NOTHROW { return data(); } - Q_DECL_CONSTEXPR const_iterator end() const Q_DECL_NOTHROW { return data() + size(); } - Q_DECL_CONSTEXPR const_iterator cend() const Q_DECL_NOTHROW { return data() + size(); } + Q_DECL_CONSTEXPR const_iterator begin() const noexcept { return data(); } + Q_DECL_CONSTEXPR const_iterator cbegin() const noexcept { return data(); } + Q_DECL_CONSTEXPR const_iterator end() const noexcept { return data() + size(); } + Q_DECL_CONSTEXPR const_iterator cend() const noexcept { return data() + size(); } using reverse_iterator = std::reverse_iterator; using const_reverse_iterator = reverse_iterator; - const_reverse_iterator rbegin() const Q_DECL_NOTHROW { return const_reverse_iterator(end()); } - const_reverse_iterator crbegin() const Q_DECL_NOTHROW { return const_reverse_iterator(end()); } - const_reverse_iterator rend() const Q_DECL_NOTHROW { return const_reverse_iterator(begin()); } - const_reverse_iterator crend() const Q_DECL_NOTHROW { return const_reverse_iterator(begin()); } + const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); } + const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(end()); } + const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); } + const_reverse_iterator crend() const noexcept { return const_reverse_iterator(begin()); } Q_DECL_CONSTEXPR QLatin1String mid(int pos) const { return Q_ASSERT(pos >= 0), Q_ASSERT(pos <= size()), QLatin1String(m_data + pos, m_size - pos); } @@ -167,14 +167,14 @@ public: Q_DECL_RELAXED_CONSTEXPR void truncate(int n) { Q_ASSERT(n >= 0); Q_ASSERT(n <= size()); m_size = n; } - Q_REQUIRED_RESULT QLatin1String trimmed() const Q_DECL_NOTHROW { return QtPrivate::trimmed(*this); } + Q_REQUIRED_RESULT QLatin1String trimmed() const noexcept { return QtPrivate::trimmed(*this); } - inline bool operator==(const QString &s) const Q_DECL_NOTHROW; - inline bool operator!=(const QString &s) const Q_DECL_NOTHROW; - inline bool operator>(const QString &s) const Q_DECL_NOTHROW; - inline bool operator<(const QString &s) const Q_DECL_NOTHROW; - inline bool operator>=(const QString &s) const Q_DECL_NOTHROW; - inline bool operator<=(const QString &s) const Q_DECL_NOTHROW; + inline bool operator==(const QString &s) const noexcept; + inline bool operator!=(const QString &s) const noexcept; + inline bool operator>(const QString &s) const noexcept; + inline bool operator<(const QString &s) const noexcept; + inline bool operator>=(const QString &s) const noexcept; + inline bool operator<=(const QString &s) const noexcept; #if !defined(QT_NO_CAST_FROM_ASCII) && !defined(QT_RESTRICTED_CAST_FROM_ASCII) inline QT_ASCII_CAST_WARN bool operator==(const char *s) const; @@ -204,15 +204,15 @@ typedef QLatin1String QLatin1Literal; // // QLatin1String inline implementations // -inline bool QtPrivate::isLatin1(QLatin1String) Q_DECL_NOTHROW +inline bool QtPrivate::isLatin1(QLatin1String) noexcept { return true; } // // QStringView members that require QLatin1String: // -bool QStringView::startsWith(QLatin1String s, Qt::CaseSensitivity cs) const Q_DECL_NOTHROW +bool QStringView::startsWith(QLatin1String s, Qt::CaseSensitivity cs) const noexcept { return QtPrivate::startsWith(*this, s, cs); } -bool QStringView::endsWith(QLatin1String s, Qt::CaseSensitivity cs) const Q_DECL_NOTHROW +bool QStringView::endsWith(QLatin1String s, Qt::CaseSensitivity cs) const noexcept { return QtPrivate::endsWith(*this, s, cs); } class Q_CORE_EXPORT QString @@ -220,22 +220,22 @@ class Q_CORE_EXPORT QString public: typedef QStringData Data; - inline QString() Q_DECL_NOTHROW; + inline QString() noexcept; explicit QString(const QChar *unicode, int size = -1); QString(QChar c); QString(int size, QChar c); inline QString(QLatin1String latin1); - inline QString(const QString &) Q_DECL_NOTHROW; + inline QString(const QString &) noexcept; inline ~QString(); QString &operator=(QChar c); - QString &operator=(const QString &) Q_DECL_NOTHROW; + QString &operator=(const QString &) noexcept; QString &operator=(QLatin1String latin1); #ifdef Q_COMPILER_RVALUE_REFS - inline QString(QString && other) Q_DECL_NOTHROW : d(other.d) { other.d = Data::sharedNull(); } - inline QString &operator=(QString &&other) Q_DECL_NOTHROW + inline QString(QString && other) noexcept : d(other.d) { other.d = Data::sharedNull(); } + inline QString &operator=(QString &&other) noexcept { qSwap(d, other.d); return *this; } #endif - inline void swap(QString &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + inline void swap(QString &other) noexcept { qSwap(d, other.d); } inline int size() const { return d->size; } inline int count() const { return d->size; } inline int length() const; @@ -399,7 +399,7 @@ public: bool startsWith(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; bool startsWith(const QStringRef &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; #endif - Q_REQUIRED_RESULT bool startsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_DECL_NOTHROW + Q_REQUIRED_RESULT bool startsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept { return QtPrivate::startsWith(*this, s, cs); } bool startsWith(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; bool startsWith(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; @@ -408,7 +408,7 @@ public: bool endsWith(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; bool endsWith(const QStringRef &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; #endif - Q_REQUIRED_RESULT bool endsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_DECL_NOTHROW + Q_REQUIRED_RESULT bool endsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept { return QtPrivate::endsWith(*this, s, cs); } bool endsWith(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; bool endsWith(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; @@ -613,25 +613,25 @@ public: inline QString &setUtf16(const ushort *utf16, int size); #if QT_STRINGVIEW_LEVEL < 2 - int compare(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_DECL_NOTHROW; - inline int compare(const QStringRef &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_DECL_NOTHROW; + int compare(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept; + inline int compare(const QStringRef &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept; #endif - int compare(QLatin1String other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_DECL_NOTHROW; - inline int compare(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_DECL_NOTHROW; + int compare(QLatin1String other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept; + inline int compare(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept; static inline int compare(const QString &s1, const QString &s2, - Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW + Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept { return s1.compare(s2, cs); } static inline int compare(const QString &s1, QLatin1String s2, - Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW + Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept { return s1.compare(s2, cs); } static inline int compare(QLatin1String s1, const QString &s2, - Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW + Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept { return -s2.compare(s1, cs); } static int compare(const QString &s1, const QStringRef &s2, - Qt::CaseSensitivity = Qt::CaseSensitive) Q_DECL_NOTHROW; + Qt::CaseSensitivity = Qt::CaseSensitive) noexcept; int localeAwareCompare(const QString& s) const; static int localeAwareCompare(const QString& s1, const QString& s2) @@ -671,19 +671,19 @@ public: static QString number(qulonglong, int base=10); static QString number(double, char f='g', int prec=6); - friend Q_CORE_EXPORT bool operator==(const QString &s1, const QString &s2) Q_DECL_NOTHROW; - friend Q_CORE_EXPORT bool operator<(const QString &s1, const QString &s2) Q_DECL_NOTHROW; - friend inline bool operator>(const QString &s1, const QString &s2) Q_DECL_NOTHROW { return s2 < s1; } - friend inline bool operator!=(const QString &s1, const QString &s2) Q_DECL_NOTHROW { return !(s1 == s2); } - friend inline bool operator<=(const QString &s1, const QString &s2) Q_DECL_NOTHROW { return !(s1 > s2); } - friend inline bool operator>=(const QString &s1, const QString &s2) Q_DECL_NOTHROW { return !(s1 < s2); } + friend Q_CORE_EXPORT bool operator==(const QString &s1, const QString &s2) noexcept; + friend Q_CORE_EXPORT bool operator<(const QString &s1, const QString &s2) noexcept; + friend inline bool operator>(const QString &s1, const QString &s2) noexcept { return s2 < s1; } + friend inline bool operator!=(const QString &s1, const QString &s2) noexcept { return !(s1 == s2); } + friend inline bool operator<=(const QString &s1, const QString &s2) noexcept { return !(s1 > s2); } + friend inline bool operator>=(const QString &s1, const QString &s2) noexcept { return !(s1 < s2); } - bool operator==(QLatin1String s) const Q_DECL_NOTHROW; - bool operator<(QLatin1String s) const Q_DECL_NOTHROW; - bool operator>(QLatin1String s) const Q_DECL_NOTHROW; - inline bool operator!=(QLatin1String s) const Q_DECL_NOTHROW { return !operator==(s); } - inline bool operator<=(QLatin1String s) const Q_DECL_NOTHROW { return !operator>(s); } - inline bool operator>=(QLatin1String s) const Q_DECL_NOTHROW { return !operator<(s); } + bool operator==(QLatin1String s) const noexcept; + bool operator<(QLatin1String s) const noexcept; + bool operator>(QLatin1String s) const noexcept; + inline bool operator!=(QLatin1String s) const noexcept { return !operator==(s); } + inline bool operator<=(QLatin1String s) const noexcept { return !operator>(s); } + inline bool operator>=(QLatin1String s) const noexcept { return !operator<(s); } // ASCII compatibility #if defined(QT_RESTRICTED_CAST_FROM_ASCII) @@ -844,15 +844,15 @@ private: Data *d; - friend inline bool operator==(QChar, const QString &) Q_DECL_NOTHROW; - friend inline bool operator< (QChar, const QString &) Q_DECL_NOTHROW; - friend inline bool operator> (QChar, const QString &) Q_DECL_NOTHROW; - friend inline bool operator==(QChar, const QStringRef &) Q_DECL_NOTHROW; - friend inline bool operator< (QChar, const QStringRef &) Q_DECL_NOTHROW; - friend inline bool operator> (QChar, const QStringRef &) Q_DECL_NOTHROW; - friend inline bool operator==(QChar, QLatin1String) Q_DECL_NOTHROW; - friend inline bool operator< (QChar, QLatin1String) Q_DECL_NOTHROW; - friend inline bool operator> (QChar, QLatin1String) Q_DECL_NOTHROW; + friend inline bool operator==(QChar, const QString &) noexcept; + friend inline bool operator< (QChar, const QString &) noexcept; + friend inline bool operator> (QChar, const QString &) noexcept; + friend inline bool operator==(QChar, const QStringRef &) noexcept; + friend inline bool operator< (QChar, const QStringRef &) noexcept; + friend inline bool operator> (QChar, const QStringRef &) noexcept; + friend inline bool operator==(QChar, QLatin1String) noexcept; + friend inline bool operator< (QChar, QLatin1String) noexcept; + friend inline bool operator> (QChar, QLatin1String) noexcept; void reallocData(uint alloc, bool grow = false); #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) @@ -861,13 +861,13 @@ private: QString multiArg(int numArgs, const QString **args) const; static int compare_helper(const QChar *data1, int length1, const QChar *data2, int length2, - Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW; + Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept; static int compare_helper(const QChar *data1, int length1, const char *data2, int length2, Qt::CaseSensitivity cs = Qt::CaseSensitive); static int compare_helper(const QChar *data1, int length1, QLatin1String s2, - Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW; + Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept; static int localeAwareCompare_helper(const QChar *data1, int length1, const QChar *data2, int length2); static QString toLower_helper(const QString &str); @@ -956,7 +956,7 @@ inline bool QString::isDetached() const { return !d->ref.isShared(); } inline void QString::clear() { if (!isNull()) *this = QString(); } -inline QString::QString(const QString &other) Q_DECL_NOTHROW : d(other.d) +inline QString::QString(const QString &other) noexcept : d(other.d) { Q_ASSERT(&other != this); d->ref.ref(); } inline int QString::capacity() const { return d->alloc ? d->alloc - 1 : 0; } @@ -1128,7 +1128,7 @@ inline void QCharRef::setRow(uchar arow) { QChar(*this).setRow(arow); } inline void QCharRef::setCell(uchar acell) { QChar(*this).setCell(acell); } -inline QString::QString() Q_DECL_NOTHROW : d(Data::sharedNull()) {} +inline QString::QString() noexcept : d(Data::sharedNull()) {} inline QString::~QString() { if (!d->ref.deref()) Data::deallocate(d); } inline void QString::reserve(int asize) @@ -1200,34 +1200,34 @@ QT_DEPRECATED_X("use !QString::isNull()") inline bool operator!=(const QString &s, QString::Null) { return !s.isNull(); } #endif -inline bool operator==(QLatin1String s1, QLatin1String s2) Q_DECL_NOTHROW +inline bool operator==(QLatin1String s1, QLatin1String s2) noexcept { return s1.size() == s2.size() && (!s1.size() || !memcmp(s1.latin1(), s2.latin1(), s1.size())); } -inline bool operator!=(QLatin1String s1, QLatin1String s2) Q_DECL_NOTHROW +inline bool operator!=(QLatin1String s1, QLatin1String s2) noexcept { return !operator==(s1, s2); } -inline bool operator<(QLatin1String s1, QLatin1String s2) Q_DECL_NOTHROW +inline bool operator<(QLatin1String s1, QLatin1String s2) noexcept { const int len = qMin(s1.size(), s2.size()); const int r = len ? memcmp(s1.latin1(), s2.latin1(), len) : 0; return r < 0 || (r == 0 && s1.size() < s2.size()); } -inline bool operator>(QLatin1String s1, QLatin1String s2) Q_DECL_NOTHROW +inline bool operator>(QLatin1String s1, QLatin1String s2) noexcept { return operator<(s2, s1); } -inline bool operator<=(QLatin1String s1, QLatin1String s2) Q_DECL_NOTHROW +inline bool operator<=(QLatin1String s1, QLatin1String s2) noexcept { return !operator>(s1, s2); } -inline bool operator>=(QLatin1String s1, QLatin1String s2) Q_DECL_NOTHROW +inline bool operator>=(QLatin1String s1, QLatin1String s2) noexcept { return !operator<(s1, s2); } -inline bool QLatin1String::operator==(const QString &s) const Q_DECL_NOTHROW +inline bool QLatin1String::operator==(const QString &s) const noexcept { return s == *this; } -inline bool QLatin1String::operator!=(const QString &s) const Q_DECL_NOTHROW +inline bool QLatin1String::operator!=(const QString &s) const noexcept { return s != *this; } -inline bool QLatin1String::operator>(const QString &s) const Q_DECL_NOTHROW +inline bool QLatin1String::operator>(const QString &s) const noexcept { return s < *this; } -inline bool QLatin1String::operator<(const QString &s) const Q_DECL_NOTHROW +inline bool QLatin1String::operator<(const QString &s) const noexcept { return s > *this; } -inline bool QLatin1String::operator>=(const QString &s) const Q_DECL_NOTHROW +inline bool QLatin1String::operator>=(const QString &s) const noexcept { return s <= *this; } -inline bool QLatin1String::operator<=(const QString &s) const Q_DECL_NOTHROW +inline bool QLatin1String::operator<=(const QString &s) const noexcept { return s >= *this; } #if !defined(QT_NO_CAST_FROM_ASCII) && !defined(QT_RESTRICTED_CAST_FROM_ASCII) @@ -1434,14 +1434,14 @@ public: #if QT_VERSION < QT_VERSION_CHECK(6,0,0) // ### Qt 6: remove all of these, the implicit ones are fine - QStringRef(const QStringRef &other) Q_DECL_NOTHROW + QStringRef(const QStringRef &other) noexcept :m_string(other.m_string), m_position(other.m_position), m_size(other.m_size) {} #ifdef Q_COMPILER_RVALUE_REFS - QStringRef(QStringRef &&other) Q_DECL_NOTHROW : m_string(other.m_string), m_position(other.m_position), m_size(other.m_size) {} - QStringRef &operator=(QStringRef &&other) Q_DECL_NOTHROW { return *this = other; } + QStringRef(QStringRef &&other) noexcept : m_string(other.m_string), m_position(other.m_position), m_size(other.m_size) {} + QStringRef &operator=(QStringRef &&other) noexcept { return *this = other; } #endif - QStringRef &operator=(const QStringRef &other) Q_DECL_NOTHROW + QStringRef &operator=(const QStringRef &other) noexcept { m_string = other.m_string; m_position = other.m_position; m_size = other.m_size; return *this; @@ -1484,8 +1484,8 @@ public: Q_REQUIRED_RESULT QStringRef chopped(int n) const { Q_ASSERT(n >= 0); Q_ASSERT(n <= size()); return left(size() - n); } - void truncate(int pos) Q_DECL_NOTHROW { m_size = qBound(0, pos, m_size); } - void chop(int n) Q_DECL_NOTHROW + void truncate(int pos) noexcept { m_size = qBound(0, pos, m_size); } + void chop(int n) noexcept { if (n >= m_size) m_size = 0; @@ -1495,7 +1495,7 @@ public: bool isRightToLeft() const; - Q_REQUIRED_RESULT bool startsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_DECL_NOTHROW + Q_REQUIRED_RESULT bool startsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept { return QtPrivate::startsWith(*this, s, cs); } bool startsWith(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; bool startsWith(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; @@ -1504,7 +1504,7 @@ public: bool startsWith(const QStringRef &c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; #endif - Q_REQUIRED_RESULT bool endsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_DECL_NOTHROW + Q_REQUIRED_RESULT bool endsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept { return QtPrivate::endsWith(*this, s, cs); } bool endsWith(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; bool endsWith(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; @@ -1567,19 +1567,19 @@ public: inline QT_ASCII_CAST_WARN bool operator>=(const char *s) const; #endif - int compare(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_DECL_NOTHROW; - int compare(const QStringRef &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_DECL_NOTHROW; - int compare(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_DECL_NOTHROW; + int compare(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept; + int compare(const QStringRef &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept; + int compare(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept; #if !defined(QT_NO_CAST_FROM_ASCII) && !defined(QT_RESTRICTED_CAST_FROM_ASCII) int compare(const QByteArray &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return QString::compare_helper(unicode(), size(), s.data(), qstrnlen(s.data(), s.size()), cs); } #endif static int compare(const QStringRef &s1, const QString &s2, - Qt::CaseSensitivity = Qt::CaseSensitive) Q_DECL_NOTHROW; + Qt::CaseSensitivity = Qt::CaseSensitive) noexcept; static int compare(const QStringRef &s1, const QStringRef &s2, - Qt::CaseSensitivity = Qt::CaseSensitive) Q_DECL_NOTHROW; + Qt::CaseSensitivity = Qt::CaseSensitive) noexcept; static int compare(const QStringRef &s1, QLatin1String s2, - Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW; + Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept; int localeAwareCompare(const QString &s) const; int localeAwareCompare(const QStringRef &s) const; @@ -1610,162 +1610,162 @@ inline QStringRef::QStringRef(const QString *aString) :m_string(aString), m_position(0), m_size(aString?aString->size() : 0){} // QStringRef <> QStringRef -Q_CORE_EXPORT bool operator==(const QStringRef &s1, const QStringRef &s2) Q_DECL_NOTHROW; -inline bool operator!=(const QStringRef &s1, const QStringRef &s2) Q_DECL_NOTHROW +Q_CORE_EXPORT bool operator==(const QStringRef &s1, const QStringRef &s2) noexcept; +inline bool operator!=(const QStringRef &s1, const QStringRef &s2) noexcept { return !(s1 == s2); } -Q_CORE_EXPORT bool operator<(const QStringRef &s1, const QStringRef &s2) Q_DECL_NOTHROW; -inline bool operator>(const QStringRef &s1, const QStringRef &s2) Q_DECL_NOTHROW +Q_CORE_EXPORT bool operator<(const QStringRef &s1, const QStringRef &s2) noexcept; +inline bool operator>(const QStringRef &s1, const QStringRef &s2) noexcept { return s2 < s1; } -inline bool operator<=(const QStringRef &s1, const QStringRef &s2) Q_DECL_NOTHROW +inline bool operator<=(const QStringRef &s1, const QStringRef &s2) noexcept { return !(s1 > s2); } -inline bool operator>=(const QStringRef &s1, const QStringRef &s2) Q_DECL_NOTHROW +inline bool operator>=(const QStringRef &s1, const QStringRef &s2) noexcept { return !(s1 < s2); } // QString <> QStringRef -Q_CORE_EXPORT bool operator==(const QString &lhs, const QStringRef &rhs) Q_DECL_NOTHROW; -inline bool operator!=(const QString &lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return lhs.compare(rhs) != 0; } -inline bool operator< (const QString &lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return lhs.compare(rhs) < 0; } -inline bool operator> (const QString &lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return lhs.compare(rhs) > 0; } -inline bool operator<=(const QString &lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return lhs.compare(rhs) <= 0; } -inline bool operator>=(const QString &lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return lhs.compare(rhs) >= 0; } +Q_CORE_EXPORT bool operator==(const QString &lhs, const QStringRef &rhs) noexcept; +inline bool operator!=(const QString &lhs, const QStringRef &rhs) noexcept { return lhs.compare(rhs) != 0; } +inline bool operator< (const QString &lhs, const QStringRef &rhs) noexcept { return lhs.compare(rhs) < 0; } +inline bool operator> (const QString &lhs, const QStringRef &rhs) noexcept { return lhs.compare(rhs) > 0; } +inline bool operator<=(const QString &lhs, const QStringRef &rhs) noexcept { return lhs.compare(rhs) <= 0; } +inline bool operator>=(const QString &lhs, const QStringRef &rhs) noexcept { return lhs.compare(rhs) >= 0; } -inline bool operator==(const QStringRef &lhs, const QString &rhs) Q_DECL_NOTHROW { return rhs == lhs; } -inline bool operator!=(const QStringRef &lhs, const QString &rhs) Q_DECL_NOTHROW { return rhs != lhs; } -inline bool operator< (const QStringRef &lhs, const QString &rhs) Q_DECL_NOTHROW { return rhs > lhs; } -inline bool operator> (const QStringRef &lhs, const QString &rhs) Q_DECL_NOTHROW { return rhs < lhs; } -inline bool operator<=(const QStringRef &lhs, const QString &rhs) Q_DECL_NOTHROW { return rhs >= lhs; } -inline bool operator>=(const QStringRef &lhs, const QString &rhs) Q_DECL_NOTHROW { return rhs <= lhs; } +inline bool operator==(const QStringRef &lhs, const QString &rhs) noexcept { return rhs == lhs; } +inline bool operator!=(const QStringRef &lhs, const QString &rhs) noexcept { return rhs != lhs; } +inline bool operator< (const QStringRef &lhs, const QString &rhs) noexcept { return rhs > lhs; } +inline bool operator> (const QStringRef &lhs, const QString &rhs) noexcept { return rhs < lhs; } +inline bool operator<=(const QStringRef &lhs, const QString &rhs) noexcept { return rhs >= lhs; } +inline bool operator>=(const QStringRef &lhs, const QString &rhs) noexcept { return rhs <= lhs; } #if QT_STRINGVIEW_LEVEL < 2 -inline int QString::compare(const QStringRef &s, Qt::CaseSensitivity cs) const Q_DECL_NOTHROW +inline int QString::compare(const QStringRef &s, Qt::CaseSensitivity cs) const noexcept { return QString::compare_helper(constData(), length(), s.constData(), s.length(), cs); } #endif -inline int QString::compare(QStringView s, Qt::CaseSensitivity cs) const Q_DECL_NOTHROW +inline int QString::compare(QStringView s, Qt::CaseSensitivity cs) const noexcept { return -s.compare(*this, cs); } -inline int QString::compare(const QString &s1, const QStringRef &s2, Qt::CaseSensitivity cs) Q_DECL_NOTHROW +inline int QString::compare(const QString &s1, const QStringRef &s2, Qt::CaseSensitivity cs) noexcept { return QString::compare_helper(s1.constData(), s1.length(), s2.constData(), s2.length(), cs); } -inline int QStringRef::compare(const QString &s, Qt::CaseSensitivity cs) const Q_DECL_NOTHROW +inline int QStringRef::compare(const QString &s, Qt::CaseSensitivity cs) const noexcept { return QString::compare_helper(constData(), length(), s.constData(), s.length(), cs); } -inline int QStringRef::compare(const QStringRef &s, Qt::CaseSensitivity cs) const Q_DECL_NOTHROW +inline int QStringRef::compare(const QStringRef &s, Qt::CaseSensitivity cs) const noexcept { return QString::compare_helper(constData(), length(), s.constData(), s.length(), cs); } -inline int QStringRef::compare(QLatin1String s, Qt::CaseSensitivity cs) const Q_DECL_NOTHROW +inline int QStringRef::compare(QLatin1String s, Qt::CaseSensitivity cs) const noexcept { return QString::compare_helper(constData(), length(), s, cs); } -inline int QStringRef::compare(const QStringRef &s1, const QString &s2, Qt::CaseSensitivity cs) Q_DECL_NOTHROW +inline int QStringRef::compare(const QStringRef &s1, const QString &s2, Qt::CaseSensitivity cs) noexcept { return QString::compare_helper(s1.constData(), s1.length(), s2.constData(), s2.length(), cs); } -inline int QStringRef::compare(const QStringRef &s1, const QStringRef &s2, Qt::CaseSensitivity cs) Q_DECL_NOTHROW +inline int QStringRef::compare(const QStringRef &s1, const QStringRef &s2, Qt::CaseSensitivity cs) noexcept { return QString::compare_helper(s1.constData(), s1.length(), s2.constData(), s2.length(), cs); } -inline int QStringRef::compare(const QStringRef &s1, QLatin1String s2, Qt::CaseSensitivity cs) Q_DECL_NOTHROW +inline int QStringRef::compare(const QStringRef &s1, QLatin1String s2, Qt::CaseSensitivity cs) noexcept { return QString::compare_helper(s1.constData(), s1.length(), s2, cs); } // QLatin1String <> QStringRef -Q_CORE_EXPORT bool operator==(QLatin1String lhs, const QStringRef &rhs) Q_DECL_NOTHROW; -inline bool operator!=(QLatin1String lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return rhs.compare(lhs) != 0; } -inline bool operator< (QLatin1String lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return rhs.compare(lhs) > 0; } -inline bool operator> (QLatin1String lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return rhs.compare(lhs) < 0; } -inline bool operator<=(QLatin1String lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return rhs.compare(lhs) >= 0; } -inline bool operator>=(QLatin1String lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return rhs.compare(lhs) <= 0; } +Q_CORE_EXPORT bool operator==(QLatin1String lhs, const QStringRef &rhs) noexcept; +inline bool operator!=(QLatin1String lhs, const QStringRef &rhs) noexcept { return rhs.compare(lhs) != 0; } +inline bool operator< (QLatin1String lhs, const QStringRef &rhs) noexcept { return rhs.compare(lhs) > 0; } +inline bool operator> (QLatin1String lhs, const QStringRef &rhs) noexcept { return rhs.compare(lhs) < 0; } +inline bool operator<=(QLatin1String lhs, const QStringRef &rhs) noexcept { return rhs.compare(lhs) >= 0; } +inline bool operator>=(QLatin1String lhs, const QStringRef &rhs) noexcept { return rhs.compare(lhs) <= 0; } -inline bool operator==(const QStringRef &lhs, QLatin1String rhs) Q_DECL_NOTHROW { return rhs == lhs; } -inline bool operator!=(const QStringRef &lhs, QLatin1String rhs) Q_DECL_NOTHROW { return rhs != lhs; } -inline bool operator< (const QStringRef &lhs, QLatin1String rhs) Q_DECL_NOTHROW { return rhs > lhs; } -inline bool operator> (const QStringRef &lhs, QLatin1String rhs) Q_DECL_NOTHROW { return rhs < lhs; } -inline bool operator<=(const QStringRef &lhs, QLatin1String rhs) Q_DECL_NOTHROW { return rhs >= lhs; } -inline bool operator>=(const QStringRef &lhs, QLatin1String rhs) Q_DECL_NOTHROW { return rhs <= lhs; } +inline bool operator==(const QStringRef &lhs, QLatin1String rhs) noexcept { return rhs == lhs; } +inline bool operator!=(const QStringRef &lhs, QLatin1String rhs) noexcept { return rhs != lhs; } +inline bool operator< (const QStringRef &lhs, QLatin1String rhs) noexcept { return rhs > lhs; } +inline bool operator> (const QStringRef &lhs, QLatin1String rhs) noexcept { return rhs < lhs; } +inline bool operator<=(const QStringRef &lhs, QLatin1String rhs) noexcept { return rhs >= lhs; } +inline bool operator>=(const QStringRef &lhs, QLatin1String rhs) noexcept { return rhs <= lhs; } // QChar <> QString -inline bool operator==(QChar lhs, const QString &rhs) Q_DECL_NOTHROW +inline bool operator==(QChar lhs, const QString &rhs) noexcept { return rhs.size() == 1 && lhs == rhs.front(); } -inline bool operator< (QChar lhs, const QString &rhs) Q_DECL_NOTHROW +inline bool operator< (QChar lhs, const QString &rhs) noexcept { return QString::compare_helper(&lhs, 1, rhs.data(), rhs.size()) < 0; } -inline bool operator> (QChar lhs, const QString &rhs) Q_DECL_NOTHROW +inline bool operator> (QChar lhs, const QString &rhs) noexcept { return QString::compare_helper(&lhs, 1, rhs.data(), rhs.size()) > 0; } -inline bool operator!=(QChar lhs, const QString &rhs) Q_DECL_NOTHROW { return !(lhs == rhs); } -inline bool operator<=(QChar lhs, const QString &rhs) Q_DECL_NOTHROW { return !(lhs > rhs); } -inline bool operator>=(QChar lhs, const QString &rhs) Q_DECL_NOTHROW { return !(lhs < rhs); } +inline bool operator!=(QChar lhs, const QString &rhs) noexcept { return !(lhs == rhs); } +inline bool operator<=(QChar lhs, const QString &rhs) noexcept { return !(lhs > rhs); } +inline bool operator>=(QChar lhs, const QString &rhs) noexcept { return !(lhs < rhs); } -inline bool operator==(const QString &lhs, QChar rhs) Q_DECL_NOTHROW { return rhs == lhs; } -inline bool operator!=(const QString &lhs, QChar rhs) Q_DECL_NOTHROW { return !(rhs == lhs); } -inline bool operator< (const QString &lhs, QChar rhs) Q_DECL_NOTHROW { return rhs > lhs; } -inline bool operator> (const QString &lhs, QChar rhs) Q_DECL_NOTHROW { return rhs < lhs; } -inline bool operator<=(const QString &lhs, QChar rhs) Q_DECL_NOTHROW { return !(rhs < lhs); } -inline bool operator>=(const QString &lhs, QChar rhs) Q_DECL_NOTHROW { return !(rhs > lhs); } +inline bool operator==(const QString &lhs, QChar rhs) noexcept { return rhs == lhs; } +inline bool operator!=(const QString &lhs, QChar rhs) noexcept { return !(rhs == lhs); } +inline bool operator< (const QString &lhs, QChar rhs) noexcept { return rhs > lhs; } +inline bool operator> (const QString &lhs, QChar rhs) noexcept { return rhs < lhs; } +inline bool operator<=(const QString &lhs, QChar rhs) noexcept { return !(rhs < lhs); } +inline bool operator>=(const QString &lhs, QChar rhs) noexcept { return !(rhs > lhs); } // QChar <> QStringRef -inline bool operator==(QChar lhs, const QStringRef &rhs) Q_DECL_NOTHROW +inline bool operator==(QChar lhs, const QStringRef &rhs) noexcept { return rhs.size() == 1 && lhs == rhs.front(); } -inline bool operator< (QChar lhs, const QStringRef &rhs) Q_DECL_NOTHROW +inline bool operator< (QChar lhs, const QStringRef &rhs) noexcept { return QString::compare_helper(&lhs, 1, rhs.data(), rhs.size()) < 0; } -inline bool operator> (QChar lhs, const QStringRef &rhs) Q_DECL_NOTHROW +inline bool operator> (QChar lhs, const QStringRef &rhs) noexcept { return QString::compare_helper(&lhs, 1, rhs.data(), rhs.size()) > 0; } -inline bool operator!=(QChar lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return !(lhs == rhs); } -inline bool operator<=(QChar lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return !(lhs > rhs); } -inline bool operator>=(QChar lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return !(lhs < rhs); } +inline bool operator!=(QChar lhs, const QStringRef &rhs) noexcept { return !(lhs == rhs); } +inline bool operator<=(QChar lhs, const QStringRef &rhs) noexcept { return !(lhs > rhs); } +inline bool operator>=(QChar lhs, const QStringRef &rhs) noexcept { return !(lhs < rhs); } -inline bool operator==(const QStringRef &lhs, QChar rhs) Q_DECL_NOTHROW { return rhs == lhs; } -inline bool operator!=(const QStringRef &lhs, QChar rhs) Q_DECL_NOTHROW { return !(rhs == lhs); } -inline bool operator< (const QStringRef &lhs, QChar rhs) Q_DECL_NOTHROW { return rhs > lhs; } -inline bool operator> (const QStringRef &lhs, QChar rhs) Q_DECL_NOTHROW { return rhs < lhs; } -inline bool operator<=(const QStringRef &lhs, QChar rhs) Q_DECL_NOTHROW { return !(rhs < lhs); } -inline bool operator>=(const QStringRef &lhs, QChar rhs) Q_DECL_NOTHROW { return !(rhs > lhs); } +inline bool operator==(const QStringRef &lhs, QChar rhs) noexcept { return rhs == lhs; } +inline bool operator!=(const QStringRef &lhs, QChar rhs) noexcept { return !(rhs == lhs); } +inline bool operator< (const QStringRef &lhs, QChar rhs) noexcept { return rhs > lhs; } +inline bool operator> (const QStringRef &lhs, QChar rhs) noexcept { return rhs < lhs; } +inline bool operator<=(const QStringRef &lhs, QChar rhs) noexcept { return !(rhs < lhs); } +inline bool operator>=(const QStringRef &lhs, QChar rhs) noexcept { return !(rhs > lhs); } // QChar <> QLatin1String -inline bool operator==(QChar lhs, QLatin1String rhs) Q_DECL_NOTHROW +inline bool operator==(QChar lhs, QLatin1String rhs) noexcept { return rhs.size() == 1 && lhs == rhs.front(); } -inline bool operator< (QChar lhs, QLatin1String rhs) Q_DECL_NOTHROW +inline bool operator< (QChar lhs, QLatin1String rhs) noexcept { return QString::compare_helper(&lhs, 1, rhs) < 0; } -inline bool operator> (QChar lhs, QLatin1String rhs) Q_DECL_NOTHROW +inline bool operator> (QChar lhs, QLatin1String rhs) noexcept { return QString::compare_helper(&lhs, 1, rhs) > 0; } -inline bool operator!=(QChar lhs, QLatin1String rhs) Q_DECL_NOTHROW { return !(lhs == rhs); } -inline bool operator<=(QChar lhs, QLatin1String rhs) Q_DECL_NOTHROW { return !(lhs > rhs); } -inline bool operator>=(QChar lhs, QLatin1String rhs) Q_DECL_NOTHROW { return !(lhs < rhs); } +inline bool operator!=(QChar lhs, QLatin1String rhs) noexcept { return !(lhs == rhs); } +inline bool operator<=(QChar lhs, QLatin1String rhs) noexcept { return !(lhs > rhs); } +inline bool operator>=(QChar lhs, QLatin1String rhs) noexcept { return !(lhs < rhs); } -inline bool operator==(QLatin1String lhs, QChar rhs) Q_DECL_NOTHROW { return rhs == lhs; } -inline bool operator!=(QLatin1String lhs, QChar rhs) Q_DECL_NOTHROW { return !(rhs == lhs); } -inline bool operator< (QLatin1String lhs, QChar rhs) Q_DECL_NOTHROW { return rhs > lhs; } -inline bool operator> (QLatin1String lhs, QChar rhs) Q_DECL_NOTHROW { return rhs < lhs; } -inline bool operator<=(QLatin1String lhs, QChar rhs) Q_DECL_NOTHROW { return !(rhs < lhs); } -inline bool operator>=(QLatin1String lhs, QChar rhs) Q_DECL_NOTHROW { return !(rhs > lhs); } +inline bool operator==(QLatin1String lhs, QChar rhs) noexcept { return rhs == lhs; } +inline bool operator!=(QLatin1String lhs, QChar rhs) noexcept { return !(rhs == lhs); } +inline bool operator< (QLatin1String lhs, QChar rhs) noexcept { return rhs > lhs; } +inline bool operator> (QLatin1String lhs, QChar rhs) noexcept { return rhs < lhs; } +inline bool operator<=(QLatin1String lhs, QChar rhs) noexcept { return !(rhs < lhs); } +inline bool operator>=(QLatin1String lhs, QChar rhs) noexcept { return !(rhs > lhs); } // QStringView <> QStringView -inline bool operator==(QStringView lhs, QStringView rhs) Q_DECL_NOTHROW { return lhs.size() == rhs.size() && QtPrivate::compareStrings(lhs, rhs) == 0; } -inline bool operator!=(QStringView lhs, QStringView rhs) Q_DECL_NOTHROW { return !(lhs == rhs); } -inline bool operator< (QStringView lhs, QStringView rhs) Q_DECL_NOTHROW { return QtPrivate::compareStrings(lhs, rhs) < 0; } -inline bool operator<=(QStringView lhs, QStringView rhs) Q_DECL_NOTHROW { return QtPrivate::compareStrings(lhs, rhs) <= 0; } -inline bool operator> (QStringView lhs, QStringView rhs) Q_DECL_NOTHROW { return QtPrivate::compareStrings(lhs, rhs) > 0; } -inline bool operator>=(QStringView lhs, QStringView rhs) Q_DECL_NOTHROW { return QtPrivate::compareStrings(lhs, rhs) >= 0; } +inline bool operator==(QStringView lhs, QStringView rhs) noexcept { return lhs.size() == rhs.size() && QtPrivate::compareStrings(lhs, rhs) == 0; } +inline bool operator!=(QStringView lhs, QStringView rhs) noexcept { return !(lhs == rhs); } +inline bool operator< (QStringView lhs, QStringView rhs) noexcept { return QtPrivate::compareStrings(lhs, rhs) < 0; } +inline bool operator<=(QStringView lhs, QStringView rhs) noexcept { return QtPrivate::compareStrings(lhs, rhs) <= 0; } +inline bool operator> (QStringView lhs, QStringView rhs) noexcept { return QtPrivate::compareStrings(lhs, rhs) > 0; } +inline bool operator>=(QStringView lhs, QStringView rhs) noexcept { return QtPrivate::compareStrings(lhs, rhs) >= 0; } // QStringView <> QChar -inline bool operator==(QStringView lhs, QChar rhs) Q_DECL_NOTHROW { return lhs == QStringView(&rhs, 1); } -inline bool operator!=(QStringView lhs, QChar rhs) Q_DECL_NOTHROW { return lhs != QStringView(&rhs, 1); } -inline bool operator< (QStringView lhs, QChar rhs) Q_DECL_NOTHROW { return lhs < QStringView(&rhs, 1); } -inline bool operator<=(QStringView lhs, QChar rhs) Q_DECL_NOTHROW { return lhs <= QStringView(&rhs, 1); } -inline bool operator> (QStringView lhs, QChar rhs) Q_DECL_NOTHROW { return lhs > QStringView(&rhs, 1); } -inline bool operator>=(QStringView lhs, QChar rhs) Q_DECL_NOTHROW { return lhs >= QStringView(&rhs, 1); } +inline bool operator==(QStringView lhs, QChar rhs) noexcept { return lhs == QStringView(&rhs, 1); } +inline bool operator!=(QStringView lhs, QChar rhs) noexcept { return lhs != QStringView(&rhs, 1); } +inline bool operator< (QStringView lhs, QChar rhs) noexcept { return lhs < QStringView(&rhs, 1); } +inline bool operator<=(QStringView lhs, QChar rhs) noexcept { return lhs <= QStringView(&rhs, 1); } +inline bool operator> (QStringView lhs, QChar rhs) noexcept { return lhs > QStringView(&rhs, 1); } +inline bool operator>=(QStringView lhs, QChar rhs) noexcept { return lhs >= QStringView(&rhs, 1); } -inline bool operator==(QChar lhs, QStringView rhs) Q_DECL_NOTHROW { return QStringView(&lhs, 1) == rhs; } -inline bool operator!=(QChar lhs, QStringView rhs) Q_DECL_NOTHROW { return QStringView(&lhs, 1) != rhs; } -inline bool operator< (QChar lhs, QStringView rhs) Q_DECL_NOTHROW { return QStringView(&lhs, 1) < rhs; } -inline bool operator<=(QChar lhs, QStringView rhs) Q_DECL_NOTHROW { return QStringView(&lhs, 1) <= rhs; } -inline bool operator> (QChar lhs, QStringView rhs) Q_DECL_NOTHROW { return QStringView(&lhs, 1) > rhs; } -inline bool operator>=(QChar lhs, QStringView rhs) Q_DECL_NOTHROW { return QStringView(&lhs, 1) >= rhs; } +inline bool operator==(QChar lhs, QStringView rhs) noexcept { return QStringView(&lhs, 1) == rhs; } +inline bool operator!=(QChar lhs, QStringView rhs) noexcept { return QStringView(&lhs, 1) != rhs; } +inline bool operator< (QChar lhs, QStringView rhs) noexcept { return QStringView(&lhs, 1) < rhs; } +inline bool operator<=(QChar lhs, QStringView rhs) noexcept { return QStringView(&lhs, 1) <= rhs; } +inline bool operator> (QChar lhs, QStringView rhs) noexcept { return QStringView(&lhs, 1) > rhs; } +inline bool operator>=(QChar lhs, QStringView rhs) noexcept { return QStringView(&lhs, 1) >= rhs; } // QStringView <> QLatin1String -inline bool operator==(QStringView lhs, QLatin1String rhs) Q_DECL_NOTHROW { return lhs.size() == rhs.size() && QtPrivate::compareStrings(lhs, rhs) == 0; } -inline bool operator!=(QStringView lhs, QLatin1String rhs) Q_DECL_NOTHROW { return !(lhs == rhs); } -inline bool operator< (QStringView lhs, QLatin1String rhs) Q_DECL_NOTHROW { return QtPrivate::compareStrings(lhs, rhs) < 0; } -inline bool operator<=(QStringView lhs, QLatin1String rhs) Q_DECL_NOTHROW { return QtPrivate::compareStrings(lhs, rhs) <= 0; } -inline bool operator> (QStringView lhs, QLatin1String rhs) Q_DECL_NOTHROW { return QtPrivate::compareStrings(lhs, rhs) > 0; } -inline bool operator>=(QStringView lhs, QLatin1String rhs) Q_DECL_NOTHROW { return QtPrivate::compareStrings(lhs, rhs) >= 0; } +inline bool operator==(QStringView lhs, QLatin1String rhs) noexcept { return lhs.size() == rhs.size() && QtPrivate::compareStrings(lhs, rhs) == 0; } +inline bool operator!=(QStringView lhs, QLatin1String rhs) noexcept { return !(lhs == rhs); } +inline bool operator< (QStringView lhs, QLatin1String rhs) noexcept { return QtPrivate::compareStrings(lhs, rhs) < 0; } +inline bool operator<=(QStringView lhs, QLatin1String rhs) noexcept { return QtPrivate::compareStrings(lhs, rhs) <= 0; } +inline bool operator> (QStringView lhs, QLatin1String rhs) noexcept { return QtPrivate::compareStrings(lhs, rhs) > 0; } +inline bool operator>=(QStringView lhs, QLatin1String rhs) noexcept { return QtPrivate::compareStrings(lhs, rhs) >= 0; } -inline bool operator==(QLatin1String lhs, QStringView rhs) Q_DECL_NOTHROW { return lhs.size() == rhs.size() && QtPrivate::compareStrings(lhs, rhs) == 0; } -inline bool operator!=(QLatin1String lhs, QStringView rhs) Q_DECL_NOTHROW { return !(lhs == rhs); } -inline bool operator< (QLatin1String lhs, QStringView rhs) Q_DECL_NOTHROW { return QtPrivate::compareStrings(lhs, rhs) < 0; } -inline bool operator<=(QLatin1String lhs, QStringView rhs) Q_DECL_NOTHROW { return QtPrivate::compareStrings(lhs, rhs) <= 0; } -inline bool operator> (QLatin1String lhs, QStringView rhs) Q_DECL_NOTHROW { return QtPrivate::compareStrings(lhs, rhs) > 0; } -inline bool operator>=(QLatin1String lhs, QStringView rhs) Q_DECL_NOTHROW { return QtPrivate::compareStrings(lhs, rhs) >= 0; } +inline bool operator==(QLatin1String lhs, QStringView rhs) noexcept { return lhs.size() == rhs.size() && QtPrivate::compareStrings(lhs, rhs) == 0; } +inline bool operator!=(QLatin1String lhs, QStringView rhs) noexcept { return !(lhs == rhs); } +inline bool operator< (QLatin1String lhs, QStringView rhs) noexcept { return QtPrivate::compareStrings(lhs, rhs) < 0; } +inline bool operator<=(QLatin1String lhs, QStringView rhs) noexcept { return QtPrivate::compareStrings(lhs, rhs) <= 0; } +inline bool operator> (QLatin1String lhs, QStringView rhs) noexcept { return QtPrivate::compareStrings(lhs, rhs) > 0; } +inline bool operator>=(QLatin1String lhs, QStringView rhs) noexcept { return QtPrivate::compareStrings(lhs, rhs) >= 0; } #if !defined(QT_NO_CAST_FROM_ASCII) && !defined(QT_RESTRICTED_CAST_FROM_ASCII) // QStringRef <> QByteArray diff --git a/src/corelib/tools/qstringalgorithms.h b/src/corelib/tools/qstringalgorithms.h index e94f725598..8e7fc0af9b 100644 --- a/src/corelib/tools/qstringalgorithms.h +++ b/src/corelib/tools/qstringalgorithms.h @@ -56,31 +56,31 @@ template class QVector; namespace QtPrivate { -Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype qustrlen(const ushort *str) Q_DECL_NOTHROW; +Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype qustrlen(const ushort *str) noexcept; Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION const ushort *qustrchr(QStringView str, ushort ch) noexcept; -Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QStringView lhs, QStringView rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW; -Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QStringView lhs, QLatin1String rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW; -Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QLatin1String lhs, QStringView rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW; -Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QLatin1String lhs, QLatin1String rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW; +Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QStringView lhs, QStringView rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept; +Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QStringView lhs, QLatin1String rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept; +Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QLatin1String lhs, QStringView rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept; +Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QLatin1String lhs, QLatin1String rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept; -Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool startsWith(QStringView haystack, QStringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW; -Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool startsWith(QStringView haystack, QLatin1String needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW; -Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool startsWith(QLatin1String haystack, QStringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW; -Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool startsWith(QLatin1String haystack, QLatin1String needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW; +Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool startsWith(QStringView haystack, QStringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept; +Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool startsWith(QStringView haystack, QLatin1String needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept; +Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool startsWith(QLatin1String haystack, QStringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept; +Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool startsWith(QLatin1String haystack, QLatin1String needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept; -Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool endsWith(QStringView haystack, QStringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW; -Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool endsWith(QStringView haystack, QLatin1String needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW; -Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool endsWith(QLatin1String haystack, QStringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW; -Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool endsWith(QLatin1String haystack, QLatin1String needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW; +Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool endsWith(QStringView haystack, QStringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept; +Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool endsWith(QStringView haystack, QLatin1String needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept; +Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool endsWith(QLatin1String haystack, QStringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept; +Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool endsWith(QLatin1String haystack, QLatin1String needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept; -Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype findChar(QStringView str, QChar ch, qsizetype from, Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW; -Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype findString(QStringView haystack, qsizetype from, QStringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW; -Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype findString(QStringView haystack, qsizetype from, QLatin1String needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW; +Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype findChar(QStringView str, QChar ch, qsizetype from, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept; +Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype findString(QStringView haystack, qsizetype from, QStringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept; +Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype findString(QStringView haystack, qsizetype from, QLatin1String needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept; -Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION QStringView trimmed(QStringView s) Q_DECL_NOTHROW; -Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION QLatin1String trimmed(QLatin1String s) Q_DECL_NOTHROW; +Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION QStringView trimmed(QStringView s) noexcept; +Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION QLatin1String trimmed(QLatin1String s) noexcept; Q_REQUIRED_RESULT Q_CORE_EXPORT QByteArray convertToLatin1(QStringView str); Q_REQUIRED_RESULT Q_CORE_EXPORT QByteArray convertToUtf8(QStringView str); @@ -88,10 +88,10 @@ Q_REQUIRED_RESULT Q_CORE_EXPORT QByteArray convertToLocal8Bit(QStringView str); Q_REQUIRED_RESULT Q_CORE_EXPORT QVector convertToUcs4(QStringView str); Q_REQUIRED_RESULT Q_CORE_EXPORT bool isRightToLeft(QStringView string); -Q_REQUIRED_RESULT Q_CORE_EXPORT bool isAscii(QLatin1String s) Q_DECL_NOTHROW; -Q_REQUIRED_RESULT Q_CORE_EXPORT bool isAscii(QStringView s) Q_DECL_NOTHROW; -Q_REQUIRED_RESULT bool isLatin1(QLatin1String s) Q_DECL_NOTHROW; // in qstring.h -Q_REQUIRED_RESULT Q_CORE_EXPORT bool isLatin1(QStringView s) Q_DECL_NOTHROW; +Q_REQUIRED_RESULT Q_CORE_EXPORT bool isAscii(QLatin1String s) noexcept; +Q_REQUIRED_RESULT Q_CORE_EXPORT bool isAscii(QStringView s) noexcept; +Q_REQUIRED_RESULT bool isLatin1(QLatin1String s) noexcept; // in qstring.h +Q_REQUIRED_RESULT Q_CORE_EXPORT bool isLatin1(QStringView s) noexcept; } // namespace QtPRivate diff --git a/src/corelib/tools/qstringbuilder.cpp b/src/corelib/tools/qstringbuilder.cpp index 8afc83819b..cf443ec369 100644 --- a/src/corelib/tools/qstringbuilder.cpp +++ b/src/corelib/tools/qstringbuilder.cpp @@ -124,7 +124,7 @@ QT_BEGIN_NAMESPACE /*! \internal */ -void QAbstractConcatenable::convertFromAscii(const char *a, int len, QChar *&out) Q_DECL_NOTHROW +void QAbstractConcatenable::convertFromAscii(const char *a, int len, QChar *&out) noexcept { if (Q_UNLIKELY(len == -1)) { if (!a) diff --git a/src/corelib/tools/qstringbuilder.h b/src/corelib/tools/qstringbuilder.h index 1d96d70637..79ed10c7a8 100644 --- a/src/corelib/tools/qstringbuilder.h +++ b/src/corelib/tools/qstringbuilder.h @@ -58,12 +58,12 @@ QT_BEGIN_NAMESPACE struct Q_CORE_EXPORT QAbstractConcatenable { protected: - static void convertFromAscii(const char *a, int len, QChar *&out) Q_DECL_NOTHROW; - static inline void convertFromAscii(char a, QChar *&out) Q_DECL_NOTHROW + static void convertFromAscii(const char *a, int len, QChar *&out) noexcept; + static inline void convertFromAscii(char a, QChar *&out) noexcept { *out++ = QLatin1Char(a); } - static void appendLatin1To(const char *a, int len, QChar *out) Q_DECL_NOTHROW; + static void appendLatin1To(const char *a, int len, QChar *out) noexcept; }; template struct QConcatenable {}; diff --git a/src/corelib/tools/qstringlist.h b/src/corelib/tools/qstringlist.h index b6c48488df..6387161269 100644 --- a/src/corelib/tools/qstringlist.h +++ b/src/corelib/tools/qstringlist.h @@ -100,11 +100,11 @@ class QStringList : public QList { #endif public: - inline QStringList() Q_DECL_NOTHROW { } + inline QStringList() noexcept { } inline explicit QStringList(const QString &i) { append(i); } inline QStringList(const QList &l) : QList(l) { } #ifdef Q_COMPILER_RVALUE_REFS - inline QStringList(QList &&l) Q_DECL_NOTHROW : QList(std::move(l)) { } + inline QStringList(QList &&l) noexcept : QList(std::move(l)) { } #endif #ifdef Q_COMPILER_INITIALIZER_LISTS inline QStringList(std::initializer_list args) : QList(args) { } @@ -113,7 +113,7 @@ public: QStringList &operator=(const QList &other) { QList::operator=(other); return *this; } #ifdef Q_COMPILER_RVALUE_REFS - QStringList &operator=(QList &&other) Q_DECL_NOTHROW + QStringList &operator=(QList &&other) noexcept { QList::operator=(std::move(other)); return *this; } #endif diff --git a/src/corelib/tools/qstringliteral.h b/src/corelib/tools/qstringliteral.h index 64296b89fc..603f19c0b4 100644 --- a/src/corelib/tools/qstringliteral.h +++ b/src/corelib/tools/qstringliteral.h @@ -63,7 +63,7 @@ Q_STATIC_ASSERT_X(sizeof(qunicodechar) == 2, #define QT_UNICODE_LITERAL(str) u"" str #define QStringLiteral(str) \ - ([]() Q_DECL_NOEXCEPT -> QString { \ + ([]() noexcept -> QString { \ enum { Size = sizeof(QT_UNICODE_LITERAL(str))/2 - 1 }; \ static const QStaticStringData qstring_literal = { \ Q_STATIC_STRING_DATA_HEADER_INITIALIZER(Size), \ diff --git a/src/corelib/tools/qstringview.h b/src/corelib/tools/qstringview.h index 4a900b5e89..5b6d63b71c 100644 --- a/src/corelib/tools/qstringview.h +++ b/src/corelib/tools/qstringview.h @@ -139,13 +139,13 @@ private: using if_compatible_qstring_like = typename std::enable_if::value || std::is_same::value, bool>::type; template - static Q_DECL_CONSTEXPR qsizetype lengthHelperArray(const Char (&)[N]) Q_DECL_NOTHROW + static Q_DECL_CONSTEXPR qsizetype lengthHelperArray(const Char (&)[N]) noexcept { return qsizetype(N - 1); } template - static qsizetype lengthHelperPointer(const Char *str) Q_DECL_NOTHROW + static qsizetype lengthHelperPointer(const Char *str) noexcept { #if defined(Q_CC_GNU) && !defined(Q_CC_CLANG) && !defined(Q_CC_INTEL) if (__builtin_constant_p(*str)) { @@ -157,21 +157,21 @@ private: #endif return QtPrivate::qustrlen(reinterpret_cast(str)); } - static qsizetype lengthHelperPointer(const QChar *str) Q_DECL_NOTHROW + static qsizetype lengthHelperPointer(const QChar *str) noexcept { return QtPrivate::qustrlen(reinterpret_cast(str)); } template - static const storage_type *castHelper(const Char *str) Q_DECL_NOTHROW + static const storage_type *castHelper(const Char *str) noexcept { return reinterpret_cast(str); } - static Q_DECL_CONSTEXPR const storage_type *castHelper(const storage_type *str) Q_DECL_NOTHROW + static Q_DECL_CONSTEXPR const storage_type *castHelper(const storage_type *str) noexcept { return str; } public: - Q_DECL_CONSTEXPR QStringView() Q_DECL_NOTHROW + Q_DECL_CONSTEXPR QStringView() noexcept : m_size(0), m_data(nullptr) {} - Q_DECL_CONSTEXPR QStringView(std::nullptr_t) Q_DECL_NOTHROW + Q_DECL_CONSTEXPR QStringView(std::nullptr_t) noexcept : QStringView() {} template = true> @@ -185,38 +185,38 @@ public: #ifdef Q_CLANG_QDOC template - Q_DECL_CONSTEXPR QStringView(const Char (&array)[N]) Q_DECL_NOTHROW; + Q_DECL_CONSTEXPR QStringView(const Char (&array)[N]) noexcept; template - Q_DECL_CONSTEXPR QStringView(const Char *str) Q_DECL_NOTHROW; + Q_DECL_CONSTEXPR QStringView(const Char *str) noexcept; #else template = true> - Q_DECL_CONSTEXPR QStringView(const Array &str) Q_DECL_NOTHROW + Q_DECL_CONSTEXPR QStringView(const Array &str) noexcept : QStringView(str, lengthHelperArray(str)) {} template = true> - Q_DECL_CONSTEXPR QStringView(const Pointer &str) Q_DECL_NOTHROW + Q_DECL_CONSTEXPR QStringView(const Pointer &str) noexcept : QStringView(str, str ? lengthHelperPointer(str) : 0) {} #endif #ifdef Q_CLANG_QDOC - QStringView(const QString &str) Q_DECL_NOTHROW; - QStringView(const QStringRef &str) Q_DECL_NOTHROW; + QStringView(const QString &str) noexcept; + QStringView(const QStringRef &str) noexcept; #else template = true> - QStringView(const String &str) Q_DECL_NOTHROW + QStringView(const String &str) noexcept : QStringView(str.isNull() ? nullptr : str.data(), qsizetype(str.size())) {} #endif template = true> - QStringView(const StdBasicString &str) Q_DECL_NOTHROW + QStringView(const StdBasicString &str) noexcept : QStringView(str.data(), qsizetype(str.size())) {} Q_REQUIRED_RESULT inline QString toString() const; // defined in qstring.h - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR qsizetype size() const Q_DECL_NOTHROW { return m_size; } - Q_REQUIRED_RESULT const_pointer data() const Q_DECL_NOTHROW { return reinterpret_cast(m_data); } - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR const storage_type *utf16() const Q_DECL_NOTHROW { return m_data; } + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR qsizetype size() const noexcept { return m_size; } + Q_REQUIRED_RESULT const_pointer data() const noexcept { return reinterpret_cast(m_data); } + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR const storage_type *utf16() const noexcept { return m_data; } Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QChar operator[](qsizetype n) const { return Q_ASSERT(n >= 0), Q_ASSERT(n < size()), QChar(m_data[n]); } @@ -248,28 +248,28 @@ public: Q_DECL_RELAXED_CONSTEXPR void chop(qsizetype n) { Q_ASSERT(n >= 0); Q_ASSERT(n <= size()); m_size -= n; } - Q_REQUIRED_RESULT QStringView trimmed() const Q_DECL_NOTHROW { return QtPrivate::trimmed(*this); } + Q_REQUIRED_RESULT QStringView trimmed() const noexcept { return QtPrivate::trimmed(*this); } - Q_REQUIRED_RESULT int compare(QStringView other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_DECL_NOTHROW + Q_REQUIRED_RESULT int compare(QStringView other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept { return QtPrivate::compareStrings(*this, other, cs); } - Q_REQUIRED_RESULT bool startsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_DECL_NOTHROW + Q_REQUIRED_RESULT bool startsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept { return QtPrivate::startsWith(*this, s, cs); } - Q_REQUIRED_RESULT inline bool startsWith(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_DECL_NOTHROW; - Q_REQUIRED_RESULT bool startsWith(QChar c) const Q_DECL_NOTHROW + Q_REQUIRED_RESULT inline bool startsWith(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept; + Q_REQUIRED_RESULT bool startsWith(QChar c) const noexcept { return !empty() && front() == c; } - Q_REQUIRED_RESULT bool startsWith(QChar c, Qt::CaseSensitivity cs) const Q_DECL_NOTHROW + Q_REQUIRED_RESULT bool startsWith(QChar c, Qt::CaseSensitivity cs) const noexcept { return QtPrivate::startsWith(*this, QStringView(&c, 1), cs); } - Q_REQUIRED_RESULT bool endsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_DECL_NOTHROW + Q_REQUIRED_RESULT bool endsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept { return QtPrivate::endsWith(*this, s, cs); } - Q_REQUIRED_RESULT inline bool endsWith(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_DECL_NOTHROW; - Q_REQUIRED_RESULT bool endsWith(QChar c) const Q_DECL_NOTHROW + Q_REQUIRED_RESULT inline bool endsWith(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept; + Q_REQUIRED_RESULT bool endsWith(QChar c) const noexcept { return !empty() && back() == c; } - Q_REQUIRED_RESULT bool endsWith(QChar c, Qt::CaseSensitivity cs) const Q_DECL_NOTHROW + Q_REQUIRED_RESULT bool endsWith(QChar c, Qt::CaseSensitivity cs) const noexcept { return QtPrivate::endsWith(*this, QStringView(&c, 1), cs); } - Q_REQUIRED_RESULT bool isRightToLeft() const Q_DECL_NOTHROW + Q_REQUIRED_RESULT bool isRightToLeft() const noexcept { return QtPrivate::isRightToLeft(*this); } Q_REQUIRED_RESULT Q_CORE_EXPORT int toWCharArray(wchar_t *array) const; @@ -277,24 +277,24 @@ public: // // STL compatibility API: // - Q_REQUIRED_RESULT const_iterator begin() const Q_DECL_NOTHROW { return data(); } - Q_REQUIRED_RESULT const_iterator end() const Q_DECL_NOTHROW { return data() + size(); } - Q_REQUIRED_RESULT const_iterator cbegin() const Q_DECL_NOTHROW { return begin(); } - Q_REQUIRED_RESULT const_iterator cend() const Q_DECL_NOTHROW { return end(); } - Q_REQUIRED_RESULT const_reverse_iterator rbegin() const Q_DECL_NOTHROW { return const_reverse_iterator(end()); } - Q_REQUIRED_RESULT const_reverse_iterator rend() const Q_DECL_NOTHROW { return const_reverse_iterator(begin()); } - Q_REQUIRED_RESULT const_reverse_iterator crbegin() const Q_DECL_NOTHROW { return rbegin(); } - Q_REQUIRED_RESULT const_reverse_iterator crend() const Q_DECL_NOTHROW { return rend(); } + Q_REQUIRED_RESULT const_iterator begin() const noexcept { return data(); } + Q_REQUIRED_RESULT const_iterator end() const noexcept { return data() + size(); } + Q_REQUIRED_RESULT const_iterator cbegin() const noexcept { return begin(); } + Q_REQUIRED_RESULT const_iterator cend() const noexcept { return end(); } + Q_REQUIRED_RESULT const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); } + Q_REQUIRED_RESULT const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); } + Q_REQUIRED_RESULT const_reverse_iterator crbegin() const noexcept { return rbegin(); } + Q_REQUIRED_RESULT const_reverse_iterator crend() const noexcept { return rend(); } - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR bool empty() const Q_DECL_NOTHROW { return size() == 0; } + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR bool empty() const noexcept { return size() == 0; } Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QChar front() const { return Q_ASSERT(!empty()), QChar(m_data[0]); } Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QChar back() const { return Q_ASSERT(!empty()), QChar(m_data[m_size - 1]); } // // Qt compatibility API: // - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR bool isNull() const Q_DECL_NOTHROW { return !m_data; } - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR bool isEmpty() const Q_DECL_NOTHROW { return empty(); } + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR bool isNull() const noexcept { return !m_data; } + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR bool isEmpty() const noexcept { return empty(); } Q_REQUIRED_RESULT Q_DECL_CONSTEXPR int length() const /* not nothrow! */ { return Q_ASSERT(int(size()) == size()), int(size()); } Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QChar first() const { return front(); } @@ -308,7 +308,7 @@ Q_DECLARE_TYPEINFO(QStringView, Q_PRIMITIVE_TYPE); template ::value || std::is_same::value, bool>::type = true> -inline QStringView qToStringViewIgnoringNull(const QStringLike &s) Q_DECL_NOTHROW +inline QStringView qToStringViewIgnoringNull(const QStringLike &s) noexcept { return QStringView(s.data(), s.size()); } QT_END_NAMESPACE diff --git a/src/corelib/tools/qtimezone.cpp b/src/corelib/tools/qtimezone.cpp index cbc6b50c98..ef323de14a 100644 --- a/src/corelib/tools/qtimezone.cpp +++ b/src/corelib/tools/qtimezone.cpp @@ -317,7 +317,7 @@ Q_GLOBAL_STATIC(QTimeZoneSingleton, global_tz); Create a null/invalid time zone instance. */ -QTimeZone::QTimeZone() Q_DECL_NOTHROW +QTimeZone::QTimeZone() noexcept : d(0) { } diff --git a/src/corelib/tools/qtimezone.h b/src/corelib/tools/qtimezone.h index 29d8a4dbe5..ca98986ec1 100644 --- a/src/corelib/tools/qtimezone.h +++ b/src/corelib/tools/qtimezone.h @@ -89,7 +89,7 @@ public: }; typedef QVector OffsetDataList; - QTimeZone() Q_DECL_NOTHROW; + QTimeZone() noexcept; explicit QTimeZone(const QByteArray &ianaId); explicit QTimeZone(int offsetSeconds); /*implicit*/ QTimeZone(const QByteArray &zoneId, int offsetSeconds, const QString &name, @@ -100,10 +100,10 @@ public: QTimeZone &operator=(const QTimeZone &other); #ifdef Q_COMPILER_RVALUE_REFS - QTimeZone &operator=(QTimeZone &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QTimeZone &operator=(QTimeZone &&other) noexcept { swap(other); return *this; } #endif - void swap(QTimeZone &other) Q_DECL_NOTHROW + void swap(QTimeZone &other) noexcept { d.swap(other.d); } bool operator==(const QTimeZone &other) const; diff --git a/src/corelib/tools/qtimezoneprivate_p.h b/src/corelib/tools/qtimezoneprivate_p.h index 24a9a00f11..b5e9286f6a 100644 --- a/src/corelib/tools/qtimezoneprivate_p.h +++ b/src/corelib/tools/qtimezoneprivate_p.h @@ -282,9 +282,9 @@ struct QTzTransitionRule quint8 abbreviationIndex; }; Q_DECLARE_TYPEINFO(QTzTransitionRule, Q_PRIMITIVE_TYPE); -Q_DECL_CONSTEXPR inline bool operator==(const QTzTransitionRule &lhs, const QTzTransitionRule &rhs) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline bool operator==(const QTzTransitionRule &lhs, const QTzTransitionRule &rhs) noexcept { return lhs.stdOffset == rhs.stdOffset && lhs.dstOffset == rhs.dstOffset && lhs.abbreviationIndex == rhs.abbreviationIndex; } -Q_DECL_CONSTEXPR inline bool operator!=(const QTzTransitionRule &lhs, const QTzTransitionRule &rhs) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline bool operator!=(const QTzTransitionRule &lhs, const QTzTransitionRule &rhs) noexcept { return !operator==(lhs, rhs); } class Q_AUTOTEST_EXPORT QTzTimeZonePrivate final : public QTimeZonePrivate diff --git a/src/corelib/tools/qtimezoneprivate_tz.cpp b/src/corelib/tools/qtimezoneprivate_tz.cpp index f75a61977d..6105c93a23 100644 --- a/src/corelib/tools/qtimezoneprivate_tz.cpp +++ b/src/corelib/tools/qtimezoneprivate_tz.cpp @@ -467,7 +467,7 @@ struct PosixZone static PosixZone invalid() { return {QString(), InvalidOffset}; } static PosixZone parse(const char *&pos, const char *end); - bool hasValidOffset() const Q_DECL_NOTHROW { return offset != InvalidOffset; } + bool hasValidOffset() const noexcept { return offset != InvalidOffset; } }; } // unnamed namespace diff --git a/src/corelib/tools/qtools_p.h b/src/corelib/tools/qtools_p.h index 17d2ab852a..b239987871 100644 --- a/src/corelib/tools/qtools_p.h +++ b/src/corelib/tools/qtools_p.h @@ -57,17 +57,17 @@ QT_BEGIN_NAMESPACE namespace QtMiscUtils { -Q_DECL_CONSTEXPR inline char toHexUpper(uint value) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline char toHexUpper(uint value) noexcept { return "0123456789ABCDEF"[value & 0xF]; } -Q_DECL_CONSTEXPR inline char toHexLower(uint value) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline char toHexLower(uint value) noexcept { return "0123456789abcdef"[value & 0xF]; } -Q_DECL_CONSTEXPR inline int fromHex(uint c) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline int fromHex(uint c) noexcept { return ((c >= '0') && (c <= '9')) ? int(c - '0') : ((c >= 'A') && (c <= 'F')) ? int(c - 'A' + 10) : @@ -75,12 +75,12 @@ Q_DECL_CONSTEXPR inline int fromHex(uint c) Q_DECL_NOTHROW /* otherwise */ -1; } -Q_DECL_CONSTEXPR inline char toOct(uint value) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline char toOct(uint value) noexcept { return '0' + char(value & 0x7); } -Q_DECL_CONSTEXPR inline int fromOct(uint c) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline int fromOct(uint c) noexcept { return ((c >= '0') && (c <= '7')) ? int(c - '0') : -1; } @@ -98,9 +98,9 @@ struct CalculateGrowingBlockSizeResult { // implemented in qbytearray.cpp size_t Q_CORE_EXPORT Q_DECL_CONST_FUNCTION -qCalculateBlockSize(size_t elementCount, size_t elementSize, size_t headerSize = 0) Q_DECL_NOTHROW; +qCalculateBlockSize(size_t elementCount, size_t elementSize, size_t headerSize = 0) noexcept; CalculateGrowingBlockSizeResult Q_CORE_EXPORT Q_DECL_CONST_FUNCTION -qCalculateGrowingBlockSize(size_t elementCount, size_t elementSize, size_t headerSize = 0) Q_DECL_NOTHROW ; +qCalculateGrowingBlockSize(size_t elementCount, size_t elementSize, size_t headerSize = 0) noexcept ; QT_END_NAMESPACE diff --git a/src/corelib/tools/qunicodetables.cpp b/src/corelib/tools/qunicodetables.cpp index 4c4821802d..d57b39ff1f 100644 --- a/src/corelib/tools/qunicodetables.cpp +++ b/src/corelib/tools/qunicodetables.cpp @@ -8803,42 +8803,42 @@ static const Properties uc_properties[] = { { 12, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 12, 0 } }; -Q_DECL_CONST_FUNCTION static inline const Properties *qGetProp(uint ucs4) Q_DECL_NOTHROW +Q_DECL_CONST_FUNCTION static inline const Properties *qGetProp(uint ucs4) noexcept { return uc_properties + GET_PROP_INDEX(ucs4); } -Q_DECL_CONST_FUNCTION static inline const Properties *qGetProp(ushort ucs2) Q_DECL_NOTHROW +Q_DECL_CONST_FUNCTION static inline const Properties *qGetProp(ushort ucs2) noexcept { return uc_properties + GET_PROP_INDEX_UCS2(ucs2); } -Q_DECL_CONST_FUNCTION Q_CORE_EXPORT const Properties * QT_FASTCALL properties(uint ucs4) Q_DECL_NOTHROW +Q_DECL_CONST_FUNCTION Q_CORE_EXPORT const Properties * QT_FASTCALL properties(uint ucs4) noexcept { return qGetProp(ucs4); } -Q_DECL_CONST_FUNCTION Q_CORE_EXPORT const Properties * QT_FASTCALL properties(ushort ucs2) Q_DECL_NOTHROW +Q_DECL_CONST_FUNCTION Q_CORE_EXPORT const Properties * QT_FASTCALL properties(ushort ucs2) noexcept { return qGetProp(ucs2); } -Q_CORE_EXPORT GraphemeBreakClass QT_FASTCALL graphemeBreakClass(uint ucs4) Q_DECL_NOTHROW +Q_CORE_EXPORT GraphemeBreakClass QT_FASTCALL graphemeBreakClass(uint ucs4) noexcept { return static_cast(qGetProp(ucs4)->graphemeBreakClass); } -Q_CORE_EXPORT WordBreakClass QT_FASTCALL wordBreakClass(uint ucs4) Q_DECL_NOTHROW +Q_CORE_EXPORT WordBreakClass QT_FASTCALL wordBreakClass(uint ucs4) noexcept { return static_cast(qGetProp(ucs4)->wordBreakClass); } -Q_CORE_EXPORT SentenceBreakClass QT_FASTCALL sentenceBreakClass(uint ucs4) Q_DECL_NOTHROW +Q_CORE_EXPORT SentenceBreakClass QT_FASTCALL sentenceBreakClass(uint ucs4) noexcept { return static_cast(qGetProp(ucs4)->sentenceBreakClass); } -Q_CORE_EXPORT LineBreakClass QT_FASTCALL lineBreakClass(uint ucs4) Q_DECL_NOTHROW +Q_CORE_EXPORT LineBreakClass QT_FASTCALL lineBreakClass(uint ucs4) noexcept { return static_cast(qGetProp(ucs4)->lineBreakClass); } diff --git a/src/corelib/tools/qunicodetables_p.h b/src/corelib/tools/qunicodetables_p.h index 3f2e91a9b2..cb7a211cb6 100644 --- a/src/corelib/tools/qunicodetables_p.h +++ b/src/corelib/tools/qunicodetables_p.h @@ -93,8 +93,8 @@ struct Properties { ushort script : 8; }; -Q_CORE_EXPORT const Properties * QT_FASTCALL properties(uint ucs4) Q_DECL_NOTHROW; -Q_CORE_EXPORT const Properties * QT_FASTCALL properties(ushort ucs2) Q_DECL_NOTHROW; +Q_CORE_EXPORT const Properties * QT_FASTCALL properties(uint ucs4) noexcept; +Q_CORE_EXPORT const Properties * QT_FASTCALL properties(ushort ucs2) noexcept; struct LowercaseTraits { @@ -209,20 +209,20 @@ enum LineBreakClass { NumLineBreakClasses }; -Q_CORE_EXPORT GraphemeBreakClass QT_FASTCALL graphemeBreakClass(uint ucs4) Q_DECL_NOTHROW; -inline GraphemeBreakClass graphemeBreakClass(QChar ch) Q_DECL_NOTHROW +Q_CORE_EXPORT GraphemeBreakClass QT_FASTCALL graphemeBreakClass(uint ucs4) noexcept; +inline GraphemeBreakClass graphemeBreakClass(QChar ch) noexcept { return graphemeBreakClass(ch.unicode()); } -Q_CORE_EXPORT WordBreakClass QT_FASTCALL wordBreakClass(uint ucs4) Q_DECL_NOTHROW; -inline WordBreakClass wordBreakClass(QChar ch) Q_DECL_NOTHROW +Q_CORE_EXPORT WordBreakClass QT_FASTCALL wordBreakClass(uint ucs4) noexcept; +inline WordBreakClass wordBreakClass(QChar ch) noexcept { return wordBreakClass(ch.unicode()); } -Q_CORE_EXPORT SentenceBreakClass QT_FASTCALL sentenceBreakClass(uint ucs4) Q_DECL_NOTHROW; -inline SentenceBreakClass sentenceBreakClass(QChar ch) Q_DECL_NOTHROW +Q_CORE_EXPORT SentenceBreakClass QT_FASTCALL sentenceBreakClass(uint ucs4) noexcept; +inline SentenceBreakClass sentenceBreakClass(QChar ch) noexcept { return sentenceBreakClass(ch.unicode()); } -Q_CORE_EXPORT LineBreakClass QT_FASTCALL lineBreakClass(uint ucs4) Q_DECL_NOTHROW; -inline LineBreakClass lineBreakClass(QChar ch) Q_DECL_NOTHROW +Q_CORE_EXPORT LineBreakClass QT_FASTCALL lineBreakClass(uint ucs4) noexcept; +inline LineBreakClass lineBreakClass(QChar ch) noexcept { return lineBreakClass(ch.unicode()); } } // namespace QUnicodeTables diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index 9762ec1b5b..2de21e92fa 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -65,18 +65,18 @@ class QVector Data *d; public: - inline QVector() Q_DECL_NOTHROW : d(Data::sharedNull()) { } + inline QVector() noexcept : d(Data::sharedNull()) { } explicit QVector(int size); QVector(int size, const T &t); inline QVector(const QVector &v); inline ~QVector() { if (!d->ref.deref()) freeData(d); } QVector &operator=(const QVector &v); #if defined(Q_COMPILER_RVALUE_REFS) || defined(Q_CLANG_QDOC) - QVector(QVector &&other) Q_DECL_NOTHROW : d(other.d) { other.d = Data::sharedNull(); } - QVector &operator=(QVector &&other) Q_DECL_NOTHROW + QVector(QVector &&other) noexcept : d(other.d) { other.d = Data::sharedNull(); } + QVector &operator=(QVector &&other) noexcept { QVector moved(std::move(other)); swap(moved); return *this; } #endif - void swap(QVector &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + void swap(QVector &other) noexcept { qSwap(d, other.d); } #ifdef Q_COMPILER_INITIALIZER_LISTS inline QVector(std::initializer_list args); QVector &operator=(std::initializer_list args); @@ -209,29 +209,29 @@ public: typedef std::reverse_iterator const_reverse_iterator; #if !defined(QT_STRICT_ITERATORS) || defined(Q_CLANG_QDOC) inline iterator begin() { detach(); return d->begin(); } - inline const_iterator begin() const Q_DECL_NOTHROW { return d->constBegin(); } - inline const_iterator cbegin() const Q_DECL_NOTHROW { return d->constBegin(); } - inline const_iterator constBegin() const Q_DECL_NOTHROW { return d->constBegin(); } + inline const_iterator begin() const noexcept { return d->constBegin(); } + inline const_iterator cbegin() const noexcept { return d->constBegin(); } + inline const_iterator constBegin() const noexcept { return d->constBegin(); } inline iterator end() { detach(); return d->end(); } - inline const_iterator end() const Q_DECL_NOTHROW { return d->constEnd(); } - inline const_iterator cend() const Q_DECL_NOTHROW { return d->constEnd(); } - inline const_iterator constEnd() const Q_DECL_NOTHROW { return d->constEnd(); } + inline const_iterator end() const noexcept { return d->constEnd(); } + inline const_iterator cend() const noexcept { return d->constEnd(); } + inline const_iterator constEnd() const noexcept { return d->constEnd(); } #else inline iterator begin(iterator = iterator()) { detach(); return d->begin(); } - inline const_iterator begin(const_iterator = const_iterator()) const Q_DECL_NOTHROW { return d->constBegin(); } - inline const_iterator cbegin(const_iterator = const_iterator()) const Q_DECL_NOTHROW { return d->constBegin(); } - inline const_iterator constBegin(const_iterator = const_iterator()) const Q_DECL_NOTHROW { return d->constBegin(); } + inline const_iterator begin(const_iterator = const_iterator()) const noexcept { return d->constBegin(); } + inline const_iterator cbegin(const_iterator = const_iterator()) const noexcept { return d->constBegin(); } + inline const_iterator constBegin(const_iterator = const_iterator()) const noexcept { return d->constBegin(); } inline iterator end(iterator = iterator()) { detach(); return d->end(); } - inline const_iterator end(const_iterator = const_iterator()) const Q_DECL_NOTHROW { return d->constEnd(); } - inline const_iterator cend(const_iterator = const_iterator()) const Q_DECL_NOTHROW { return d->constEnd(); } - inline const_iterator constEnd(const_iterator = const_iterator()) const Q_DECL_NOTHROW { return d->constEnd(); } + inline const_iterator end(const_iterator = const_iterator()) const noexcept { return d->constEnd(); } + inline const_iterator cend(const_iterator = const_iterator()) const noexcept { return d->constEnd(); } + inline const_iterator constEnd(const_iterator = const_iterator()) const noexcept { return d->constEnd(); } #endif reverse_iterator rbegin() { return reverse_iterator(end()); } reverse_iterator rend() { return reverse_iterator(begin()); } - const_reverse_iterator rbegin() const Q_DECL_NOTHROW { return const_reverse_iterator(end()); } - const_reverse_iterator rend() const Q_DECL_NOTHROW { return const_reverse_iterator(begin()); } - const_reverse_iterator crbegin() const Q_DECL_NOTHROW { return const_reverse_iterator(end()); } - const_reverse_iterator crend() const Q_DECL_NOTHROW { return const_reverse_iterator(begin()); } + const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); } + const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); } + const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(end()); } + const_reverse_iterator crend() const noexcept { return const_reverse_iterator(begin()); } iterator insert(iterator before, int n, const T &x); inline iterator insert(iterator before, const T &x) { return insert(before, 1, x); } inline iterator insert(iterator before, T &&x); diff --git a/src/corelib/tools/qversionnumber.cpp b/src/corelib/tools/qversionnumber.cpp index b96e48252e..6fcb9f50e9 100644 --- a/src/corelib/tools/qversionnumber.cpp +++ b/src/corelib/tools/qversionnumber.cpp @@ -235,7 +235,7 @@ QVersionNumber QVersionNumber::normalized() const \sa commonPrefix() */ -bool QVersionNumber::isPrefixOf(const QVersionNumber &other) const Q_DECL_NOTHROW +bool QVersionNumber::isPrefixOf(const QVersionNumber &other) const noexcept { if (segmentCount() > other.segmentCount()) return false; @@ -259,7 +259,7 @@ bool QVersionNumber::isPrefixOf(const QVersionNumber &other) const Q_DECL_NOTHRO \snippet qversionnumber/main.cpp 1 */ -int QVersionNumber::compare(const QVersionNumber &v1, const QVersionNumber &v2) Q_DECL_NOTHROW +int QVersionNumber::compare(const QVersionNumber &v1, const QVersionNumber &v2) noexcept { int commonlen; diff --git a/src/corelib/tools/qversionnumber.h b/src/corelib/tools/qversionnumber.h index 1bfb4aab39..d51947c091 100644 --- a/src/corelib/tools/qversionnumber.h +++ b/src/corelib/tools/qversionnumber.h @@ -87,7 +87,7 @@ class QVersionNumber }; // set the InlineSegmentMarker and set length to zero - SegmentStorage() Q_DECL_NOTHROW : dummy(1) {} + SegmentStorage() noexcept : dummy(1) {} SegmentStorage(const QVector &seg) { @@ -120,13 +120,13 @@ class QVersionNumber } #ifdef Q_COMPILER_RVALUE_REFS - SegmentStorage(SegmentStorage &&other) Q_DECL_NOTHROW + SegmentStorage(SegmentStorage &&other) noexcept : dummy(other.dummy) { other.dummy = 1; } - SegmentStorage &operator=(SegmentStorage &&other) Q_DECL_NOTHROW + SegmentStorage &operator=(SegmentStorage &&other) noexcept { qSwap(dummy, other.dummy); return *this; @@ -153,10 +153,10 @@ class QVersionNumber ~SegmentStorage() { if (isUsingPointer()) delete pointer_segments; } - bool isUsingPointer() const Q_DECL_NOTHROW + bool isUsingPointer() const noexcept { return (inline_segments[InlineSegmentMarker] & 1) == 0; } - int size() const Q_DECL_NOTHROW + int size() const noexcept { return isUsingPointer() ? pointer_segments->size() : (inline_segments[InlineSegmentMarker] >> 1); } void setInlineSize(int len) @@ -218,7 +218,7 @@ class QVersionNumber } m_segments; public: - inline QVersionNumber() Q_DECL_NOTHROW + inline QVersionNumber() noexcept : m_segments() {} inline explicit QVersionNumber(const QVector &seg) @@ -248,34 +248,34 @@ public: inline explicit QVersionNumber(int maj, int min, int mic) { m_segments.setSegments(3, maj, min, mic); } - Q_REQUIRED_RESULT inline bool isNull() const Q_DECL_NOTHROW + Q_REQUIRED_RESULT inline bool isNull() const noexcept { return segmentCount() == 0; } - Q_REQUIRED_RESULT inline bool isNormalized() const Q_DECL_NOTHROW + Q_REQUIRED_RESULT inline bool isNormalized() const noexcept { return isNull() || segmentAt(segmentCount() - 1) != 0; } - Q_REQUIRED_RESULT inline int majorVersion() const Q_DECL_NOTHROW + Q_REQUIRED_RESULT inline int majorVersion() const noexcept { return segmentAt(0); } - Q_REQUIRED_RESULT inline int minorVersion() const Q_DECL_NOTHROW + Q_REQUIRED_RESULT inline int minorVersion() const noexcept { return segmentAt(1); } - Q_REQUIRED_RESULT inline int microVersion() const Q_DECL_NOTHROW + Q_REQUIRED_RESULT inline int microVersion() const noexcept { return segmentAt(2); } Q_REQUIRED_RESULT Q_CORE_EXPORT QVersionNumber normalized() const; Q_REQUIRED_RESULT Q_CORE_EXPORT QVector segments() const; - Q_REQUIRED_RESULT inline int segmentAt(int index) const Q_DECL_NOTHROW + Q_REQUIRED_RESULT inline int segmentAt(int index) const noexcept { return (m_segments.size() > index) ? m_segments.at(index) : 0; } - Q_REQUIRED_RESULT inline int segmentCount() const Q_DECL_NOTHROW + Q_REQUIRED_RESULT inline int segmentCount() const noexcept { return m_segments.size(); } - Q_REQUIRED_RESULT Q_CORE_EXPORT bool isPrefixOf(const QVersionNumber &other) const Q_DECL_NOTHROW; + Q_REQUIRED_RESULT 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) Q_DECL_NOTHROW; + Q_REQUIRED_RESULT 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); @@ -299,22 +299,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) Q_DECL_NOTHROW +Q_REQUIRED_RESULT 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) Q_DECL_NOTHROW +Q_REQUIRED_RESULT 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) Q_DECL_NOTHROW +Q_REQUIRED_RESULT 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) Q_DECL_NOTHROW +Q_REQUIRED_RESULT 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) Q_DECL_NOTHROW +Q_REQUIRED_RESULT 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) Q_DECL_NOTHROW +Q_REQUIRED_RESULT inline bool operator!=(const QVersionNumber &lhs, const QVersionNumber &rhs) noexcept { return QVersionNumber::compare(lhs, rhs) != 0; } QT_END_NAMESPACE