$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Damien Fisher (damien_at_[hidden])
Date: 2002-06-12 22:58:10
On Wed, 12 Jun 2002, David Abrahams wrote:
> > I think this is a good argument in favor of dyn_bitset, and for providing
> > iterators. I haven't looked at it closely, but can we provide an iterator
> > for dyn_bitset that meets all the requirements for STL iterators?
>
> Actually you can. There are two ways:
>
> 1. the iterator is an input iterator but not a forward iterator
> 2. The iterator is a random access iterator that internally stores a copy
> of the bool lvalue you would get by dereferencing it.
How would this work? (I don't know what the semantics are for
dyn_bitset, but I think this code is understandable)
dyn_bitset bs(6); // create bitset of size 6
bs[5] = 0; // set 6th bit to 0
dyn_bitset::iterator itr1 = bs[5];
dyn_bitset::iterator itr2 = bs[5];
*itr1 = 1; // saves 1 in the iterator
*itr2 = 0; // saves 0 in the iterator
// itr2 destroyed -- writes 0 to the bitset
// itr1 destroyed -- writes 1 to the bitset
If the iterator writes the values back upon destruction, then the value
of bs[5] here will be 1, not 0. This strikes me as really
weird...surely this isn't standards conforming???