|
Boost Users : |
From: dave_abrahams (david.abrahams_at_[hidden])
Date: 2002-01-13 22:40:11
--- In Boost-Users_at_y..., Duane Murphy <duanemurphy_at_m...> wrote:
> I have now built a couple of iterators using
boost::iterator_adaptor.
> These are not adapted iterators but rather iterators developed to
iterate
> over interfaces that have not iterators.
>
> I havent found a good example of how to declare the equivalent of a
> const_iterator like in vector. What would the declartion look like?
>
> If the definition of an iterator is:
>
> typedef boost::iterator_adaptor< Base, Policy > iterator;
>
> What would the declartion for a const_iterator look like?
depending on your compiler and requirements, it might look like:
boost::iterator_adaptor<Base
, Policy, std::iterator_traits<Base>::value_type const>
const_iterator;
The library is full of iterator pair generators which generate a
const/mutable iterator pair. You could look at those for examples.
This paper http://www.boost.org/libs/utility/iterator_adaptors.pdf is
also helpful in understanding how a constant iterator should be
declared.
-Dave
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net