|
Boost Users : |
Subject: Re: [Boost-users] PropertyGraphConcept concept checking errors for an example implicit graph
From: Jeremiah Willcock (jewillco_at_[hidden])
Date: 2010-07-01 00:50:39
On Tue, 29 Jun 2010, W.P. McNeill wrote:
> It looks like the adjacency_iterator created by adjacency_iterator_generator was being defined in terms of  vertex_descriptor
> and out_edge_iterator, which are in turn defined via graph_traits<>, which would cause this problem.
> I got a little closer to an ideal solution by putting
>
> Â Â Â typedef ring_adjacency_iterator adjacency_iterator;
>
> in the graph class and forward-defining ring_adjacency_iterator, then later on in implicit.hpp deriving ring_adjacency_iterator
> from boost::adjacency_iterator like so
>
> Â Â class ring_adjacency_iterator:public boost::adjacency_iterator<
> Â Â Â graph,
> Â Â Â vertex_descriptor,
> Â Â Â out_edge_iterator,
> Â Â Â boost::use_default> {
> Â Â public:
> Â Â Â typedef boost::adjacency_iterator<
> Â Â Â Â graph,
> Â Â Â Â vertex_descriptor,
> Â Â Â Â out_edge_iterator,
> Â Â Â Â boost::use_default> parent_class;
> Â Â Â ring_adjacency_iterator() {};
> Â Â Â ring_adjacency_iterator(const out_edge_iterator& ei, const graph* g):
> Â Â Â Â parent_class(ei, g) {};
> Â Â };
>
> I didn't have to typedef the adjacency_iterator to void in the graph definition, so this is a valid AdjacencyGraph model.
>
> I like this better than writing my own iterator_adaptor because it uses boost::adjacency_iterator, though it feels a little hacky because
> the body of ring_adjacency_iterator is mostly cut-and-pasted from adjacency_iterator.hpp.
>
> I'd like to find a way to define the adjacency iterator with the generator using the statement
>
> Â Â boost::adjacency_iterator_generator<graph, vertex_descriptor, out_edge_iterator>::type
>
> but I haven't been able to do it.  This generator statement relies on graph_traits<> properties vertex_descriptor and out_edge_iterator,
> so has to come after the definition of implicit_ring::graph. Â But that means I have to have a forward declaration of the
> adjacency_iterator, and I don't know how to forward-declare something I'm getting from  boost::adjacency_iterator_generator<>::type.
>
> It's still pretty good, but if this is going to be example code I'd like to make sure I'm doing it the best way possible.
You have the actual types that vertex_descriptor, etc. are defined to,
right? Can you use those as the arguments to
adjacency_iterator_generator?
-- Jeremiah Willcock
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