Boost logo

Boost Users :

From: Eric Niebler (eric_at_[hidden])
Date: 2007-05-24 15:31:22


Daniel Gehriger wrote:
> My I suggest an addition to BOOST_FOREACH ?
>
> I happen to work with custom containers whose iterators are invalidated when
> certain member functions are called on the contained objects. So I typically
> use a loop pattern as follows:
>
> -------------------
> for (Coll::iterator it = col.begin(); it != col.end(); /* noop */)
> {
> Coll::value_type& o = *(it++);
> o.destroy();
> }

Are you saying that calling o.destroy() causes "it" to be invalidated?
This is bad practice. If that's not the case, then vanilla FOREACH
should meet your needs. Please correct me if I've misunderstood your
situation.

-- 
Eric Niebler
Boost Consulting
www.boost-consulting.com

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net