There is a problem with ranges and iterators. To work properly they must be resolved firstly, before operator rangeTo.