I am trying to build a template function. Inside templated classes are used and I would like to pass the template type of the function to those classes. So I have:
template <class T>
T find_bottleneck (ListGraph &g, CrossRefMap<ListGraph, Edge, T> &weight, Node &s, Node &t) {
// Check if theres a single edge left
if (countEdges(g) == 1) {
CrossRefMap<ListGraph, Edge, T>::ValueIt itr = weight.beginValue();
return *itr;
}
However this fails, citing
lemon_graph.cpp: In function ‘T find_bottleneck(lemon::ListGraph&, lemon::CrossRefMap<lemon::ListGraph, lemon::ListGraphBase::Edge, T>&, Node&, Node&)’:
lemon_graph.cpp:20: error: expected ‘;’ before ‘itr’
lemon_graph.cpp:21: error: ‘itr’ was not declared in this scope
I tried to recreate this using a simple example of a function which generates vectors based on the type passed to it and that compiled fine, so I am not sure what the problem is here.