Boost logo

Boost Users :

From: Marshall Clow (marshall_at_[hidden])
Date: 2002-06-05 20:21:25

>"Marshall Clow" <marshall_at_[hidden]> wrote in message
>> At 10:02 PM -0700 6/3/02, Duane Murphy wrote:
>> >The canonical example is a file iterator; iterate over the files in a
>> >directory. The directory appears to be a container with filenames as the
>> >members of the container.
>> I have gone back to this example several times in the last few years.
> > I have finally decided that this is a bad idea, because a file system directory
> > is not really a container. The container can be changed outside the currently
>> executing program, and there is no "container-like" semantics to tell the
> > program that the iterators into that container are invalid.
>Except in some implementations' debug mode, none of the standard containers
>tell the program when their iterators become invalid either.

Yes, the container's iterators are under your control.

You can ensure that the iterators stay valid by not changing the container.
(or by making only 'safe' changes).
[ Multi-threaded programs are more complicated, but can be solved, too ]

You cannot get any such guarantees for a directory.

-- Marshall
Marshall Clow     Idio Software   <mailto:marshall_at_[hidden]>
My name is Bobba Fett. You killed my father, prepare to die!

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at