From a09aebd66b47d65ed76a4ce2a6bb313be6531594 Mon Sep 17 00:00:00 2001 From: nobody Date: Sun, 21 Jan 2001 05:56:58 +0000 Subject: [PATCH] This commit was manufactured by cvs2svn to create branch 'unlabeled-1.12.2'. [SVN r8674] --- include/boost/iterator.hpp | 60 -- include/boost/pending/detail/int_iterator.hpp | 75 -- include/boost/pending/iterator_adaptors.hpp | 800 ------------------ include/boost/pending/iterator_tests.hpp | 173 ---- 4 files changed, 1108 deletions(-) delete mode 100644 include/boost/iterator.hpp delete mode 100644 include/boost/pending/detail/int_iterator.hpp delete mode 100644 include/boost/pending/iterator_adaptors.hpp delete mode 100644 include/boost/pending/iterator_tests.hpp diff --git a/include/boost/iterator.hpp b/include/boost/iterator.hpp deleted file mode 100644 index 34e4e4b..0000000 --- a/include/boost/iterator.hpp +++ /dev/null @@ -1,60 +0,0 @@ -// interator.hpp workarounds for non-conforming standard libraries ---------// - -// (C) Copyright Boost.org 2000. 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. - -// See http://www.boost.org for most recent version including documentation. - -// Revision History -// 12 Jan 01 added for std::ptrdiff_t (Jens Maurer) -// 28 Jun 00 Workarounds to deal with known MSVC bugs (David Abrahams) -// 26 Jun 00 Initial version (Jeremy Siek) - -#ifndef BOOST_ITERATOR_HPP -#define BOOST_ITERATOR_HPP - -#include -#include // std::ptrdiff_t -#include - -namespace boost -{ -# ifdef BOOST_NO_STD_ITERATOR - template - struct iterator - { - typedef T value_type; - typedef Distance difference_type; - typedef Pointer pointer; - typedef Reference reference; - typedef Category iterator_category; - }; -# else - - // declare iterator_base in namespace detail to work around MSVC bugs which - // prevent derivation from an identically-named class in a different namespace. - namespace detail { - template -# if !defined(BOOST_MSVC_STD_ITERATOR) - struct iterator_base : std::iterator {}; -# else - struct iterator_base : std::iterator - { - typedef Reference reference; - typedef Pointer pointer; - typedef Distance difference_type; - }; -# endif - } - - template - struct iterator : detail::iterator_base {}; -# endif -} // namespace boost - -#endif // BOOST_ITERATOR_HPP diff --git a/include/boost/pending/detail/int_iterator.hpp b/include/boost/pending/detail/int_iterator.hpp deleted file mode 100644 index 9fcfffe..0000000 --- a/include/boost/pending/detail/int_iterator.hpp +++ /dev/null @@ -1,75 +0,0 @@ -// (C) Copyright Jeremy Siek 1999. 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. - -#ifndef BOOST_INT_ITERATOR_H -#define BOOST_INT_ITERATOR_H - -#include -#if !defined BOOST_MSVC -#include -#endif -#include -//using namespace std; - -#ifndef BOOST_NO_OPERATORS_IN_NAMESPACE -namespace boost { -#endif - -// this should use random_access_iterator_helper but I've had -// VC++ portablility problems with that. -JGS -template -class int_iterator -{ - typedef int_iterator self; -public: - typedef std::random_access_iterator_tag iterator_category; - typedef IntT value_type; - typedef IntT& reference; - typedef IntT* pointer; - typedef ptrdiff_t difference_type; - - inline int_iterator() : _i(0) { } - inline int_iterator(IntT i) : _i(i) { } - inline int_iterator(const self& x) : _i(x._i) { } - inline self& operator=(const self& x) { _i = x._i; return *this; } - inline IntT operator*() { return _i; } - inline IntT operator[](IntT n) { return _i + n; } - inline self& operator++() { ++_i; return *this; } - inline self operator++(int) { self t = *this; ++_i; return t; } - inline self& operator+=(IntT n) { _i += n; return *this; } - inline self operator+(IntT n) { self t = *this; t += n; return t; } - inline self& operator--() { --_i; return *this; } - inline self operator--(int) { self t = *this; --_i; return t; } - inline self& operator-=(IntT n) { _i -= n; return *this; } - inline IntT operator-(const self& x) const { return _i - x._i; } - inline bool operator==(const self& x) const { return _i == x._i; } - // vc++ had a problem finding != in random_access_iterator_helper - // need to look into this... for now implementing everything here -JGS - inline bool operator!=(const self& x) const { return _i != x._i; } - inline bool operator<(const self& x) const { return _i < x._i; } - inline bool operator<=(const self& x) const { return _i <= x._i; } - inline bool operator>(const self& x) const { return _i > x._i; } - inline bool operator>=(const self& x) const { return _i >= x._i; } -protected: - IntT _i; -}; - -template -inline int_iterator -operator+(IntT n, int_iterator t) { t += n; return t; } - -#ifndef BOOST_NO_OPERATORS_IN_NAMESPACE -} /* namespace boost */ -#endif - -#ifdef BOOST_NO_OPERATORS_IN_NAMESPACE -namespace boost { - using ::int_iterator; -} -#endif - - -#endif /* BOOST_INT_ITERATOR_H */ diff --git a/include/boost/pending/iterator_adaptors.hpp b/include/boost/pending/iterator_adaptors.hpp deleted file mode 100644 index 379762b..0000000 --- a/include/boost/pending/iterator_adaptors.hpp +++ /dev/null @@ -1,800 +0,0 @@ -// (C) Copyright David Abrahams 2000. 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. -// -// (C) Copyright Jeremy Siek 2000. 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. - -#ifndef BOOST_ITERATOR_ADAPTOR_DWA053000_HPP_ -#define BOOST_ITERATOR_ADAPTOR_DWA053000_HPP_ - -#include -#include -#include -#include - -// I was having some problems with VC6. I couldn't tell whether our hack for -// stock GCC was causing problems so I needed an easy way to turn it on and -// off. Now we can test the hack with various compilers and still have an -// "out" if it doesn't work. -dwa 7/31/00 -#if __GNUC__ == 2 && __GNUC_MINOR__ <= 96 && !defined(__STL_USE_NAMESPACES) -# define BOOST_RELOPS_AMBIGUITY_BUG 1 -#endif - -namespace boost { - -// Just a "type envelope"; works around some MSVC deficiencies. -template -struct type {}; - - -//============================================================================ -// Concept checking classes that express the requirements for iterator -// policies and adapted types. These classes are mostly for -// documentation purposes, and are not used in this header file. They -// merely provide a more succinct statement of what is expected of the -// iterator policies. - -template -struct TrivialIteratorPoliciesConcept -{ - typedef typename Traits::reference Reference; - void constraints() { - function_requires< AssignableConcept >(); - function_requires< DefaultConstructibleConcept >(); - function_requires< AssignableConcept >(); - function_requires< DefaultConstructibleConcept >(); - - const_constraints(); - } - void const_constraints() const { - Reference r = p.dereference(type(), x); - b = p.equal(x, x); - ignore_unused_variable_warning(r); - } - Policies p; - Adapted x; - mutable bool b; -}; - -// Add InputIteratorPoliciesConcept? - -template -struct ForwardIteratorPoliciesConcept -{ - typedef typename Traits::iterator_category iterator_category; - void constraints() { - function_requires< - TrivialIteratorPoliciesConcept - >(); - - p.increment(x); - std::forward_iterator_tag t = iterator_category(); - ignore_unused_variable_warning(t); - } - Policies p; - Adapted x; - iterator_category category; -}; - -template -struct BidirectionalIteratorPoliciesConcept -{ - typedef typename Traits::iterator_category iterator_category; - void constraints() { - function_requires< - ForwardIteratorPoliciesConcept - >(); - - p.decrement(x); - std::bidirectional_iterator_tag t = iterator_category(); - ignore_unused_variable_warning(t); - } - Policies p; - Adapted x; -}; - -template -struct RandomAccessIteratorPoliciesConcept -{ - typedef typename Traits::difference_type DifferenceType; - typedef typename Traits::iterator_category iterator_category; - void constraints() { - function_requires< - BidirectionalIteratorPoliciesConcept - >(); - - p.advance(x, n); - std::random_access_iterator_tag t = iterator_category(); - const_constraints(); - ignore_unused_variable_warning(t); - } - void const_constraints() const { - n = p.distance(type(), x, x); - b = p.less(x, x); - } - Policies p; - Adapted x; - mutable DifferenceType n; - mutable bool b; -}; - - -//============================================================================ -// Default policies for iterator adaptors. You can use this as a base -// class if you want to customize particular policies. -struct default_iterator_policies -{ - // Some of these members were defined static, but Borland got confused - // and thought they were non-const. Also, Sun C++ does not like static - // function templates. - - template - Reference dereference(type, const Iterator& x) const - { return *x; } - - template - void increment(Iterator& x) - { ++x; } - - template - void decrement(Iterator& x) - { --x; } - - template - void advance(Iterator& x, DifferenceType n) - { x += n; } - - template - Difference distance(type, const Iterator1& x, - const Iterator2& y) const - { return y - x; } - - template - bool equal(const Iterator1& x, const Iterator2& y) const - { return x == y; } - - template - bool less(const Iterator1& x, const Iterator2& y) const - { return x < y; } -}; - -// putting the comparisons in a base class avoids the g++ -// ambiguous overload bug due to the relops operators - -#ifdef BOOST_RELOPS_AMBIGUITY_BUG -template -struct iterator_comparisons : Base { }; - -template -inline bool operator==(const iterator_comparisons& xb, - const iterator_comparisons& yb) -{ - const D1& x = static_cast(xb); - const D2& y = static_cast(yb); - return x.policies().equal(x.iter(), y.iter()); -} - -template -inline bool operator!=(const iterator_comparisons& xb, - const iterator_comparisons& yb) -{ - const D1& x = static_cast(xb); - const D2& y = static_cast(yb); - return !x.policies().equal(x.iter(), y.iter()); -} - -template -inline bool operator<(const iterator_comparisons& xb, - const iterator_comparisons& yb) -{ - const D1& x = static_cast(xb); - const D2& y = static_cast(yb); - return x.policies().less(x.iter(), y.iter()); -} - -template -inline bool operator>(const iterator_comparisons& xb, - const iterator_comparisons& yb) -{ - const D1& x = static_cast(xb); - const D2& y = static_cast(yb); - return x.policies().less(y.iter(), x.iter()); -} - -template -inline bool operator>=(const iterator_comparisons& xb, - const iterator_comparisons& yb) -{ - const D1& x = static_cast(xb); - const D2& y = static_cast(yb); - return !x.policies().less(x.iter(), y.iter()); -} - -template -inline bool operator<=(const iterator_comparisons& xb, - const iterator_comparisons& yb) -{ - const D1& x = static_cast(xb); - const D2& y = static_cast(yb); - return !x.policies().less(y.iter(), x.iter()); -} -#endif - -//============================================================================ -// Some compilers (SGI MIPSpro 7.1.3.3) instantiate/compile member functions -// whether or not they are used. The following functions make sure that -// when the base iterators do not support particular operators, those -// operators do not get used. - -namespace detail { - - // Dummy versions for iterators that don't support member access - template - inline typename Iter::pointer - operator_arrow(const Iter&, std::input_iterator_tag) { - return typename Iter::pointer(); - } - template - inline typename Iter::pointer - operator_arrow(const Iter&, std::output_iterator_tag) { - return typename Iter::pointer(); - } - - // Real version - template - inline typename Iter::pointer - operator_arrow(const Iter& i, std::forward_iterator_tag) { - return &(*i); - } - - // Dummy version for non-random access iterators - template - inline void advance_impl(Iter&, Diff, std::input_iterator_tag) { } - template - inline void advance_impl(Iter&, Diff, std::output_iterator_tag) { } - - // Real version - template - inline void - advance_impl(Iter& i, Diff n, std::random_access_iterator_tag) { -#ifdef __MWERKS__ - i.policies().advance(i.iter(), n); -#else - i.policies().advance(i.iter(), n); -#endif - } - - // Dummy versions for non-bidirectional iterators - template - inline void decrement_impl(Iter&, std::input_iterator_tag) { } - template - inline void decrement_impl(Iter&, std::output_iterator_tag) { } - - // Real version - template - inline void - decrement_impl(Iter& i, std::bidirectional_iterator_tag) { -#ifdef __MWERKS__ - i.policies().decrement(i.iter()); -#else - i.policies().decrement(i.iter()); -#endif - } - -} // namespace detail - -//============================================================================ -// iterator_adaptor - A generalized adaptor around an existing -// iterator, which is itself an iterator -// -// Iterator - the iterator type being wrapped. -// -// Policies - a set of policies determining how the resulting iterator -// works. -// -// Traits - a class satisfying the same requirements as a specialization of -// std::iterator_traits for the resulting iterator. -// -template -#endif - > -struct iterator_adaptor : -#ifdef BOOST_RELOPS_AMBIGUITY_BUG - iterator_comparisons< - iterator_adaptor, -#endif - boost::iterator -#ifdef BOOST_RELOPS_AMBIGUITY_BUG -> -#endif -{ - typedef iterator_adaptor Self; -public: - typedef typename Traits::difference_type difference_type; - typedef typename Traits::value_type value_type; - typedef typename Traits::pointer pointer; - typedef typename Traits::reference reference; - typedef typename Traits::iterator_category iterator_category; - typedef Iterator iterator_type; - - iterator_adaptor() { } - - iterator_adaptor(const Iterator& iter, const Policies& p = Policies()) - : m_iter_p(iter, p) {} - - template - iterator_adaptor (const iterator_adaptor& src) - : m_iter_p(src.iter(), src.policies()) { - } - - reference operator*() const { - return policies().dereference(type(), iter()); - } - -#ifdef _MSC_VER -# pragma warning(push) -# pragma warning( disable : 4284 ) -#endif - - pointer operator->() const - { return detail::operator_arrow(*this, iterator_category()); } - -#ifdef _MSC_VER -# pragma warning(pop) -#endif - - reference operator[](difference_type n) const - { return *(*this + n); } - - Self& operator++() { -#ifdef __MWERKS__ - // Odd bug, MWERKS couldn't deduce the type for the member template - // Workaround by explicitly specifying the type. - policies().increment(iter()); -#else - policies().increment(iter()); -#endif - return *this; - } - - Self operator++(int) { Self tmp(*this); ++*this; return tmp; } - - Self& operator--() { - detail::decrement_impl(*this, iterator_category()); - return *this; - } - - Self operator--(int) { Self tmp(*this); --*this; return tmp; } - - Self& operator+=(difference_type n) { - detail::advance_impl(*this, n, iterator_category()); - return *this; - } - - Self& operator-=(difference_type n) { - detail::advance_impl(*this, -n, iterator_category()); - return *this; - } - - iterator_type base() const { return m_iter_p.first(); } - -private: - typedef Policies policies_type; - compressed_pair m_iter_p; -public: // too many compilers have trouble when these are private. - Policies& policies() { return m_iter_p.second(); } - const Policies& policies() const { return m_iter_p.second(); } - Iterator& iter() { return m_iter_p.first(); } - const Iterator& iter() const { return m_iter_p.first(); } -}; - - -template -iterator_adaptor -operator-(iterator_adaptor p, const typename Traits::difference_type x) -{ - return p -= x; -} - -template -iterator_adaptor -operator+(iterator_adaptor p, typename Traits::difference_type x) -{ - return p += x; -} - -template -iterator_adaptor -operator+(typename Traits::difference_type x, iterator_adaptor p) -{ - return p += x; -} - -template -typename Traits1::difference_type operator-( - const iterator_adaptor& x, - const iterator_adaptor& y ) -{ - typedef typename Traits1::difference_type difference_type; - return x.policies().distance(type(), y.iter(), x.iter()); -} - -#ifndef BOOST_RELOPS_AMBIGUITY_BUG -template -inline bool -operator==(const iterator_adaptor& x, const iterator_adaptor& y) { - return x.policies().equal(x.iter(), y.iter()); -} - -template -inline bool -operator<(const iterator_adaptor& x, const iterator_adaptor& y) { - return x.policies().less(x.iter(), y.iter()); -} - -template -inline bool -operator>(const iterator_adaptor& x, - const iterator_adaptor& y) { - return x.policies().less(y.iter(), x.iter()); -} - -template -inline bool -operator>=(const iterator_adaptor& x, const iterator_adaptor& y) { - return !x.policies().less(x.iter(), y.iter()); -} - -template -inline bool -operator<=(const iterator_adaptor& x, - const iterator_adaptor& y) { - return !x.policies().less(y.iter(), x.iter()); -} - -template -inline bool -operator!=(const iterator_adaptor& x, - const iterator_adaptor& y) { - return !x.policies().equal(x.iter(), y.iter()); -} -#endif - -//============================================================================= -// iterator_adaptors - A type generator that simplifies creating -// mutable/const pairs of iterator adaptors. - -template , - class ConstTraits = std::iterator_traits, -#endif - class Policies = default_iterator_policies> -class iterator_adaptors -{ -public: - typedef iterator_adaptor iterator; - typedef iterator_adaptor - const_iterator; -}; - - -//============================================================================= -// Transform Iterator Adaptor -// -// Upon deference, apply some unary function object and return the -// result by value. - -template -struct transform_iterator_policies : public default_iterator_policies -{ - transform_iterator_policies() { } - transform_iterator_policies(const AdaptableUnaryFunction& f) : m_f(f) { } - - template - Reference dereference(type, const Iterator& iter) const - { return m_f(*iter); } - - AdaptableUnaryFunction m_f; -}; - -template -struct transform_iterator_traits { - typedef typename AdaptableUnaryFunction::result_type value_type; - typedef value_type reference; - typedef value_type* pointer; - typedef typename IteratorTraits::difference_type difference_type; - typedef typename IteratorTraits::iterator_category iterator_category; -}; - -template -#else - class Traits -#endif - > -struct transform_iterator -{ - typedef transform_iterator_traits - TransTraits; - typedef iterator_adaptor, TransTraits> - type; -}; - - -//============================================================================= -// Indirect Iterators Adaptor - -// Given a pointer to pointers (or iterator to iterators), -// apply a double dereference inside operator*(). -// -// We use the term "outer" to refer to the first level iterator type -// and "inner" to refer to the second level iterator type. For -// example, given T**, T* is the inner iterator type and T** is the -// outer iterator type. Also, const T* would be the const inner -// iterator. - -// We tried to implement this with transform_iterator, but that required -// using boost::remove_ref, which is not compiler portable. - -struct indirect_iterator_policies : public default_iterator_policies -{ - template - Reference dereference(type, const Iterator& x) const - { return **x; } -}; - -template , - class InnerTraits = std::iterator_traits -#endif - > -struct indirect_traits -{ - typedef typename OuterTraits::difference_type difference_type; - typedef typename InnerTraits::value_type value_type; - typedef typename InnerTraits::pointer pointer; - typedef typename InnerTraits::reference reference; - typedef typename OuterTraits::iterator_category iterator_category; -}; - -template mutable indirect iterator - // Immutable -> immutable indirect iterator -#ifdef BOOST_NO_STD_ITERATOR_TRAITS - class OuterTraits, - class InnerTraits -#else - class OuterTraits = std::iterator_traits, - class InnerTraits = std::iterator_traits -#endif - > -struct indirect_iterator -{ - typedef iterator_adaptor - > type; -}; - -template , - class InnerTraits = std::iterator_traits, - class ConstInnerTraits = std::iterator_traits -#endif - > -struct indirect_iterators -{ - typedef iterator_adaptors, - indirect_traits, - indirect_iterator_policies - > Adaptors; - typedef typename Adaptors::iterator iterator; - typedef typename Adaptors::const_iterator const_iterator; -}; - - -//============================================================================= -// Reverse Iterators Adaptor - -struct reverse_iterator_policies -{ - template - Reference dereference(type, const Iterator& x) const - { return *boost::prior(x); } - - template - void increment(Iterator& x) const - { --x; } - - template - void decrement(Iterator& x) const - { ++x; } - - template - void advance(Iterator& x, DifferenceType n) const - { x -= n; } - - template - Difference distance(type, const Iterator1& x, - const Iterator2& y) const - { return x - y; } - - template - bool equal(const Iterator1& x, const Iterator2& y) const - { return x == y; } - - template - bool less(const Iterator1& x, const Iterator2& y) const - { return y < x; } -}; - -template -#else - class Traits -#endif - > -struct reverse_iterator -{ - typedef iterator_adaptor type; -}; - -template -#else - class ConstTraits -#endif - > -struct const_reverse_iterator -{ - typedef iterator_adaptor type; -}; - -template , - class ConstTraits = std::iterator_traits -#else - class Traits, - class ConstTraits -#endif - > -struct reverse_iterators -{ - typedef iterator_adaptors Adaptor; - typedef typename Adaptor::iterator iterator; - typedef typename Adaptor::const_iterator const_iterator; -}; - -//============================================================================= -// Projection Iterators Adaptor - -template -struct projection_iterator_policies : public default_iterator_policies -{ - projection_iterator_policies() { } - projection_iterator_policies(const AdaptableUnaryFunction& f) : m_f(f) { } - - template - Reference dereference (type, Iterator const& iter) const { - return m_f(*iter); - } - - AdaptableUnaryFunction m_f; -}; - -template -struct projection_iterator_traits { - typedef typename AdaptableUnaryFunction::result_type value_type; - typedef value_type& reference; - typedef value_type* pointer; - typedef typename Traits::difference_type difference_type; - typedef typename Traits::iterator_category iterator_category; -}; - -template -struct const_projection_iterator_traits { - typedef typename AdaptableUnaryFunction::result_type value_type; - typedef value_type const& reference; - typedef value_type const* pointer; - typedef typename Traits::difference_type difference_type; - typedef typename Traits::iterator_category iterator_category; -}; - -template -#else - class Traits -#endif - > -struct projection_iterator { - typedef projection_iterator_traits - Projection_Traits; - typedef iterator_adaptor, - Projection_Traits> type; -}; - -template -#else - class Traits -#endif - > -struct const_projection_iterator { - typedef const_projection_iterator_traits Projection_Traits; - typedef iterator_adaptor, - Projection_Traits> type; -}; - -template , - class ConstTraits = std::iterator_traits -#else - class Traits, - class ConstTraits -#endif - > -struct projection_iterators { - typedef projection_iterator_traits - Projection_Traits; - typedef const_projection_iterator_traits Const_Projection_Traits; - typedef iterator_adaptors > Adaptors; - typedef typename Adaptors::iterator iterator; - typedef typename Adaptors::const_iterator const_iterator; -}; - -} // namespace boost - -#endif - - - diff --git a/include/boost/pending/iterator_tests.hpp b/include/boost/pending/iterator_tests.hpp deleted file mode 100644 index 15a5ec4..0000000 --- a/include/boost/pending/iterator_tests.hpp +++ /dev/null @@ -1,173 +0,0 @@ -#ifndef BOOST_ITERATOR_TESTS_HPP -#define BOOST_ITERATOR_TESTS_HPP - -// This is meant to be the beginnings of a comprehensive, generic -// test suite for STL concepts such as iterators and containers. - -#include -#include - -namespace boost { - - // use this for the value type -struct dummyT { - dummyT() { } - dummyT(int x) : m_x(x) { } - int foo() const { return m_x; } - bool operator==(const dummyT& d) const { return m_x == d.m_x; } - int m_x; -}; - - -// Tests whether type Iterator satisfies the requirements for a -// TrivialIterator. -// Preconditions: i != j, *i == val -template -void trivial_iterator_test(const Iterator i, const Iterator j, T val) -{ - Iterator k; - assert(i == i); - assert(j == j); - assert(i != j); -#ifdef BOOST_NO_STD_ITERATOR_TRAITS - T v = *i; -#else - typename std::iterator_traits::value_type v = *i; -#endif - assert(v == val); -#if 0 - // hmm, this will give a warning for transform_iterator... perhaps - // this should be separated out into a stand-alone test since there - // are several situations where it can't be used, like for - // integer_range::iterator. - assert(v == i->foo()); -#endif - k = i; - assert(k == k); - assert(k == i); - assert(k != j); - assert(*k == val); -} - - -// Preconditions: i != j -template -void mutable_trivial_iterator_test(const Iterator i, const Iterator j, T val) -{ - *i = val; - trivial_iterator_test(i, j, val); -} - - -// Preconditions: *i == v1, *++i == v2 -template -void input_iterator_test(Iterator i, T v1, T v2) -{ - Iterator i1 = i, i2 = i; - - assert(i == i1++); - assert(i != ++i2); - - trivial_iterator_test(i, i1, v1); - trivial_iterator_test(i, i2, v1); - - ++i; - assert(i == i1); - assert(i == i2); - ++i1; - ++i2; - - trivial_iterator_test(i, i1, v2); - trivial_iterator_test(i, i2, v2); -} - -// how to test output iterator? - -template -void forward_iterator_test(Iterator i, T v1, T v2) -{ - input_iterator_test(i, v1, v2); -} - -// Preconditions: *i == v1, *++i == v2 -template -void bidirectional_iterator_test(Iterator i, T v1, T v2) -{ - input_iterator_test(i, v1, v2); - ++i; - - Iterator i1 = i, i2 = i; - - assert(i == i1--); - assert(i != --i2); - - trivial_iterator_test(i, i1, v2); - trivial_iterator_test(i, i2, v2); - - --i; - assert(i == i1); - assert(i == i2); - --i1; - --i2; - - trivial_iterator_test(i, i1, v1); - trivial_iterator_test(i, i2, v1); -} - -// mutable_bidirectional_iterator_test - -// Preconditions: [i,i+N) is a valid range -template -void random_access_iterator_test(Iterator i, int N, TrueVals vals) -{ - bidirectional_iterator_test(i, vals[0], vals[1]); - const Iterator j = i; - int c; - - for (c = 0; c < N-1; ++c) { - assert(i == j + c); - assert(*i == vals[c]); - assert(*i == j[c]); - assert(*i == *(j + c)); - assert(*i == *(c + j)); - ++i; - assert(i > j); - assert(i >= j); - assert(j <= i); - assert(j < i); - } - - Iterator k = j + N - 1; - for (c = 0; c < N-1; ++c) { - assert(i == k - c); - assert(*i == vals[N - 1 - c]); - assert(*i == j[N - 1 - c]); - Iterator q = k - c; - assert(*i == *q); - assert(i > j); - assert(i >= j); - assert(j <= i); - assert(j < i); - --i; - } -} - -// Precondition: i != j -template -void const_nonconst_iterator_test(Iterator i, ConstIterator j) -{ - assert(i != j); - assert(j != i); - - ConstIterator k(i); - assert(k == i); - assert(i == k); - - k = i; - assert(k == i); - assert(i == k); -} - -} // namespace boost - -#endif // BOOST_ITERATOR_TESTS_HPP