summaryrefslogtreecommitdiffstats
path: root/config.tests/unix
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@nokia.com>2009-07-27 12:43:35 (GMT)
committerThiago Macieira <thiago.macieira@nokia.com>2009-07-27 14:15:51 (GMT)
commitf120b5e4b63cbc30874fa21947b75d352f18d7df (patch)
tree039ede0de5efeac20d904bd3978928d7bfba0f4c /config.tests/unix
parentf7e837ae1534b519bbe604fbb1eef22c35d37de1 (diff)
downloadQt-f120b5e4b63cbc30874fa21947b75d352f18d7df.zip
Qt-f120b5e4b63cbc30874fa21947b75d352f18d7df.tar.gz
Qt-f120b5e4b63cbc30874fa21947b75d352f18d7df.tar.bz2
Make the STL test a little more strict, using constructs used by Concurrent.
At least the RogueWave STL found in Sun Studio 12 (latest version available) isn't standards-compliant enough for QtConcurrent's needs. Note that WebKit also requires STL support, so this means QtWebKit will not compile with RW STL on Solaris. Reviewed-By: Bradley T. Hughes
Diffstat (limited to 'config.tests/unix')
-rw-r--r--config.tests/unix/stl/stltest.cpp61
1 files changed, 51 insertions, 10 deletions
diff --git a/config.tests/unix/stl/stltest.cpp b/config.tests/unix/stl/stltest.cpp
index ff653a4..4d74ed1 100644
--- a/config.tests/unix/stl/stltest.cpp
+++ b/config.tests/unix/stl/stltest.cpp
@@ -9,6 +9,53 @@ templates for common STL container classes.
#include <algorithm>
#include <iostream>
+// something mean to see if the compiler and C++ standard lib are good enough
+template<class K, class T>
+class DummyClass
+{
+ // everything in std namespace ?
+ typedef std::bidirectional_iterator_tag i;
+ typedef std::ptrdiff_t d;
+ // typename implemented ?
+ typedef typename std::map<K,T>::iterator MyIterator;
+};
+
+// extracted from QVector's strict iterator
+template<class T>
+class DummyIterator
+{
+ typedef DummyIterator<int> iterator;
+public:
+ T *i;
+ typedef std::random_access_iterator_tag iterator_category;
+ typedef ptrdiff_t difference_type;
+ typedef T value_type;
+ typedef T *pointer;
+ typedef T &reference;
+
+ inline DummyIterator() : i(0) {}
+ inline DummyIterator(T *n) : i(n) {}
+ inline DummyIterator(const DummyIterator &o): i(o.i){}
+ inline T &operator*() const { return *i; }
+ inline T *operator->() const { return i; }
+ inline T &operator[](int j) const { return *(i + j); }
+ inline bool operator==(const DummyIterator &o) const { return i == o.i; }
+ inline bool operator!=(const DummyIterator &o) const { return i != o.i; }
+ inline bool operator<(const DummyIterator& other) const { return i < other.i; }
+ inline bool operator<=(const DummyIterator& other) const { return i <= other.i; }
+ inline bool operator>(const DummyIterator& other) const { return i > other.i; }
+ inline bool operator>=(const DummyIterator& other) const { return i >= other.i; }
+ inline DummyIterator &operator++() { ++i; return *this; }
+ inline DummyIterator operator++(int) { T *n = i; ++i; return n; }
+ inline DummyIterator &operator--() { i--; return *this; }
+ inline DummyIterator operator--(int) { T *n = i; i--; return n; }
+ inline DummyIterator &operator+=(int j) { i+=j; return *this; }
+ inline DummyIterator &operator-=(int j) { i-=j; return *this; }
+ inline DummyIterator operator+(int j) const { return DummyIterator(i+j); }
+ inline DummyIterator operator-(int j) const { return DummyIterator(i-j); }
+ inline int operator-(DummyIterator j) const { return i - j.i; }
+};
+
int main()
{
std::vector<int> v1;
@@ -53,16 +100,10 @@ int main()
int m2size = m2.size();
m2size = 0;
+ DummyIterator<int> it1, it2;
+ int n = std::distance(it1, it2);
+ std::advance(it1, 3);
+
return 0;
}
-// something mean to see if the compiler and C++ standard lib are good enough
-template<class K, class T>
-class DummyClass
-{
- // everything in std namespace ?
- typedef std::bidirectional_iterator_tag i;
- typedef std::ptrdiff_t d;
- // typename implemented ?
- typedef typename std::map<K,T>::iterator MyIterator;
-};