> > 1. Line 51 of test085.cxx, I had to change from:
> >
> >   for (ITER arg = --patend; i > 0; --arg, --i)
> >   {
> >    ...
> >   }
> >
> > to:
> >
> >   for (ITER arg = patend; i > 0; --i)
> >   {
> >    --arg;
> >    ...
> >   }
> 
> Why is that?  There shouldn't be any problem here--if there is nothing
> valid before patend then I'd expect the loop condition (i > 0) to fail
> right away, and the decrement would never be executed.  I'll make the
> change if that helps, but what's the error message here exactly?

Consider the case that patend is begin() and i=0, i>0 fails but not until arg = 
--patend is executed.
Or say initial condition is  i=0, patend is begin()+1, arg will be initialized 
to begin(), after first iteration, the loop will try to execute --arg, --i 
which is also not allowed in VC++8.

> 
> 
> > 2. Line 69 of test083.cxx need to be changed from:
> >
> >     for (result::const_iterator r = R.begin(); r != R.end(); --i, ++r)
> >       ...
> >
> > to:
> >
> >  ++i;
> >  for (result::const_iterator r = R.begin(); r != R.end(); ++r) {
> >    ...
> >   }
> 
> That's a very radical change to the loop.  Are you sure there isn't some
> mistake here?  That should probably make the test fail because it will
> make the test look at different data.

Sorry, there should be a --i inside the for loop.  The reason for the change is 
the same as the first case, i.e. in the original code, --i and ++r must be 
executed together but r is allow to go past the last item whilst i is not allow 
to decrement past the first element.

> 
> > Both changes are needed to prevent a (forward) iterator from decrementing
> > past the first element.
> 
> There must be some confusion here...  If they were forward iterators, then
> they shouldn't be able to decrement at all!  There should be a
> compile-time error for that.  And I think (perhaps wrongly--it's not
> unheard of) that in the case of test085.cxx it's not possible for the
> "--patend" to go below the beginning of the sequence.  Even if it can,
> doing the initial "--arg" instead should have the exact same problem!
> 

I use the word (forward) to describe iterator(s) to make a contrast with 
reverse_iterator(s), which are allowed to move one element past the begining of 
a collection.

Cheers!

Xiaofeng
_________________________________________________________________
Search—Your way, your world, right now!
http://imagine-windowslive.com/minisites/searchlaunch/?locale=en-us&FORM=WLMTAG 
_______________________________________________
Libpqxx-general mailing list
[email protected]
http://gborg.postgresql.org/mailman/listinfo/libpqxx-general

Reply via email to