Boost logo

Boost :

From: rogeeff (rogeeff_at_[hidden])
Date: 2001-12-14 01:19:01


--- In boost_at_y..., Jeremy Siek <jsiek_at_c...> wrote:
> Hi Gennadiy,
>
> On 12/14/01 12:46 AM, "rogeeff" <rogeeff_at_m...> wrote:
>
> > Hi,
> >
> > I have a question about iterator_adaptor. The iterator_adaptor
seems
> > to assume that Policies are stateless. For example, it never copy
> > them in copy constructor and iterator. Why it was designed that
way?
>
> Sure it does. The m_iter_p member gets copied, and the policies
object
> Is inside m_iter_p, so it gets copied.

Oops. Sorry.

>
> > Another related questions:
> > Why does not iterator_adapter has a copy_constructor/assignment
> > accepting Base iterator?
>
> There is a constructor that accepts the Base iterator, though of
course it
> is not technically a copy constructor.
>
> As for the assignment operator... I guess we didn't see a real need
for it.
> Do you see a real need for it?

Rationale for my questions is performance considerations. Let say I
need to process input stream ~ 20000 times per second. I have
iterator over this stream which is implemented using iterator_adaptor
over light weight Base iterator and statefull Policies ( meaning that
copy constructor for the
m could be expensive). I have at least 2 choises: Instantiate my
iterator every time (in which case I would like to prevent Policies
from copying) or I can instantiate it once and than reset every time
with new Base iterator (plus Policies initialize call). Any other
variants?

>
> > Why does not iterator_adapter has a constructor accepting some
> > argument to be passed to policy constructor?
>

> This was considered, but we felt that would complicate things. And
you can
> just create a make_xxx_iterator function that hides the
complication of
> creating the policy object explicitly.

make_xxx_iterator function would not prevent Policies copying.

[SNIP]

>
> Cheers,
> Jeremy
>
> --
> Jeremy Siek http://www.osl.iu.edu/~jsiek
> Ph.D. Student, Indiana Univ. B'ton email: jsiek_at_o...
> C++ Booster (http://www.boost.org) office phone: (812) 855-3608

Gennadiy.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk