|
Boost Users : |
Subject: [Boost-users] [BGL] Unable to sort list of edge_descriptors
From: Mike Douglass (douglassm13_at_[hidden])
Date: 2010-11-06 05:04:57
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<edgeDescriptor, edgeDescriptor,
bool>
{
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<class Graph, class
edgeDescriptor> struct SortByNameâ
make: *** [plc] Error 1
*/
}
But clearly there are two template arguments - < typename Graph, typename
edgeDescriptor >
Thanks
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