|
Boost Users : |
From: Douglas Gregor (doug.gregor_at_[hidden])
Date: 2005-04-14 18:17:52
On Apr 14, 2005, at 11:22 PM, Vivid Yang wrote:
> I tried to compile dijkstra-example-listS (BGL CVS) in MSVC 6.0.
> There were several errors.
> In the code
>
> tie(e, inserted) = add_edge(edge_array[j].first, edge_array[j].second,
> g);
>
> The variable int edge_array[j].first and edge_array[j].second cannot
> be converted to descriptors.
>
> To solve this, I have to map int (A, B, C, D, E) to descriptor first:
> std::pair<int, vertex_descriptor> maps[5];
> int c = 0;
> graph_traits<graph_t>::vertex_iterator i, iend;
> for (tie(i, iend) = vertices(g); i != iend; ++i, ++c) {
> maps[c] = std::pair<int, vertex_descriptor>(c, *i);
> }
Yep, the MSVC 6 workaround was broken. I've fixed it in Boost CVS for
the next release, but see below for the code if you want to try it
yourself.
> ------------------------------------------------------------------
>
> The same problem happens in dijkstra_shortest_paths.hpp
> In the lines :
>
> typename graph_traits<VertexListGraph>::vertex_iterator ui, ui_end;
> put(distance, *ui, inf);
> put(predecessor, *ui, *ui);
> put(distance, s, zero);
>
> They cannot convert descriptor s and (*ui) from (void *) to int
> Here is the error description:
> boost\boost_1_32_0\boost\graph\dijkstra_shortest_paths.hpp(211) :
> error C2664: 'void __cdecl boost::put(int *,int,const double &)' :
> cannot convert parameter 2 from 'void *' to 'int'
> This conversion requires a reinterpret_cast, a C-style cast or
> function-style cast
If you find where the #if defined(BOOST_MSVC)... line is, replace the
conditional block with:
#if defined(BOOST_MSVC) && BOOST_MSVC <= 1300
graph_t g(num_nodes);
property_map<graph_t, edge_weight_t>::type weightmap =
get(edge_weight, g);
std::vector<vertex_descriptor> msvc_vertices;
for (tie(i, iend) = vertices(g); i != iend; ++i)
msvc_vertices.push_back(*i);
for (std::size_t j = 0; j < num_arcs; ++j) {
edge_descriptor e; bool inserted;
tie(e, inserted) = add_edge(msvc_vertices[edge_array[j].first],
msvc_vertices[edge_array[j].second], g);
weightmap[e] = weights[j];
}
#else
I think it'll be work, but it's hard to tell with MSVC 6, which we've
unfortunately had to stop supporting because it is too unstable :(.
Doug
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