Boost logo

Boost :

From: John E. Potter (jpotter_at_[hidden])
Date: 2001-07-06 11:14:18


On Fri, 6 Jul 2001, David Abrahams wrote:

> But whether it increments or not is not in question.
>
> The question is, if I dereference an input iterator twice without
> intervening operations, do must I get the same result?

I understrand that. The question is about iterators. Iterators
are used in algorithms to iterate over (pseudo)sequences. For
input iterators, increment must move the iterator and dereference
must not. Dereferencing an input iterator twice must give the
same element of the (pseudo)sequence. Whether that element has
a stable value has nothing to do with the iterator.

Let's ask the same irrelevant question about random access iterator.

#include <cstdlib>
#include <iostream>
#include <vector>

struct Silly {
   operator int () { return rand(); }
   };
int main () {
   std::vector<Silly> v(5);
   for (std::vector<Silly>::iterator it = v.begin(); it != v.end(); ++ it)
      std::cout << *it << ' ' << *it << std::endl;
   }

John


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk