
On Sun, Feb 24, 2013 at 1:07 PM, Christian Henning <chhenning@gmail.com>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