Hi, It's me one more time. I am still quite new to metaprogramming. I don't understand how you have a functor that "take an edge descriptor". Can you give me such example of functor? In the link you send me on "function_property_map" how should be written "get_weight" ? Thank you Damien Jeremiah Willcock a écrit :
On Wed, 6 Jan 2010, Damien Maupu wrote:
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
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
::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?
Try writing a function that takes an edge descriptor and returns a reference to m_cost for that edge (using the bundled property syntax), then using the code in URL:http://article.gmane.org/gmane.comp.lib.boost.user/54397 to convert that into a property map.
BTW, sorry about referring to this message before I sent it (this is the one I was referring to about handling pointers as bundled properties). I thought I had sent it earlier.
-- Jeremiah Willcock _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users