diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-10-30 22:30:52 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-10-30 22:30:52 (GMT) |
commit | eef6498dab75b2dce73e24d9b1c73e5ca17911b2 (patch) | |
tree | 23f475a6f89f8970dfed480fcb89345db06a7c64 /src | |
parent | c80df14aa4e7e31f4b9d19c23ed9e7793486d70e (diff) | |
parent | d548fe325f8293a9bb444a317e5191a9b639d24e (diff) | |
download | Qt-eef6498dab75b2dce73e24d9b1c73e5ca17911b2.zip Qt-eef6498dab75b2dce73e24d9b1c73e5ca17911b2.tar.gz Qt-eef6498dab75b2dce73e24d9b1c73e5ca17911b2.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 qglobal.h when included from a .c file
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 | 26 | ||||
-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, 59 insertions, 3 deletions
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index e71e3b6..b75a3d8 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -64,6 +64,10 @@ #ifdef __cplusplus +#ifndef QT_NO_STL +#include <algorithm> +#endif + #ifndef QT_NAMESPACE /* user namespace */ # define QT_PREPEND_NAMESPACE(name) ::name @@ -2064,9 +2068,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 +2087,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> |