From f120b5e4b63cbc30874fa21947b75d352f18d7df Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 27 Jul 2009 14:43:35 +0200 Subject: 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 --- config.tests/unix/stl/stltest.cpp | 61 ++++++++++++++++++++++++++++++++------- 1 file 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 #include +// something mean to see if the compiler and C++ standard lib are good enough +template +class DummyClass +{ + // everything in std namespace ? + typedef std::bidirectional_iterator_tag i; + typedef std::ptrdiff_t d; + // typename implemented ? + typedef typename std::map::iterator MyIterator; +}; + +// extracted from QVector's strict iterator +template +class DummyIterator +{ + typedef DummyIterator 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 v1; @@ -53,16 +100,10 @@ int main() int m2size = m2.size(); m2size = 0; + DummyIterator 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 DummyClass -{ - // everything in std namespace ? - typedef std::bidirectional_iterator_tag i; - typedef std::ptrdiff_t d; - // typename implemented ? - typedef typename std::map::iterator MyIterator; -}; -- cgit v0.12