Boost logo

Boost Users :

Subject: Re: [Boost-users] [BGL] Bundled properties and property maps
From: Alex Brooks (a.brooks_at_[hidden])
Date: 2008-11-18 18:23:37


Hi Andrew,

Thanks very much for the help, I've got it working now. I had to use a
non-const reference though. Here are the options I tried:

// Option A:
    Graph &nonConstGraph = const_cast<Graph&>(graph);
    typedef boost::property_map<Graph, double EdgeProp::*>::type
EdgeWeightMap;
    EdgeWeightMap edgeWeightMap = get(&EdgeProp::cost, nonConstGraph);

// Option B:
// typedef boost::property_map<Graph, double const EdgeProp::*>::type
EdgeWeightMap;
// EdgeWeightMap edgeWeightMap = get(&EdgeProp::cost, graph);

Option A works, but is a bit ugly.
Option B is what you suggested, but it gives the following error:

/home/a.brooks/shh/src/libs/prm/test/stupid.cpp:70: error: conversion
from 'boost::bundle_property_map<const boost::adjacency_list<boost::vecS,
boost::vecS, boost::undirectedS, Point*, EdgeProp, boost::no_property,
boost::listS>, boost::detail::edge_desc_impl<boost::undirected_tag, unsigned
int>, EdgeProp, const double>' to non-scalar type 'searchThroughGraph(const
Graph&, VertexRef, VertexRef, std::vector<unsigned int,
std::allocator<unsigned int> >&)::EdgeWeightMap' requested

Do I also need to modify the 'get()' line?

> 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.

Awesome, thanks for the pointer.

Cheers,

Alex


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