Boost logo

Boost Users :

Subject: Re: [Boost-users] PropertyGraphConcept concept checking errors for an example implicit graph
From: W.P. McNeill (billmcn_at_[hidden])
Date: 2010-07-01 14:28:40

The forward declarations are tricky because ring_adjacency_iterator_generator
adapts ring_incident_edge_iterator, which in turn has template parameters
defined in terms of graph_traits<>.

After playing around a bit more I was able to
use boost::adjacency_iterator_generator::type by making it a base class
of ring_adjacency_iterator_generator. This ends up only saving a few
keystrokes from the version that derives it directly
from boost::adjacency_iterator, but it still feels like the right thing to
do. I was also able to keep everything parameterized through

This example feels done. Thanks for your help.

On Wed, Jun 30, 2010 at 9:50 PM, Jeremiah Willcock <jewillco_at_[hidden]>wrote:

> 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 mailing list
> Boost-users_at_[hidden]

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at