template<class Iterator>
class SimTK::IteratorRange< Iterator >
Helper class to use range-based for loops with a pair of iterators.
This class should only be used when you're sure the iterators are valid. Don't use this class directly; instead, use makeIteratorRange().
Here's an example of using iterators first
and last
to iterate over the range [first, last)
(that is, last
won't be reached):
std::vector<int> v {5, 10, 15, 20, 22};
auto first = std::lower_bound(v.begin(), v.end(), 10);
auto last = std::lower_bound(v.begin(), v.end(), 15);
...
}
IteratorRange< Iterator > makeIteratorRange(Iterator first, Iterator last)
Make an IteratorRange object to be used in a range-based for loop, using two iterators.
Definition: IteratorRange.h:79
You can also use this class with an std::pair of iterators, such as that returned by std::multimap::equal_range(). We assume the first iterator in the pair is the first iterator in the range, and the second iterator in the pair is the last iterator in the range.
std::multimap<std::string, int> map;
...
...
}