Boost logo

Boost Users :

Subject: [Boost-users] How to make custom property map compatible with bgl_named_params?
From: Tim Keitt (tkeitt_at_[hidden])
Date: 2008-11-23 17:40:41


I have a custom (internal) property map defined as:

struct edge_weight_extractor_map
{
        typedef float8 value_type;
        typedef float8 reference;
        typedef WeightedEdgeTableSQLGraph::edge_descriptor key_type;
        typedef boost::readable_property_map_tag category;
};

inline edge_weight_extractor_map::value_type
get(const edge_weight_extractor_map& map, const
edge_weight_extractor_map::key_type& key)
{
        return key.edge_weight;
}

The map works fine as an internal property map with eg
dijkstra_shortest_paths. However, I cannot get it to work when it is
used in a bgl_named_params expression like:

boost::brandes_betweenness_centrality(g, centrality,
boost::weight_map(get(boost::edge_weight, g)));

The error looks like:

/usr/include/boost/property_map.hpp:25: error: no type named
'key_type' in 'struct
boost::bgl_named_params<edge_weight_extractor_map,
boost::edge_weight_t, boost::no_property>'
/usr/include/boost/property_map.hpp:27: error: no type named
'reference' in 'struct
boost::bgl_named_params<edge_weight_extractor_map,
boost::edge_weight_t, boost::no_property>'
/usr/include/boost/property_map.hpp:28: error: no type named
'category' in 'struct
boost::bgl_named_params<edge_weight_extractor_map,
boost::edge_weight_t, boost::no_property>'

Do I need to specialize a traits template? Can someone post an example
of how this works? (I've tried to specialize bgl_named_params itself,
but unsuccessfully.) Thanks.

THK

-- 
Timothy H. Keitt
http://www.keittlab.org/

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