summaryrefslogtreecommitdiffstats
path: root/src/corelib/global
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-10-29 11:16:43 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-10-29 11:16:43 (GMT)
commit28c004a2750205750735ccb7a46549c376673434 (patch)
tree34d73a7d5a058c531bd30eba4c3d67be23272cc5 /src/corelib/global
parent8943b44c38ee6244c4a5b190c2b35879b1921843 (diff)
parent4bfd68ccbda50fa3336d6ee6875d87b1b308b870 (diff)
downloadQt-28c004a2750205750735ccb7a46549c376673434.zip
Qt-28c004a2750205750735ccb7a46549c376673434.tar.gz
Qt-28c004a2750205750735ccb7a46549c376673434.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: qSwap: use std::swap as implementation, and specialize std::swap for our container
Diffstat (limited to 'src/corelib/global')
-rw-r--r--src/corelib/global/qglobal.h25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index e71e3b6..4e78ab1 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<TYPE>(TYPE &value1, 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