Boost logo

Boost :

From: Beman Dawes (bdawes_at_[hidden])
Date: 2002-02-04 17:51:52

At 09:20 AM 2/4/2002, Brey, Edward D wrote:

>I think that an auto_vector class would be a great addition to boost.
>Coincidentally, I just made an auto_vector for myself just a week
ago. It
>wasn't nearly complete enough (and in some ways possibly had too much)
>Boost, but rather just for my current project's needs. In any case, the
>concept is definitely useful.
>I can share a bit of my experience vis a vis George's suggestion
>returning references. Before I made my auto_vector, I had made an
>incantation where the iterators performed the dereference for you. That
>worked out fine until I needed to copy the pointers to another container
>(the destination container just held pointers, but didn't own any
>The problem was that I couldn't go backwards from a reference/pointer to
>iterator. At this point I decided that there wasn't enough value in
>the indirection level to be worth the trouble it causes.
>This predicament points out a general lacking in STL that I'd like to
>other's opinions of. That is the concept of transforming an iterator to

Be very careful. See library issue 198

Unless the container gives guarantees beyond those of the standard's
container and iterator requirements, you could be headed for undefined

Although some of the standard library's containers do give stronger
guarantees, in general the object an iterator points to may be cached, and
go away when the last iterator to the object goes away. Thus it is
generally unsafe to hang onto pointers or references which escape from


Boost list run by bdawes at, gregod at, cpdaniel at, john at