From 62b67092eadd97d739b05aeac68d556e02d22f85 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 19 Jun 2014 10:49:34 -0700 Subject: 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 Reviewed-by: Marc Mutz --- src/corelib/global/qtypeinfo.h | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'src/corelib/global/qtypeinfo.h') 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, 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 &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 -- cgit v1.2.3