Support for input iterators

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