Boost logo

Boost Users :

Subject: Re: [Boost-users] [BGL] Bundled properties and property maps
From: Dmitry Bufistov (dmitry_at_[hidden])
Date: 2008-12-17 18:05:25


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


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