diff --git a/include/boost/pending/iterator_adaptors.hpp b/include/boost/pending/iterator_adaptors.hpp index a267636..7b5c6c4 100644 --- a/include/boost/pending/iterator_adaptors.hpp +++ b/include/boost/pending/iterator_adaptors.hpp @@ -16,6 +16,7 @@ #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 @@ -31,6 +32,86 @@ namespace boost { 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); + } + Policies p; + Adapted x; + mutable bool b; +}; + +template +struct ForwardIteratorPoliciesConcept +{ + void constraints() { + function_requires< + TrivialIteratorPoliciesConcept + >(); + + p.increment(x); + } + Policies p; + Adapted x; +}; + +template +struct BidirectionalIteratorPoliciesConcept +{ + void constraints() { + function_requires< + ForwardIteratorPoliciesConcept + >(); + + p.decrement(x); + } + Policies p; + Adapted x; +}; + +template +struct RandomAccessIteratorPoliciesConcept +{ + typedef typename Traits::difference_type DifferenceType; + void constraints() { + function_requires< + BidirectionalIteratorPoliciesConcept + >(); + + p.advance(x, n); + const_constraints(); + } + 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.