In order to make it possible to iterate a range of numbers in reverse, we add the operator--() method to IntIterator and upgradeiterator_category to std::bidirectional_iterator_tag:
class IntIterator { ... using iterator_category = std::bidirectional_iterator_tag; ... auto& operator--() { --value_; return *this; } ...};
This is an example of iterating in reverse order:
for(auto it = IntIterator{12}; it != IntIterator{-1}; --it) { std::cout << *it << " ";}// Prints: 12 11 10 9 8 7 6 5 4 3 2 1 0