This is the Range class :
template <typename T>
class Range
{
public:
class iterator;
Range(T low, T high) : low_(low), high_(high)
{
}
const iterator begin() const
{
return iterator(low_);
}
const iterator end() const
{
return iterator(high_);
}
};
Which king of iterator (forward, random, input) is the best to choose ?
You can provide any type of iterator, including if you wish a random iterator, as long as you do not allow modification of the iterator state from
operator*oroperator->. That is, if you are keeping the count in the iterator, thenoperator*should return aT(value) andoperator->aT const *, so that the iteration cannot be modified through these operators.