fix non-modifying algorithm: for InputIterator Requirements