Ranges in C++: Counted Iterables and Efficiency -- Eric Niebler
New in Eric's series on ranges for C++:
Ranges in C++: Counted Iterables and Efficiency
by Eric Niebler
From the article:
I’ve been hard at work fleshing out my range library and writing a proposal to get range support into the standard. That proposal describes a foundational range concept: Iterable. An Iterable is anything we can pass to
std::begin()andstd::end()to get an Iterator/Sentinel pair. Sentinels, as I described here earlier this year, make it possible for the Iterable concept to efficiently describe other kinds of ranges besides iterator pairs.The three types of ranges that we would like the Iterable concept to be able to efficiently model are:
- Two iterators
- An iterator and a predicate
- An iterator and a count
The Iterator/Sentinel abstraction is what makes it possible for the algorithms to handle these three cases with uniform syntax. However, as Sean Parent pointed out here, the third option presents challenges when trying to make some algorithms optimally efficient. Back in February, when Sean offered his criticism, I promised to follow up with a blog post that justified the design. This is that post.

ACCU 2015 is now putting together its program, and they want you to speak on C++. ACCU has long had a strong C++ track, though it is not a C++-only conference. If you have something to share, check out the call for papers.
A widely-used C++ program you might never have heard of: Physicists and other scientists use the GEANT4 toolkit to identify problems before they occur.
On Sticky Bits: