Boost logo

Boost :

From: Daryle Walker (darylew_at_[hidden])
Date: 2001-09-07 10:50:09


on 9/6/01 9:24 AM, Darin Adler at darin_at_[hidden] wrote:

> on 9/4/01 2:17 PM, darylew_at_[hidden] at darylew_at_[hidden] wrote:
>
>> I'm trying to use reverse iterators for a bitset iterator class I wrote. The
>> problem is that my attempts choke on the use of the rbegin reverse iterator,
>> which corresponds to the end regular iterator. The off-by-1 effect I've read
>> about doesn't happen and the reverse iterator tries to dereference past the
>> bitset. What's wrong?
>
> There's no reverse iterator issue here. There's just a cut and paste mistake
> in your test program. I hope you tried to use the debugger before posting to
> Boost -- the problem was obvious to me with a few moments of debugging.

I did use the debugger, but I still overlooked the problem until I reviewed
the code for another reason. The newest version (1) has the fix.

> This line
>
> BOOST_TEST( *t1.first == bs[i - 1] );
>
> needs to be
>
> BOOST_TEST( *t2.first == bs[i - 1] );
>
> otherwise you dereference the end() value from the forward iterator test.

-- 
Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT mac DOT com

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