David Abrahams wrote:
Louis Lavery
writes: I'm looking for a transforming iterator. I've looked at the [snip] Hmm, so my question now is - is there some reason why the base iterator is dereferenced before being passed to the function? Wouldn't it be better to let the function decide that?
Not if nearly every use of the thing would have to add a dereference operation. That would make many uses terribly inconvenient, and some impossible (i.e. if you only want to build the function object in place using Boost.Bind or the standard binders instead of Boost.Lambda).
Yes, in the short time between my post and receiving your reply the idea had already begun to putrefy. I went back and reviewed the boost iterators, yet again, and immediately dismissed counting_iterator, yet again, as that just counts, dunnit?
It seems to me all you really need to do is use transform_iterator over counting_iterator.
Kick ouch! Kick ouch! Kick ouch! counting_iterator enumerates the values of
your underlying iterator, and transform_iterator operates on those values. Please let me know if you can't get that to work.
If I can't do that then I should be writing microcode for waffle irons and toaster ovens and not dabbling in C++ :o) Thanks a lot, that's the neat soloution I was after, Louis. -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.322 / Virus Database: 266.11.15 - Release Date: 22/05/2005