Boost logo

Boost :

Subject: Re: [boost] [BGL] [PropertyMap] Key param is passed by value in put function
From: Cosimo Calabrese (cosimo.calabrese_at_[hidden])
Date: 2009-11-18 06:28:26


Cosimo Calabrese wrote:
> Hi to all,
>
> I've noticed that the put function that takes a generic put_get_helper
> map, takes a key param. The question is: why the key param is passed by
> value? Is any reason for this? The key value is not modified setting the
> property map.
>
> I've noticed it because in my graph type the descriptors are variant,
> and so every time I've to set a property map, a new copy of the variant
> is created.
>
> I've reported the function below, for sake of comfort. It is in
> boost/property_map.hpp
>
> template <class PropertyMap, class Reference, class K, class V>
> inline void
> put(const put_get_helper<Reference, PropertyMap>& pa, K k, const V& v)
> {
> static_cast<const PropertyMap&>(pa)[k] = v;
> }
>

The same thing is in class iterator_property_map, in operator[] the key
value is passed by value:

inline R operator[](key_type v) const { return *(iter + get(index, v));}

Best regards,
Cosimo Calabrese.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk