diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-10-30 02:47:06 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-10-30 02:47:06 (GMT) |
commit | 28857ef00643a59506ba1899cfe081f4aef5b839 (patch) | |
tree | cc07ca0a87a88b3c6e4d8037b766da9bb4852c76 /src | |
parent | 967afc717ffd411e22ce94de77cf54284815b27e (diff) | |
parent | 3796cc5f51074088ba60af7347f79e5e716c0c4a (diff) | |
download | Qt-28857ef00643a59506ba1899cfe081f4aef5b839.zip Qt-28857ef00643a59506ba1899cfe081f4aef5b839.tar.gz Qt-28857ef00643a59506ba1899cfe081f4aef5b839.tar.bz2 |
Merge branch 'master' of scm.dev.nokia.troll.no:qt/oslo-staging-2 into master-integration
* 'master' of scm.dev.nokia.troll.no:qt/oslo-staging-2:
Fix compilation in namespace
qSwap: use std::swap as implementation, and specialize std::swap for our container
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/global/qglobal.h | 25 | ||||
-rw-r--r-- | src/corelib/tools/qscopedpointer.h | 12 | ||||
-rw-r--r-- | src/corelib/tools/qshareddata.h | 14 | ||||
-rw-r--r-- | src/corelib/tools/qsharedpointer_impl.h | 10 |
4 files changed, 58 insertions, 3 deletions
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index e71e3b6..50f1538 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -43,6 +43,9 @@ #define QGLOBAL_H #include <stddef.h> +#ifndef QT_NO_STL +#include <algorithm> +#endif #define QT_VERSION_STR "4.8.0" /* @@ -2064,9 +2067,14 @@ Q_DECLARE_TYPEINFO_BODY(TYPE, FLAGS) template <typename T> inline void qSwap(T &value1, T &value2) { +#ifdef QT_NO_STL const T t = value1; value1 = value2; value2 = t; +#else + using std::swap; + swap(value1, value2); +#endif } /* @@ -2078,12 +2086,23 @@ inline void qSwap(T &value1, T &value2) types must declare a 'bool isDetached(void) const;' member for this to work. */ +#ifdef QT_NO_STL +#define Q_DECLARE_SHARED_STL(TYPE) +#else +#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) \ + { swap(value1.data_ptr(), value2.data_ptr()); } \ +} \ +QT_BEGIN_NAMESPACE +#endif + #define Q_DECLARE_SHARED(TYPE) \ template <> inline bool qIsDetached<TYPE>(TYPE &t) { return t.isDetached(); } \ template <> inline void qSwap<TYPE>(TYPE &value1, TYPE &value2) \ -{ \ - qSwap(value1.data_ptr(), value2.data_ptr()); \ -} +{ qSwap(value1.data_ptr(), value2.data_ptr()); } \ +Q_DECLARE_SHARED_STL(TYPE) /* QTypeInfo primitive specializations diff --git a/src/corelib/tools/qscopedpointer.h b/src/corelib/tools/qscopedpointer.h index 40d3851..b3a6db6 100644 --- a/src/corelib/tools/qscopedpointer.h +++ b/src/corelib/tools/qscopedpointer.h @@ -186,6 +186,18 @@ template <class T, class Cleanup> Q_INLINE_TEMPLATE void qSwap(QScopedPointer<T, Cleanup> &p1, QScopedPointer<T, Cleanup> &p2) { p1.swap(p2); } +#ifndef QT_NO_STL +QT_END_NAMESPACE +namespace std { + template <class T, class Cleanup> + Q_INLINE_TEMPLATE void swap(QT_PREPEND_NAMESPACE(QScopedPointer)<T, Cleanup> &p1, QT_PREPEND_NAMESPACE(QScopedPointer)<T, Cleanup> &p2) + { p1.swap(p2); } +} +QT_BEGIN_NAMESPACE +#endif + + + namespace QtPrivate { template <typename X, typename Y> struct QScopedArrayEnsureSameType; template <typename X> struct QScopedArrayEnsureSameType<X,X> { typedef X* Type; }; diff --git a/src/corelib/tools/qshareddata.h b/src/corelib/tools/qshareddata.h index b646a9d..45456fe 100644 --- a/src/corelib/tools/qshareddata.h +++ b/src/corelib/tools/qshareddata.h @@ -263,6 +263,20 @@ template <class T> Q_INLINE_TEMPLATE void qSwap(QExplicitlySharedDataPointer<T> &p1, QExplicitlySharedDataPointer<T> &p2) { p1.swap(p2); } +#ifndef QT_NO_STL +QT_END_NAMESPACE +namespace std { + template <class T> + Q_INLINE_TEMPLATE void swap(QT_PREPEND_NAMESPACE(QSharedDataPointer)<T> &p1, QT_PREPEND_NAMESPACE(QSharedDataPointer)<T> &p2) + { p1.swap(p2); } + + template <class T> + Q_INLINE_TEMPLATE void swap(QT_PREPEND_NAMESPACE(QExplicitlySharedDataPointer)<T> &p1, QT_PREPEND_NAMESPACE(QExplicitlySharedDataPointer)<T> &p2) + { p1.swap(p2); } +} +QT_BEGIN_NAMESPACE +#endif + QT_END_NAMESPACE QT_END_HEADER diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h index 4b47713..ef8c454 100644 --- a/src/corelib/tools/qsharedpointer_impl.h +++ b/src/corelib/tools/qsharedpointer_impl.h @@ -784,6 +784,16 @@ inline void qSwap(QSharedPointer<T> &p1, QSharedPointer<T> &p2) p1.swap(p2); } +#ifndef QT_NO_STL +QT_END_NAMESPACE +namespace std { + template <class T> + inline void swap(QT_PREPEND_NAMESPACE(QSharedPointer)<T> &p1, QT_PREPEND_NAMESPACE(QSharedPointer)<T> &p2) + { p1.swap(p2); } +} +QT_BEGIN_NAMESPACE +#endif + namespace QtSharedPointer { // helper functions: template <class X, class T> |