Listing 2: <iterator>, part 6


        // TEMPLATE CLASS reverse_bidirectional_iterator
template<class BidIt, class T, class Ref = T&,
    class Ptr = T *, class Dist = ptrdiff_t>
    class reverse_bidirectional_iterator
        : public bidirectional_iterator<T, Dist> {
public:
    typedef reverse_bidirectional_iterator<BidIt,
        T, Ref, Ptr, Dist> Mytype;
    reverse_bidirectional_iterator()
        {}
    explicit reverse_bidirectional_iterator(BidIt x)
        : current(x) {}
    BidIt base() const
        {return (current); }
    Ref operator*() const
        {BidIt tmp = current;
        return (*--tmp); }
    Ptr operator->() const
        {return (&**this); }
    Mytype& operator++()
        {--current;
        return (*this); }
    Mytype operator++(int)
        {Mytype tmp = *this;
        --current;
        return (tmp); }
    Mytype& operator--()
        {++current;
        return (*this); }
    Mytype operator--(int)
        {Mytype tmp = *this;
        ++current;
        return (tmp); }
protected:
    BidIt current;
    };

        // reverse_bidirectional_iterator OPERATORS
template<class BidIt, class T, class Ref, class Ptr,
    class Dist> inline
    bool operator==(const reverse_bidirectional_iterator<BidIt,
            T, Ref, Ptr, Dist>& x,
        const reverse_bidirectional_iterator<BidIt,
            T, Ref, Ptr, Dist>& y)
    {return (x.base() == y.base()); }
/* End of File */