Boost logo

Boost :

From: Douglas Gregor (gregod_at_[hidden])
Date: 2003-05-10 21:31:29

I just finished writing out a BGL algorithm that requires 9 utility property
maps (!), and I found that I didn't want to separately allocate 9 vectors for
use with iterator property maps. Instead, I packaged all the data for the
separate property maps (all vertex property maps) into a single data
structure and wrote a property map adaptor that projects from a data
structure to a member. Now I only have to allocate a single vector of this
data bundle, and create a few projection property maps to each of the

Here's the projection_property_map class template. Anyone need it in

template<typename PropertyMap, typename T, typename Class, T Class::*Member>
struct projection_property_map
  : put_get_helper<T&, projection_property_map<PropertyMap, T, Class, Member>
  typedef T value_type;
  typedef typename property_traits<PropertyMap>::key_type key_type;
  typedef value_type& reference;
  typedef lvalue_property_map_tag category;

  explicit projection_property_map(PropertyMap pmap) : pmap(pmap) {}

  reference operator[](const key_type& key) const
    Class& c = const_cast<Class&>(pmap[key]);
    return c.*Member;

  PropertyMap pmap;


Boost list run by bdawes at, gregod at, cpdaniel at, john at