Boost logo

Boost Users :

Subject: Re: [Boost-users] iterator_adaptor usage question
From: Dave Abrahams (dave_at_[hidden])
Date: 2012-03-14 23:23:38

on Sun Mar 11 2012, "Jeffrey Lee Hellrung, Jr." <> wrote:

> On Sun, Mar 11, 2012 at 8:27 PM, John M. Dlugosz <mpbecey7gu_at_[hidden]> wrote:
> What is a good way to create both an iterator and a const iterator while only having to specify all my custom behavior once?
> Maybe template your iterator on the base iterator, and dispatching when necessary depending on whether that base iterator is the
> const iterator or the mutable iterator? E.g.,
> template< class Base >
> struct my_iterator
>     : boost::iterator_adaptor< Base >
> { };
> typedef my_iterator< base_iterator > iterator;
> typedef my_iterator< base_const_iterator > const_iterator;
shows how to do it with iterator_facade, and
extends that to iterator_adaptor


Dave Abrahams
BoostPro Computing

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at