samedi 26 juin 2021

How can I create an iterator of a range of indexes in C++11?

I'm working with an API that takes a start and end iterator, and runs async work on the objects in that range. However, in one case I want to iterate over indexes of objects, not objects (from 0 to myVector.size() - 1). I could create a simple vector of those indexes and use its .begin() and .end() iterators, but that has unacceptable performance overhead.

What's the easiest way to create two iterators, where iterating from the first one to the second takes you from 0 to N?

Aucun commentaire:

Enregistrer un commentaire