Boost logo

Boost :

Subject: Re: [boost] [gil::io] Feedback for scanline_read_iterator
From: Jeffrey Lee Hellrung, Jr. (jeffrey.hellrung_at_[hidden])
Date: 2013-02-24 20:01:26


On Sun, Feb 24, 2013 at 1:07 PM, Christian Henning <chhenning_at_[hidden]>wrote:

> Hi Michael,
>
> >> I moved the buffer creation internally.
> >>
> >
> > I think this might be even worse unfortunately, if the iterator is
> copied, such
> > as with (*i++) it's going to make a full copy of the buffer. Now that
> readers
> > have a begin and end maybe the reader could own the buffer?
>
> I see two ways, apart from moving the buffer into the reader. I could
> use a shared ptr or the user has to pass the buffer into the
> constructor. I lean towards the shared pointer. Do you have an
> opinion?
>

Does that mean all copies of an iterator share the same buffer? Won't that
screw things up if iterators which share the same buffer are dereferenced
from different positions in the image?

Sounds like the thing to do is to create the buffer on-demand upon
dereferencing (and retain it for further dereferences until the iterator is
destroyed), and when an iterator is copied, the buffer isn't.

Or, maybe having a shared buffer is okay if your iterators are only
advertised as input iterators or (equivalently, I think) readable +
incrementable.

- Jeff

- Jeff


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