Worked around issue with using iterators in device code.