Formatting
Use boost::next to retrieve next iterator

As suggested by Dave Abrahams <dave@boostpro.com>
Support for input iterators

As suggested by Evgeny Panasyuk <evgeny.panasyuk@gmail.com>