Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2003-05-11 12:47:00

Sylvain Pion <Sylvain.Pion_at_[hidden]> writes:

> Dave, Jeremy, and Thomas,
> I have a suggestion for another "orthogonal" feature of iterators, which
> is available for plain pointers : NULL.
> More precisely, the fact that the default initialized iterator is a unique
> (singular) value which you can reliably test equality with.
> It is very useful to have this capability : in the CGAL library, we store
> the nodes of a graph in containers. Graphs are a bunch of nodes storing
> pointers/iterators to each other. Having a value like NULL is very useful
> there, because the alternative is either to allocate a specific object whose
> iterator you use for this purpose (but it requires access to the associated
> container to test with, which is painful), or storing a bool, which is a waste
> of memory.
> I don't know if these issues arise in the BGL as well.
> I think this feature doesn't make sense for all iterators, especially for Input
> and Output iterators. However, for iterators connected with containers, they
> are usually trivial to provide because the iterator usually stores a pointer,
> which can then be default initialized to NULL.
> In the case of CGAL, it would simply allow us to re-use the standard containers
> for storing our graphs, while right now we re-implement containers...

What, specifically, would allow you to re-use the standard
containers? I'm looking for a statement along the lines of, "if ...
then we could re-use the standard containers".

I'm guessing "..." is something like, "if default-constructed standard
container iterators were non-singular and guaranteed to be unequal to
any iterator obtained by other means".

> Another feature (less important but connected to the previous one) that
> pointers have and iterators don't : automatic conversion to bool.
> What do you think ?

It sounds like a useful concept, if I've understood you correctly.

At the same time, I doubt it belongs in our proposal: we don't say
anything about containers (except vector<bool>, and then only in the
rationale). You should write a proposal for extension and submit it
to the commitee if you care about this. It should be easy, compared
to the iterator adaptors/categories proposal.

Dave Abrahams
Boost Consulting

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