
22 Nov
2008
22 Nov
'08
5:20 p.m.
Scott McMurray wrote:
Also, what if I write a random_number_iterator, a forward iterator which returns a different random number after each increment? Then iterator_range<random_number_iterator>() is again non-singular, and it has an infinite size (operator== would always be false)
In that case, it might be clearer to write something like iterator_range<random_number_iterator> r(random_number_iterator(), random_number_iterator()); Here, it is explicitly initialized and thus iterator_range should know that this is not a singular range. That is quite a pain, of course.
, so the empty() for the range should *not* return false.
I'm not sure I'm following. The way you wrote it, it should abort, and the way I wrote it, it should return false.