From 2ab3af564c7c8424b558c5902614d1a410850acf Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 2 Aug 2019 22:27:45 +0300 Subject: Thou Shalt Not Specialize std Function Templates (or forward-declare std types) (with apologies to Mr Walter Brown) This applies the changes to our other smart pointers that a0c4b6f34546bdd22167a76a0540d37e9a37c0cf applied to QSharedPointer, with the same rationale: wg21.link/p0551. It also fixes a fwd declaration of std::function, including instead. Rationale: wg21.link/p684r0. Change-Id: If275af91f6eac15eb418b200ac7d08ba084a6130 Reviewed-by: Giuseppe D'Angelo --- src/corelib/kernel/qeventdispatcher_winrt_p.h | 2 +- src/corelib/tools/qarraydatapointer.h | 13 +------------ src/corelib/tools/qshareddata.h | 16 ++-------------- 3 files changed, 4 insertions(+), 27 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qeventdispatcher_winrt_p.h b/src/corelib/kernel/qeventdispatcher_winrt_p.h index 8b998a7958..2672f11123 100644 --- a/src/corelib/kernel/qeventdispatcher_winrt_p.h +++ b/src/corelib/kernel/qeventdispatcher_winrt_p.h @@ -57,7 +57,7 @@ #include -namespace std { template class function; } +#include QT_BEGIN_NAMESPACE diff --git a/src/corelib/tools/qarraydatapointer.h b/src/corelib/tools/qarraydatapointer.h index 0322615f91..af5173c9ad 100644 --- a/src/corelib/tools/qarraydatapointer.h +++ b/src/corelib/tools/qarraydatapointer.h @@ -202,22 +202,11 @@ inline bool operator!=(const QArrayDataPointer &lhs, const QArrayDataPointer< } template -inline void qSwap(QArrayDataPointer &p1, QArrayDataPointer &p2) +inline void swap(QArrayDataPointer &p1, QArrayDataPointer &p2) { p1.swap(p2); } QT_END_NAMESPACE -namespace std -{ - template - inline void swap( - QT_PREPEND_NAMESPACE(QArrayDataPointer) &p1, - QT_PREPEND_NAMESPACE(QArrayDataPointer) &p2) - { - p1.swap(p2); - } -} - #endif // include guard diff --git a/src/corelib/tools/qshareddata.h b/src/corelib/tools/qshareddata.h index ab54c76720..f123f8e7b9 100644 --- a/src/corelib/tools/qshareddata.h +++ b/src/corelib/tools/qshareddata.h @@ -297,25 +297,13 @@ template inline bool operator==(const QExplicitlySharedDataPointer } template -Q_INLINE_TEMPLATE void qSwap(QSharedDataPointer &p1, QSharedDataPointer &p2) +Q_INLINE_TEMPLATE void swap(QSharedDataPointer &p1, QSharedDataPointer &p2) { p1.swap(p2); } template -Q_INLINE_TEMPLATE void qSwap(QExplicitlySharedDataPointer &p1, QExplicitlySharedDataPointer &p2) +Q_INLINE_TEMPLATE void swap(QExplicitlySharedDataPointer &p1, QExplicitlySharedDataPointer &p2) { p1.swap(p2); } -QT_END_NAMESPACE -namespace std { - template - Q_INLINE_TEMPLATE void swap(QT_PREPEND_NAMESPACE(QSharedDataPointer) &p1, QT_PREPEND_NAMESPACE(QSharedDataPointer) &p2) - { p1.swap(p2); } - - template - Q_INLINE_TEMPLATE void swap(QT_PREPEND_NAMESPACE(QExplicitlySharedDataPointer) &p1, QT_PREPEND_NAMESPACE(QExplicitlySharedDataPointer) &p2) - { p1.swap(p2); } -} -QT_BEGIN_NAMESPACE - template Q_INLINE_TEMPLATE uint qHash(const QSharedDataPointer &ptr, uint seed = 0) noexcept { -- cgit v1.2.3