I tried this:
typedef boost::adjacency_list Graph;
typedef typename boost::graph_traits<Graph>::degree_size_type
(*FuncPtrType)(typename boost::graph_traits<Graph>::vertex_descriptor, const
Graph &);
FuncPtrType funcPtr = boost::in_degree<Graph>;
The error I'm getting:
error: no matches converting function ‘in_degree’ to type ‘size_t (*)(long
unsigned int, const class boost::adjacency_list&)’
/usr/include/boost/graph/detail/adjacency_list.hpp:1058: error: candidates
are: template<class Config> typename Config::degree_size_type
boost::in_degree(typename Config::vertex_descriptor, const
boost::undirected_graph_helper<C>&)
/usr/include/boost/graph/detail/adjacency_list.hpp:1649: error:
template<class Config> typename Config::degree_size_type
boost::in_degree(typename Config::vertex_descriptor, const
boost::directed_edges_helper<Config>&)
Sounds reasonable since the signature of in_degree is way more complex than
my function pointer signature. I couldn't find a way to get the correct
Config template for my Graph class, that's why I tried to pass the Graph
class itself but apparently that's not how it works.
I also tried casting which ends up in the "improper use of overloaded
function" error that you mentioned:
FuncPtrType funcPtr = static_cast<FuncPtrType>(boost::in_degree<Graph>);
error: invalid static_cast from type ‘<unresolved overloaded function type>’
to type ‘size_t (*)(long unsigned int, const
boost::adjacency_list&)’
As for your concerns about efficiency, I'd ultimately use the function
pointer as an additional template for the visitor which then shouldn't
affect code efficiency at all but avoid code duplication only.
~Matthias
--
View this message in context: http://boost.2283326.n4.nabble.com/Function-pointer-to-in-out-degree-in-BGL-...
Sent from the Boost - Users mailing list archive at Nabble.com.