From 676cb678cc7826366429761d2b3e57a052c1d868 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 9 Jan 2015 23:51:26 +0100 Subject: Remove qSwap specialization from Q_DECLARE_SHARED The way swapping is supposed to work is: 1. Each type supplies a swap() function or function template in its namespace. Any good STL implementation will find it there through ADL. As will the primary qSwap() template. 2. Each use of swap() in Qt, in particular in template code, should use qSwap() instead of std::swap() or the using+swap-trick, because qSwap() automatically enables ADL. It also has a sophisticated conditional noexcept specification that can be used in the custom swap() functions' own noexcept clause. This change also allows us to convert implicitly-shared classes' member-swap functions to noexcept one at a time, because the specialization will no longer be in conflict with the primary template regarding exception specifications. The primary's specification could, of course, be reused here, but it's complex and if the machinery around it is changed later on, it will not affect Q_DECLARE_SHARED classes. Change-Id: I3389a655a9fd8de370f363c8fcef60269a9f506c Reviewed-by: Olivier Goffart Reviewed-by: Thiago Macieira --- src/corelib/global/qtypeinfo.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/corelib/global/qtypeinfo.h b/src/corelib/global/qtypeinfo.h index 1429ad6547..e2b165ccbc 100644 --- a/src/corelib/global/qtypeinfo.h +++ b/src/corelib/global/qtypeinfo.h @@ -205,8 +205,6 @@ Q_DECLARE_TYPEINFO_BODY(QFlags, Q_PRIMITIVE_TYPE); #define Q_DECLARE_SHARED(TYPE) \ Q_DECLARE_TYPEINFO(TYPE, Q_MOVABLE_TYPE); \ -template <> inline void qSwap(TYPE &value1, TYPE &value2) \ -{ value1.swap(value2); } \ inline void swap(TYPE &value1, TYPE &value2) \ Q_DECL_NOEXCEPT_EXPR(noexcept(value1.swap(value2))) \ { value1.swap(value2); } -- cgit v1.2.3