$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
Subject: Re: [Boost-users] [BGL] Bundled properties and property maps
From: Geoff Hilton (geoff.hilton_at_[hidden])
Date: 2008-12-18 11:48:59
Dmitry Bufistov wrote:
> Geoff Hilton escribió:
>>
>> Note: graph variable is of type const Graph&.
>>
> [skip]
>>
>> 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
> 
> It looks like the problem is with
> template <class PMap, class Key> struct ReadablePropertyMapConcept;
> 
> The following code fails to compile:
> 
> #include <boost/graph/graph_concepts.hpp>
> #include <boost/graph/adjacency_list.hpp>
> 
> using namespace boost;
> struct EdgeProp
> {
>         double weight;
> };
> 
> typedef boost::adjacency_list<vecS, vecS, directedS, no_property, 
> EdgeProp > graph_t;
> int main()
> {
>         typedef boost::property_map<graph_t, double 
> EdgeProp::*>::const_type WeightMap;
>         typedef boost::graph_traits<graph_t>::edge_descriptor Edge;
>         function_requires<ReadablePropertyMapConcept<WeightMap, Edge> >();
> }
> 
> You may try to change the boost/property_map.hpp as follows:
> (in the version 1.37 the line number is 165)
> typename typename property_traits<PMap>::value_type val;
> to the
> typename remove_const<typename property_traits<PMap>::value_type>::type 
> val;
> 
> Does it work for you?
> 
> Regards,
> Dmitry
Thanks Dmitry, it does work! I do wonder though, isn't there a better 
fix? What about specializing ReadablePropertyMapConcept specifically for 
const properties, or does that not make sense with concept classes? I'm 
okay with modifying BGL code, but the remove_const makes me feel dirty.
This sounds like something that should be brought up with BGL maintainers...
Geoff