|
Boost Users : |
Subject: Re: [Boost-users] [BGL] Bundled properties and property maps
From: Geoff Hilton (geoff.hilton_at_[hidden])
Date: 2008-12-17 13:30:50
Dmitry Bufistov wrote:
> Geoff Hilton wrote:
>>
>>
>> I'm having the same problem though mine (with MSVC9) says:
>>
>> error C2678: binary '=': no operator found which takes a left-hand
>> operand of type 'const Weight' (or there is no acceptable conversion)
>> c:\program files\boost\boost_1_37_0\boost\property_map.hpp 161
>>
>>
>> A follow-up would be greatly appreciated.
>>
>> Thanks,
>> Geoff
>
> You can try to use
> boost::remove_const<Weight>::type
>
> Regards,
> Dmitry
To help things along, here's the code in question:
Note: graph variable is of type const Graph&.
const boost::property_map<Graph,
Weight EdgeProp::*>::const_type eprop =
boost::get(&EdgeProp::weight, graph);
const boost::property_map<Graph,
boost::vertex_index_t>::const_type vindex =
boost::get(boost::vertex_index, graph);
const vertex_descriptor firstVertex = *GetGraphBeginVertexIterator(graph);
PredecessorMap preds = PredecessorMap(numVertices);
DistanceMap dists = DistanceMap(numVertices);
boost::bellman_ford_shortest_paths(graph, numVertices,
weight_map(eprop)
.predecessor_map(boost::make_iterator_property_map(preds.begin(),
vindex))
.distance_map(boost::make_iterator_property_map(dists.begin(), vindex))
.root_vertex(firstVertex)
.distance_combine(Combiner())
.distance_compare(Comparer(currentOffset))
);
Also, my Weight type has an explicit constructor which takes a POD
convertible to 0, a requirement imposed it seems by line 155 of
bellman_ford_shortest_paths.hpp. Why doesn't the algorithm take a weight
of value zero as a parameter and use it instead?
Anyway, because of this explicit constructor I've added a (typical)
assignment operator (not sure if this is relevant, but I'm mentioning it
just in case).
I should also note that out of curiosity I commented out line 103 of
bellman_ford_shortest_paths.hpp which is:
function_requires<ReadablePropertyMapConcept<WeightMap, Edge> >();
Commenting out the above line allows my code as written above to
compile, otherwise it fails with the error written in my original
response (quoted above). Whether the compiled code (with line 103
commented out) functions as expected I don't know, I haven't tested it.
Thanks,
Geoff
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