Boost logo

Boost :

From: Robert Ramey (ramey_at_[hidden])
Date: 2004-01-31 16:26:12

I have a problem with the latest version of the new iterators.
This is illustrated in the following example.

#include <strstream>
#include <iterator>
#include <boost/iterator/counting_iterator.hpp>

        std::istrstream is("abcdefg");
        typedef boost::counting_iterator<std::istream_iterator<char> > ci;
        const ci end = std::istream_iterator<char>(); // note the const !!!
        ci begin = std::istream_iterator<char>(is);

        unsigned int size;

        // the following should fail at compilation ?
        // in fact it compiles are returns a value of -7 !!!
        size = begin - end;

        // the following should compile and return a value of 7
        // in fact, it compiles but goes into an infinite loop
        size = end - begin;

Note that this problem did not appear with the first release candidate.

Also, if one follows the links from the main documentation page, one is directed
to the documentation of the old iterators. This is extremely confusing. This has
been pointed out before.

This above example is using 1.31. "release candidate" #2 compiled with VC 7.0

Robert Ramey

Boost list run by bdawes at, gregod at, cpdaniel at, john at