diff options
Diffstat (limited to 'src/corelib/tools/qmap.h')
-rw-r--r-- | src/corelib/tools/qmap.h | 35 |
1 files changed, 12 insertions, 23 deletions
diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h index 1cf9299e26..18c681581f 100644 --- a/src/corelib/tools/qmap.h +++ b/src/corelib/tools/qmap.h @@ -49,13 +49,10 @@ #include <QtCore/qdebug.h> #endif -#include <map> -#include <new> #include <functional> - -#ifdef Q_COMPILER_INITIALIZER_LISTS #include <initializer_list> -#endif +#include <map> +#include <new> QT_BEGIN_NAMESPACE @@ -100,10 +97,10 @@ struct Q_CORE_EXPORT QMapNodeBase template <typename T> static typename std::enable_if<QTypeInfo<T>::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 <typename T> static typename std::enable_if<!QTypeInfo<T>::isComplex>::type - callDestructorIfNecessary(T &) Q_DECL_NOTHROW {} + callDestructorIfNecessary(T &) noexcept {} }; template <class Key, class T> @@ -142,7 +139,7 @@ private: rightNode()->destroySubTree(); } - QMapNode() Q_DECL_EQ_DELETE; + QMapNode() = delete; Q_DISABLE_COPY(QMapNode) }; @@ -325,32 +322,28 @@ class QMap QMapData<Key, T> *d; public: - inline QMap() Q_DECL_NOTHROW : d(static_cast<QMapData<Key, T> *>(const_cast<QMapDataBase *>(&QMapDataBase::shared_null))) { } -#ifdef Q_COMPILER_INITIALIZER_LISTS + inline QMap() noexcept : d(static_cast<QMapData<Key, T> *>(const_cast<QMapDataBase *>(&QMapDataBase::shared_null))) { } inline QMap(std::initializer_list<std::pair<Key,T> > list) : d(static_cast<QMapData<Key, T> *>(const_cast<QMapDataBase *>(&QMapDataBase::shared_null))) { for (typename std::initializer_list<std::pair<Key,T> >::const_iterator it = list.begin(); it != list.end(); ++it) insert(it->first, it->second); } -#endif QMap(const QMap<Key, T> &other); inline ~QMap() { if (!d->ref.deref()) d->destroy(); } QMap<Key, T> &operator=(const QMap<Key, T> &other); -#ifdef Q_COMPILER_RVALUE_REFS - inline QMap(QMap<Key, T> &&other) Q_DECL_NOTHROW + inline QMap(QMap<Key, T> &&other) noexcept : d(other.d) { other.d = static_cast<QMapData<Key, T> *>( const_cast<QMapDataBase *>(&QMapDataBase::shared_null)); } - inline QMap<Key, T> &operator=(QMap<Key, T> &&other) Q_DECL_NOTHROW + inline QMap<Key, T> &operator=(QMap<Key, T> &&other) noexcept { QMap moved(std::move(other)); swap(moved); return *this; } -#endif - inline void swap(QMap<Key, T> &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + inline void swap(QMap<Key, T> &other) noexcept { qSwap(d, other.d); } explicit QMap(const typename std::map<Key, T> &other); std::map<Key, T> toStdMap() const; @@ -1187,19 +1180,15 @@ template <class Key, class T> class QMultiMap : public QMap<Key, T> { public: - QMultiMap() Q_DECL_NOTHROW {} -#ifdef Q_COMPILER_INITIALIZER_LISTS + QMultiMap() noexcept {} inline QMultiMap(std::initializer_list<std::pair<Key,T> > list) { for (typename std::initializer_list<std::pair<Key,T> >::const_iterator it = list.begin(); it != list.end(); ++it) insert(it->first, it->second); } -#endif QMultiMap(const QMap<Key, T> &other) : QMap<Key, T>(other) {} -#ifdef Q_COMPILER_RVALUE_REFS - QMultiMap(QMap<Key, T> &&other) Q_DECL_NOTHROW : QMap<Key, T>(std::move(other)) {} -#endif - void swap(QMultiMap<Key, T> &other) Q_DECL_NOTHROW { QMap<Key, T>::swap(other); } + QMultiMap(QMap<Key, T> &&other) noexcept : QMap<Key, T>(std::move(other)) {} + void swap(QMultiMap<Key, T> &other) noexcept { QMap<Key, T>::swap(other); } inline typename QMap<Key, T>::iterator replace(const Key &key, const T &value) { return QMap<Key, T>::insert(key, value); } |