Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r58144 - in trunk/libs/unordered/test: exception helpers unordered
From: daniel_james_at_[hidden]
Date: 2009-12-04 14:44:35


Author: danieljames
Date: 2009-12-04 14:44:34 EST (Fri, 04 Dec 2009)
New Revision: 58144
URL: http://svn.boost.org/trac/boost/changeset/58144

Log:
Remove use of iterator_adaptor in unordered tests.
Text files modified:
   trunk/libs/unordered/test/exception/constructor_exception_tests.cpp | 5 ++-
   trunk/libs/unordered/test/exception/insert_exception_tests.cpp | 1
   trunk/libs/unordered/test/helpers/input_iterator.hpp | 51 +++++++++++++++++++++++++++++----------
   trunk/libs/unordered/test/unordered/constructor_tests.cpp | 8 ++++-
   trunk/libs/unordered/test/unordered/insert_tests.cpp | 4 ++
   5 files changed, 49 insertions(+), 20 deletions(-)

Modified: trunk/libs/unordered/test/exception/constructor_exception_tests.cpp
==============================================================================
--- trunk/libs/unordered/test/exception/constructor_exception_tests.cpp (original)
+++ trunk/libs/unordered/test/exception/constructor_exception_tests.cpp 2009-12-04 14:44:34 EST (Fri, 04 Dec 2009)
@@ -126,8 +126,9 @@
     input_range_construct_test() : range<T>(60) {}
 
     void run() const {
- T x(test::input_iterator(this->values.begin()),
- test::input_iterator(this->values.end()),
+ BOOST_DEDUCED_TYPENAME test::random_values<T>::const_iterator
+ begin = this->values.begin(), end = this->values.end();
+ T x(test::input_iterator(begin), test::input_iterator(end),
                 0, hash, equal_to, allocator);
     }
 };

Modified: trunk/libs/unordered/test/exception/insert_exception_tests.cpp
==============================================================================
--- trunk/libs/unordered/test/exception/insert_exception_tests.cpp (original)
+++ trunk/libs/unordered/test/exception/insert_exception_tests.cpp 2009-12-04 14:44:34 EST (Fri, 04 Dec 2009)
@@ -10,7 +10,6 @@
 #include "../helpers/random_values.hpp"
 #include "../helpers/invariants.hpp"
 #include "../helpers/strong.hpp"
-#include "../helpers/input_iterator.hpp"
 #include <boost/utility.hpp>
 #include <cmath>
 

Modified: trunk/libs/unordered/test/helpers/input_iterator.hpp
==============================================================================
--- trunk/libs/unordered/test/helpers/input_iterator.hpp (original)
+++ trunk/libs/unordered/test/helpers/input_iterator.hpp 2009-12-04 14:44:34 EST (Fri, 04 Dec 2009)
@@ -7,7 +7,8 @@
 #define BOOST_UNORDERED_TEST_HELPERS_INPUT_ITERATOR_HEADER
 
 #include <boost/config.hpp>
-#include <boost/iterator_adaptors.hpp>
+#include <boost/iterator.hpp>
+#include <boost/iterator/iterator_traits.hpp>
 
 namespace test
 {
@@ -16,7 +17,7 @@
     {
         typedef BOOST_DEDUCED_TYPENAME Iterator::value_type value_type;
 
- proxy(value_type const& v) : v_(v) {}
+ explicit proxy(value_type const& v) : v_(v) {}
         proxy(proxy const& x) : v_(x.v_) {}
         operator value_type const&() const { return v_; }
         
@@ -27,22 +28,44 @@
 
     template <class Iterator>
     struct input_iterator_adaptor
- : boost::iterator_adaptor<
- input_iterator_adaptor<Iterator>, Iterator,
- boost::use_default, std::input_iterator_tag,
- proxy<Iterator> >
+ : public boost::iterator<
+ std::input_iterator_tag,
+ BOOST_DEDUCED_TYPENAME boost::iterator_value<Iterator>::type,
+ std::ptrdiff_t,
+ BOOST_DEDUCED_TYPENAME boost::iterator_pointer<Iterator>::type,
+ proxy<Iterator>
+ >
     {
- typedef boost::iterator_adaptor<
- input_iterator_adaptor<Iterator>, Iterator,
- boost::use_default, std::input_iterator_tag,
- proxy<Iterator> > base;
-
- explicit input_iterator_adaptor(Iterator it = Iterator())
- : base(it) {}
+ typedef BOOST_DEDUCED_TYPENAME boost::iterator_value<Iterator>::type
+ value_type;
+
+ input_iterator_adaptor()
+ : base_() {}
+ explicit input_iterator_adaptor(Iterator& it)
+ : base_(&it) {}
+ proxy<Iterator> operator*() const {
+ return proxy<Iterator>(**base_);
+ }
+ value_type* operator->() const {
+ return &**base_;
+ }
+ input_iterator_adaptor& operator++() {
+ ++*base_; return *this;
+ }
+ //input_iterator_adaptor operator++(int) {
+ //}
+ bool operator==(input_iterator_adaptor const& x) const {
+ return *base_ == *x.base_;
+ }
+ bool operator!=(input_iterator_adaptor const& x) const {
+ return *base_ != *x.base_;
+ }
+ private:
+ Iterator* base_;
     };
 
     template <class Iterator>
- input_iterator_adaptor<Iterator> input_iterator(Iterator it)
+ input_iterator_adaptor<Iterator> input_iterator(Iterator& it)
     {
         return input_iterator_adaptor<Iterator>(it);
     }

Modified: trunk/libs/unordered/test/unordered/constructor_tests.cpp
==============================================================================
--- trunk/libs/unordered/test/unordered/constructor_tests.cpp (original)
+++ trunk/libs/unordered/test/unordered/constructor_tests.cpp 2009-12-04 14:44:34 EST (Fri, 04 Dec 2009)
@@ -245,8 +245,12 @@
     std::cerr<<"Construct 8 - from input iterator\n";
     {
         test::random_values<T> v(100, generator);
- T x(test::input_iterator(v.begin()), test::input_iterator(v.end()), 0, hf1, eq1);
- T y(test::input_iterator(x.begin()), test::input_iterator(x.end()), 0, hf2, eq2);
+ BOOST_DEDUCED_TYPENAME test::random_values<T>::const_iterator
+ v_begin = v.begin(), v_end = v.end();
+ T x(test::input_iterator(v_begin), test::input_iterator(v_end), 0, hf1, eq1);
+ BOOST_DEDUCED_TYPENAME T::const_iterator
+ x_begin = x.begin(), x_end = x.end();
+ T y(test::input_iterator(x_begin), test::input_iterator(x_end), 0, hf2, eq2);
         test::check_container(x, v);
         test::check_container(y, x);
         test::check_equivalent_keys(x);

Modified: trunk/libs/unordered/test/unordered/insert_tests.cpp
==============================================================================
--- trunk/libs/unordered/test/unordered/insert_tests.cpp (original)
+++ trunk/libs/unordered/test/unordered/insert_tests.cpp 2009-12-04 14:44:34 EST (Fri, 04 Dec 2009)
@@ -213,7 +213,9 @@
         X x;
 
         test::random_values<X> v(1000, generator);
- x.insert(test::input_iterator(v.begin()), test::input_iterator(v.end()));
+ BOOST_DEDUCED_TYPENAME test::random_values<X>::const_iterator
+ begin = v.begin(), end = v.end();
+ x.insert(test::input_iterator(begin), test::input_iterator(end));
         test::check_container(x, v);
 
         test::check_equivalent_keys(x);


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk