class const_iterator
: public _Ranit<_Ty, _Dift, _Ctptr, const_reference>
{ // iterator for nonmutable vector
public:
typedef random_access_iterator_tag iterator_category;
typedef _Ty value_type;
typedef _Dift difference_type;
typedef _Ctptr pointer;
typedef const_reference reference;
const_iterator()
{ // construct with null pointer
_Myptr = 0;
}
const_iterator(_Tptr _Ptr)
{ // construct with pointer _Ptr
_Myptr = _Ptr;
}
const_reference operator*() const
{ // return designated object
return (*_Myptr);
}
_Ctptr operator->() const
{ // return pointer to class object
return (&**this);
}
const_iterator& operator++()
{ // preincrement
++_Myptr;
return (*this);
}
const_iterator operator++(int)
{ // postincrement
const_iterator _Tmp = *this;
++*this;
return (_Tmp);
}
const_iterator& operator--()
{ // predecrement
--_Myptr;
return (*this);
}
const_iterator operator--(int)
{ // postdecrement
const_iterator _Tmp = *this;
--*this;
return (_Tmp);
}
const_iterator& operator+=(difference_type _Off)
{ // increment by integer
_Myptr += _Off;
return (*this);
}
const_iterator operator+(difference_type _Off) const
{ // return this + integer
const_iterator _Tmp = *this;
return (_Tmp += _Off);
}
const_iterator& operator-=(difference_type _Off)
{ // decrement by integer
return (*this += -_Off);
}
const_iterator operator-(difference_type _Off) const
{ // return this - integer
const_iterator _Tmp = *this;
return (_Tmp -= _Off);
}
difference_type operator-(const const_iterator& _Right) const
{ // return difference of iterators
return (_Myptr - _Right._Myptr);
}
const_reference operator[](difference_type _Off) const
{ // subscript
return (*(*this + _Off));
}
bool operator==(const const_iterator& _Right) const
{ // test for iterator equality
return (_Myptr == _Right._Myptr);
}
bool operator!=(const const_iterator& _Right) const
{ // test for iterator inequality
return (!(*this == _Right));
}
bool operator<(const const_iterator& _Right) const
{ // test if this < _Right
return (_Myptr < _Right._Myptr);
}
bool operator>(const const_iterator& _Right) const
{ // test if this > _Right
return (_Right < *this);
}
bool operator<=(const const_iterator& _Right) const
{ // test if this <= _Right
return (!(_Right < *this));
}
bool operator>=(const const_iterator& _Right) const
{ // test if this >= _Right
return (!(*this < _Right));
}
friend const_iterator operator+(difference_type _Off,
const const_iterator& _Right)
{ // return iterator + integer
return (_Right + _Off);
}
_Tptr _Myptr; // offset of element in vector
};
// CLASS iterator