From: Sylvain Pion (Sylvain.Pion_at_[hidden])
Date: 2003-05-11 05:25:27
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
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...
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 ?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk