Default constructed iterators as past-the-end iterators

Starting from C++14 we have that: A value-initialized ForwardIterator behaves like the past-the-end iterator of some unspecified empty container: it compares equal to all value-initialized ForwardIterators of the same type. This answer on SO explains this well: Forward iterators and stronger are generally just a lightweight handle onto something…

Delimited ranges

Phenomenal article by Eric Niebler. Lately, I had to write a similar iterator and I was at first puzzled by the need of taking into account for the sentinel.…

Why is *it++ valid for output iterators?

Given an output iterator it, the expression *it++ makes a copy of it, increments it, and then returns the copy which is finally dereferenced The important notions needed to understand are as follows: The standard requires that *it++ = t work for output iterators Output iterators are single pass iterators, which…

counting_range vs irange

The main difference is that irange is a random-access range while counting_range isn't. counting_range is based on Boost.Iterator's counting_iterator which uses all the underlying integers operations directly. Integers in C++ almost fit the iterator concept: the only thing missing is an operator*. counting_iterator provides an…