Problem compiling some simple code ..

I have been fiddling with this library off and on for some time ... now am getting this error: /home/eric/boostplay/g0/src/g0.cpp:55: error: no matching function for call to 'add_vertex(Graph (&)())' /home/eric/boostplay/g0/src/g0.cpp:56: error: no matching function for call to 'add_edge(Vertex&, Vertex&, Graph (&)())' on this code: <boost-users@lists.boost.org> #ifdef HAVE_CONFIG_H #include <config.h> #endif #include <iostream> #include <cstdlib> #include <boost/config.hpp> #include <boost/graph/adjacency_list.hpp> #include <boost/tuple/tuple.hpp> using namespace std; using namespace boost; typedef adjacency_list<vecS, vecS, undirectedS> Graph; typedef graph_traits<Graph>::vertex_descriptor Vertex; typedef graph_traits<Graph>::edge_descriptor Edge; int main(int argc, char *argv[]) { Graph g(); Vertex v = 0; for(int iv = 0; iv < 10; ++iv) for(int iu = 0; iu < 5; ++iu) { Vertex u; Edge e; bool inserted; u = v; tie(v, inserted) = add_vertex(g); tie(e, inserted) = add_edge(u, v, g); if(inserted) cout << "Inserted edge " << e << " from vertex " << u << " to vertex " << v << endl; else cout << "Failed to insert edge " << e << " from vertex " << u << " to vertex " << v << endl; } return EXIT_SUCCESS; } There was a thread on this a while back which suggested casting the call: tie(e, inserted) = add_edge(u, v, g); to tie(e, inserted) = add_edge(std::size_t(u), std::size_t(v), g); but that did not work. Notice my graph has no properties .. usually I don't make 'em that way, but that should be fine, right? Thanks very much, Eric

On Jan 9, 2008 11:36 PM, Eric Fowler <eric.fowler@gmail.com> wrote:
I have been fiddling with this library off and on for some time ... now am getting this error:
/home/eric/boostplay/g0/src/g0.cpp:55: error: no matching function for call to 'add_vertex(Graph (&)())' /home/eric/boostplay/g0/src/g0.cpp:56: error: no matching function for call to 'add_edge(Vertex&, Vertex&, Graph (&)())'
on this code:
[snip]
int main(int argc, char *argv[]) { Graph g();
try instead: Graph g; Graph g(); gets interpreted as a function declaration. In the errors, you can see that type of g is listed as "Graph (&)()" (rather than Graph) HTH, Stjepan
participants (2)
-
Eric Fowler
-
Stjepan Rajko