Boost logo

Boost Users :

Subject: Re: [Boost-users] Function pointer to in/out_degree in BGL
From: langermatze (langer.matze_at_[hidden])
Date: 2010-10-27 04:06:41


I tried this:

typedef boost::adjacency_list<boost::vecS, boost::vecS,
boost::bidirectionalS> 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<boost::vecS, boost::vecS,
boost::bidirectionalS, boost::no_property, boost::no_property,
boost::no_property, boost::listS>&)’
/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<boost::vecS, boost::vecS, boost::bidirectionalS,
boost::no_property, boost::no_property, boost::no_property, boost::listS>&)’

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-tp3014116p3015012.html
Sent from the Boost - Users mailing list archive at Nabble.com.

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