Boost logo

Boost Users :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2004-11-29 07:14:14


Hi Sebastian,

> Hi folks!
>
> I got a cyclic type-dependency problem. I am trying to let every vertex
> store a iterator to a list which stores vertex-iterators. This sounds
> weired, but I need to keep track of very few vertices within my graph
> which have a particle located at it. Thus I created a list of
> vertex-iterators who carry my particle positions in the graph. In order
> to be able to tell quickly if a vertice is taken by a particle I want
> each vertice to include a pointer to a null element representing the
> absence of a particle or a pointer into that list. My non-working code
> looks like:
>
> Definition of my graph:
>
> struct Spot {
> // acutally I need the vertex_iterator to be defined already
> // in order to define particle, but this is not yet defined
> // so I am using the knowledge that it is going to be represented
> // by a vector<std::size_t>::iterator (at least I hope so)
> // this assumption is WRONG!!
> typedef std::list< std::vector<std::size_t>::iterator >::iterator \\

There are two approaches.

1. Use pimpl or incomplete type to postpone defining the property type until
you know the iterator type.

  struct Spot;
  typedef boost::adjacency_list<boost::vecS, boost::vecS, \\
  boost::undirectedS, Spot* > graph_t;

  struct Spot { ............. } ;

2. Don't bother with iterators, store vector<unsigned> inside the Spot
class. For VecS/VecS graph, using unsigned to identify vertices should be
OK.

BTW, I'm not sure why your code does not work. It should work, maybe after
changing size_t to int -- don't remember if vertex_descrption is signed or
not.

- Volodya


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net