Boost logo

Boost :

From: jsiek_at_[hidden]
Date: 2000-07-03 17:22:53


Wondering if anyone else has encountered this problem before:

typedef list<B::iterator> A;
typedef list<A::iterator> B;

This won't compile because B::iterator is an incomplete type, and
forward declarations won't help.

However, this really *should* be possible, because the size of
the iterator object does not really depend on the value_type.

So there's this workaround I'm tempted to use:

typedef list<foo>::iterator list_iter;
typedef list<list_iter> A;
typedef list<list_iter> B;

And then cast the list_iter to the real iterator type. I think this
should be safe... anyone disagree?

Is this a common enough problem that there should be a general
solution? Somethink like a void_iterator that can do everything a
normal iterator can do, except be dereferenced (and which also can
be converted back to a non-void iterator).

Cheers,

Jeremy

P.S. This problem came up when implementing the ggcl::dynamic_graph
class. To avoid the problem I basically re-implemented std::list
inside ggcl::dynamic_graph, yuk! I'll probably switch to the above
workaround since I'd also like to be able to swap std::set for the
std::list.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk