Boost logo

Boost :

Subject: Re: [boost] [range] fat iterators?
From: Evgeny Panasyuk (evgeny.panasyuk_at_[hidden])
Date: 2013-11-12 11:21:11


12.11.2013 19:41, Eric Niebler:
> I've now built a filter_range, transform_range, and an istream_range in
> this vein. Initial results are looking promising, but I haven't
> benchmarked performance, yet. A commenter on my blog claims to have
> benchmarked perf of istream_range, with good results, which is encouraging.

While new "slim" istream_range is faster than version with "fat"
iterators, it is still not the fastest possible.
In particular, it does two comparisons per cycle iteration: one is
"!rng_->next()", and another is comparison of iterators, like "it != last".
But it is possible to do only one comparison per iteration, like
http://coliru.stacked-crooked.com/a/b0a989aa0b2e9741 :

while(!empty(it))
{
     cout << *it << " ";
     ++it;
}

We can have new fast algorithms for such iterators. Such iterators are
not replacement of STL iterators, but complementary. It is OK to have
different iterators and different algorithms for different kinds of
things - http://www.youtube.com/watch?v=COuHLky7E2Q&amp;t=42m18s .
Plus, when backward compatibility matters - we can use adaptors like you
showed.

-- 
Evgeny Panasyuk

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