Boost logo

Boost :

From: David Abrahams (david.abrahams_at_[hidden])
Date: 2001-07-11 20:03:11


Ulli,

I just don't see it. Remember that erasing an element of the vector
invalidates all following iterators. Maybe you have something in mind that
you haven't explained?

-Dave

----- Original Message -----
From: "Ullrich Koethe" <u.koethe_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Wednesday, July 11, 2001 4:18 PM
Subject: Re: [boost] challenge: stable_vector

> David Abrahams wrote:
> >
> > Doesn't work, I think:
> >
> > template <class Container, class Iterator>
> > void test_stability(Container& c, Iterator x)
> > {
> > Iterator y = x;
> > ++y;
> > std::iterator_traits<Iterator>::pointer p = &*y;
> > std::iterator_traits<Iterator>::value_type v = *y;
> > c.erase(x);
> > assert(p == &*y); // test pointer and iterator stability
> > }
> >
>
> Too bad. But it could be repaired if the vector actually stored
> "pair<key,value>*". The additional indirection could be hidden in the
> access functions. Of course, performance will suffer.
>
> On the other hand,
>
> assert(v.first == (*y).first);
> assert(v.second == (*y).second);
>
> would work, and I regard this as the more important requirement. If the
> mapped object were stored by pointer, even
>
> assert(&v.second == &(*y).second);
>
> would work. I regard the pair stored in a map as as helper object whose
> identity is of no interest.
>
> Ulli
> --
> ________________________________________________________________
> | |
> | Ullrich Koethe Universität Hamburg / University of Hamburg |
> | FB Informatik / Dept. of Computer Science |
> | AB Kognitive Systeme / Cognitive Systems Group |
> | |
> | Phone: +49 (0)40 42883-2573 Vogt-Koelln-Str. 30 |
> | Fax: +49 (0)40 42883-2572 D - 22527 Hamburg |
> | Email: u.koethe_at_[hidden] Germany |
> | koethe_at_[hidden] |
> | WWW: http://kogs-www.informatik.uni-hamburg.de/~koethe/ |
> |________________________________________________________________|
>
> Info: http://www.boost.org Unsubscribe:
<mailto:boost-unsubscribe_at_[hidden]>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>


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