Boost logo

Boost :

From: Dietmar Kuehl (dietmar_kuehl_at_[hidden])
Date: 2000-07-04 06:53:50


Hi,
--- jsiek_at_[hidden] wrote:
> Wondering if anyone else has encountered this problem before:
>
> typedef list<B::iterator> A;
> typedef list<A::iterator> B;

In one form or another when implementing graphs: The nodes somehow
reference edges and the edges somehow reference nodes (well, at least
on node). Normally, I avoided this problem by using something different
than an iterator, ie. a pointer or an integer, for one of those.
However, normally I got the problem in form of incomplete node or edge
types:

  struct node { std::list<edge> adjacent; };
  struct edge { std::list<node>::iterator head; };

In such situations it would be desirable to have some form of forward
declarations for member classes.

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

Of course, this statement is not correct: For example, I can imagine
that the iterator type for our friend 'std::vector<bool>' is very
different from the iterator type of all other 'std::vector<T>'. Of
course, this is not specific to this particular case, just a well now
example...

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

I don't think this is a work around. I would not use it...

Regards,
  Dietmar

=====
<mailto:dietmar_kuehl_at_[hidden]>
<http://www.dietmar-kuehl.de/>

__________________________________________________
Do You Yahoo!?
Kick off your party with Yahoo! Invites.
http://invites.yahoo.com/


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