diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2014-06-19 10:49:34 -0700 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2015-01-09 12:05:26 +0100 |
commit | 62b67092eadd97d739b05aeac68d556e02d22f85 (patch) | |
tree | 0fae24dd3075251da665e40d85eb8ed83dea6c0a /src/corelib/global/qtypeinfo.h | |
parent | 3fc9f97d61f5cf6a5d4941ddb4b6cd94136dc646 (diff) |
Don't specialize std::swap, just overload it in the global namespace
This is the modern, correct way of providing a swap
operation. See http://stackoverflow.com/a/8439357/134841 for more
information. By changing this, we also fix Qt building with ICC
and libc++.
This patch also adds a noexcept() rule to match what the C++11 standard
requires.
Change-Id: I18f22fe7c92cf253e94168e1312346b4c183f536
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'src/corelib/global/qtypeinfo.h')
-rw-r--r-- | src/corelib/global/qtypeinfo.h | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/src/corelib/global/qtypeinfo.h b/src/corelib/global/qtypeinfo.h index e5abb8138b..1429ad6547 100644 --- a/src/corelib/global/qtypeinfo.h +++ b/src/corelib/global/qtypeinfo.h @@ -202,19 +202,14 @@ Q_DECLARE_TYPEINFO_BODY(QFlags<T>, Q_PRIMITIVE_TYPE); types must define a member-swap, and be defined in the same namespace as Qt for this to work. */ -#define Q_DECLARE_SHARED_STL(TYPE) \ -QT_END_NAMESPACE \ -namespace std { \ - template<> inline void swap< QT_PREPEND_NAMESPACE(TYPE) >(QT_PREPEND_NAMESPACE(TYPE) &value1, QT_PREPEND_NAMESPACE(TYPE) &value2) \ - { value1.swap(value2); } \ -} \ -QT_BEGIN_NAMESPACE #define Q_DECLARE_SHARED(TYPE) \ Q_DECLARE_TYPEINFO(TYPE, Q_MOVABLE_TYPE); \ template <> inline void qSwap<TYPE>(TYPE &value1, TYPE &value2) \ { value1.swap(value2); } \ -Q_DECLARE_SHARED_STL(TYPE) +inline void swap(TYPE &value1, TYPE &value2) \ + Q_DECL_NOEXCEPT_EXPR(noexcept(value1.swap(value2))) \ +{ value1.swap(value2); } /* QTypeInfo primitive specializations |