Boost logo

Boost :

From: Stefan Slapeta (stefan_nospam__at_[hidden])
Date: 2004-07-19 17:46:31

David Abrahams wrote:

> I don't know what the original code is and I don't want to have to
> try to piece them together, so it would help if you'd just post what
> you believe to be a conforming iterator. That said...

Sorry. I'll try to give a short explanation which I hope is sufficient.

See again:

     Default constructor.

     Construct null iterator. All null iterators are equal.

     Postconditions: eof()==true

What you wanted to know is: the original code was comparing the content
of the iterators _before_ comparing the eof states, which is not correct
  (see below). That said [ ... :) ]

> This appears to be a complicated way to write:
> return eof() && Other.eof()
> || m_Match==Other.m_Match && m_End==Other.m_End;

No. Just interpret boolean expressions the way they want to talk to you
:) (rationale: see below again)

> Somehow that seems unlikely to be correct. Are m_Match and m_End
> valid when eof() is true?

They are only valid if _both_ eof()'s are false (see documentation
above)! m_Match and m_End must not be compared if _one_ of the iterators
is in eof (= past-the-end _and_ uninitialized) state.

I hope I could make it clear.


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