Boost logo

Boost Users :

Subject: [Boost-users] BGL: shared_ptr as bundled properties > how to generate properties maps ???
From: Damien Maupu (damien.maupu_at_[hidden])
Date: 2010-01-06 11:20:53


Dear all,

I am using bundled properties when I define my graph.
The bundled properties are smart pointers to my own class Edge and Vertex.
I write something like:
typedef boost::shared_ptr<Vertex> VertexPtr;
typedef boost::shared_ptr<Edge> EdgePtr;
typedef adjacency_list<vecS, vecS, directedS, VertexPtr, EdgePtr> Graph;

Vertex and Edge being my own classes to store information on the
vertices and the edges.
For what I read in the doc, this is the correct, more modern way to do it.

My problem is the following.
I am trying to use the BGL algorithms and some of them require
vertex/edge info to be provide as properties maps.

 From http://www.boost.org/doc/libs/1_41_0/libs/graph/doc/bundles.html
I know it is possible to generate those maps from bundled properties.

It works well if I don't use shared_ptr but cannot compile otherwise.

When using shared_ptr, similarly to the doc, I wrote:

typedef property_map<SearchGraph, float EdgePtr::*>::type WeightMap;
WeightMap weightMap = get(&EdgePtr::m_cost, *_graph);

m_cost being a public float member of my own class Edge.

I have the following compilation error:
'm_cost' : is not a member of 'boost::shared_ptr<T>'

Indeed it is not.
My question is, I can let the shared_ptr access the member?
In other world how to deal with bundled properties / properties maps and
shared_ptr.

Extra question, could 'm_cost' be a private member of my own class Edge?

Thank you very much

Sincerely,

Damien


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