On Mon, September 25, 2006 22:00, X Z wrote:
> Consider the case that patend is begin() and i=0, i>0 fails but not until
> arg = --patend is executed.
Ah, of course. How silly of me not to see it. OTOH that shouldn't happen
anywhere in this program.
> 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.
Yes, that makes more sense. The loop condition stops that from happening
if i is zero.
>> 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.
In that case I'll just replace i with a const_reverse_iterator here.
Let's try this in test/test083.cxx, lines 69--73:
items<items<int> >::const_reverse_iterator j(++i);
for (result::const_iterator r = R.begin(); r != R.end(); ++j, ++r)
if (r->at(0).as(0) != (*j)[0])
throw logic_error("Writing numbers with tablewriter went wrong: "
"expected " + to_string((*j)[0]) + ", found " + r[0].c_str());
Does that fix the problem? With reverse_iterators there's an rend()
"before the begin()" (and an rbegin() before the end()) so that's exactly
right for this usage.
> 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.
Ah, that's clear then. Thanks for reporting all this!
Jeroen
_______________________________________________
Libpqxx-general mailing list
[email protected]
http://gborg.postgresql.org/mailman/listinfo/libpqxx-general