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...


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 ?

-- 
Sylvain
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Reply via email to