|
Boost Users : |
From: Michael Linck (mgl_at_[hidden])
Date: 2007-11-09 18:27:53
> The question is: I want to have an iterator of a std::list type
> that denotes a NULL iterator, which means the iterator points to
> nothing, and is obviously different from list::end(), which points
> to the pass-the-end of a list.
I can only think of two possible uses for this (you didn't explicitly
mention one) and I don't think either of them should pass any code
review. The first one because it doesn't require a special iterator,
and the second one because it's *dangerous*.
The first one is to see whether and entry in a container is null. This
should not require a separate iterator (more work than necessary.) It
should merely require that the container be a container of pointers and
a check for the value of the stored pointers.
The second reason is that you're attempting to erase entries in a
container without shrinking/growing the container. In other words,
using an inappropriate container as an object pool. All I can say to
that is "don't" because this is eradicates all the benefits of using
standard containers. If you're having performance problems, think about
changing what type of container you're using instead.
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