carlpett
carlpett

Reputation: 12583

Copying a boost::property_map into a boost::vector_property_map

When calling boost::get on a graph, the return type is boost::associative_property_map<Graph, PropertyType>. I'd like to get a copy of this map, and I'd like to store it in a boost::vector_property_map. However, they are not compatible enough to allow simply assigning to the vector map. Looking at the source of property_map, it seems boost::associative_property_map does not have any access methods at all (the vector variety at least exposes "storage iterators").

Is there a way? Or do I have to find the keys somehow and loop over them?

Upvotes: 1

Views: 317

Answers (1)

Beno&#238;t
Beno&#238;t

Reputation: 16994

I am sorry, but simply using boost::associative_property_map, you won't be able to retrieve iterators over contained items. You must use an alternate way to iterate over them -- iterate over edges or vertices, i guess, and put them into a boost::vector_property_map.

But if you have to do that, it means you are deconstructing the whole idea of having the common interface that property maps provide. Can't you templatize the algorithm which currently needs vector_property_map to have it accept other property_map types ?

Upvotes: 1

Related Questions