Ticket #3739: property_map.hpp.diff

File property_map.hpp.diff, 1.6 KB (added by Noel Belcourt, 13 years ago)
  • property_map.hpp

     
    302302    }
    303303  };
    304304
    305   struct identity_property_map;
     305  template <typename T>
     306  struct typed_identity_property_map;
    306307
    307308  // A helper class for constructing a property map
    308309  // from a class that implements operator[]
     
    539540  };
    540541
    541542  //=========================================================================
    542   // A property map that applies the identity function to integers
    543   struct identity_property_map
    544     : public boost::put_get_helper<std::size_t,
    545         identity_property_map>
     543  // A generalized identity property map
     544  template <typename T>
     545  struct typed_identity_property_map
     546    : public boost::put_get_helper<T, typed_identity_property_map<T> >
    546547  {
    547     typedef std::size_t key_type;
    548     typedef std::size_t value_type;
    549     typedef std::size_t reference;
     548    typedef T key_type;
     549    typedef T value_type;
     550    typedef T reference;
    550551    typedef boost::readable_property_map_tag category;
    551552
    552553    inline value_type operator[](const key_type& v) const { return v; }
    553554  };
    554555
     556//=========================================================================
     557  // A property map that applies the identity function to integers
     558  typedef typed_identity_property_map<std::size_t> identity_property_map;
     559
    555560  //=========================================================================
    556561  // A property map that does not do anything, for
    557562  // when you have to supply a property map, but don't need it.