/* * (C) Copyright Neal D. Becker (2004) * Permission to copy, use, modify, sell and distribute this software * is granted provided this copyright notice appears in all copies. * This software is provided "as is" without express or implied * warranty, and with no claim as to its suitability for any purpose. */ #include #include #include #include #include #include "zippy_iterator.H" using namespace boost; using namespace std; template class noop_iterator : public iterator_facade, typename iterator_traits::value_type, forward_traversal_tag> { public: typedef typename iterator_traits::value_type value_t; explicit noop_iterator (Iter i) : iter (i) {} private: friend class iterator_core_access; void increment() { iter++; } value_t& dereference() const { return *iter; } Iter iter; bool equal (noop_iterator const& other) const { return other.iter == iter; } }; template inline array make_array_2 (T t1, T t2) { array a; a[0] = t1; a[1] = t2; return a; } using namespace std; void TestNoop () { vector v (10); typedef vector::iterator vit; copy (noop_iterator (v.begin()), noop_iterator (v.end()), ostream_iterator (cout, "\n")); } void TestZip () { vector v0 (10, 1); vector v1 (10); copy (make_zippy_iterator (make_array_2 (v0.begin(), v1.begin())), make_zippy_iterator (make_array_2 (v0.end(), v1.end())), ostream_iterator (cerr, "\n")); } int main () { TestNoop(); TestZip(); }