Boost logo

Boost Users :

Subject: Re: [Boost-users] [BGL] Bundled properties and property maps
From: Andrew Sutton (andrew.n.sutton_at_[hidden])
Date: 2008-11-18 13:28:12


>
> Does anyone know what might be wrong?

Yes... The type of the property map generated by the get() function is built
for a *const* graph (since you're passing graph as const&), but your're
declaring EdgeWeightMap over a non-const graph (as in property_map<Graph,
...>). I think the most appropriate fix is to change the definition of
EdgeWeightMap to

   typedef boost::property_map<const Graph, double const EdgeProp::*>::type
EdgeWeightMap;

Another solution might be to always pass by non-const reference, but that's
not really good style. I would have thought that property_map was
appropriately specialized for const/non-const versions. I'll have to look
into it.

More generally, I'm a bit mystefied by the "<Graph, double
> EdgeProp::*>::type"
> syntax -- can anyone give me any pointers about what this syntax means, or
> where I can look it up? (googling for colon-colon-star doesn't help much).
> I also tried pattern-matching from the documentation page about bundled
> properties (the weight_map(get(&Highway::miles, map)) example) but couldn't
> get this to compile either. Is this example correct?
>

It's pointer-to-member syntax. Read from right to left You're saying that
the type is a "pointer to a member of EdgeProp that is of type double." Or
in this case, a pointer to a const EdgeProp that's a double.

Andrew Sutton
andrew.n.sutton_at_[hidden]



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