I'm trying to sort a list of edge_descriptors, but I get the compiler error
described below.
typedef adjacency_list < vecS, vecS, bidirectionalS >::edge_descriptor
edgeDescriptor; // defined globally
template < typename Graph, typename edgeDescriptor >
struct SortByName : public binary_function
{
bool operator()(const Graph & g, const edgeDescriptor& a, const
edgeDescriptor& b)
{
return g[a].eName < g[b].eName;
}
};
template < typename Graph >
void Sort_Test(Graph & g)
{
typedef std::list<edgeDescriptor> edge_list;
typename graph_traits<Graph>::edge_iterator edge_iter, edges_end;
edge_list A;
for (tie(edge_iter, edges_end) = edges(g); edge_iter != edges_end;
++edge_iter)
A.push_back(*edge_iter);
for (edge_list::iterator i = A.begin(); i != A.end(); ++i)
cout << " *i = " << " " << g[*i].eName << "\n";
// If the following line is commented out the program compiles and runs
OK.
A.sort(SortByName< typename Graph, typename edgeDescriptor >());
//With the above line uncommented the compiler says:
/*
./Includes/Utilities.cpp: In function ‘void Sort_Test(Graph&)’:
./Includes/Utilities.cpp:539: error: wrong number of template arguments (1,
should be 2)
./Includes/Utilities.cpp:513: error: provided for ‘template struct SortByName’
make: *** [plc] Error 1
*/
}
But clearly there are two template arguments - < typename Graph, typename
edgeDescriptor >
Thanks