
Andrew Sutton wrote:
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.
The original application of keys for property maps only covered some fairly trivial data types (ints, pointers, and pairs thereof). Passing by value is perfectly acceptable in these cases.
Leaving aside whether copy elision is performed or not, isn't this what call_traits<T>::param_type is for, passing built-in types and pointers as T and user-defined types as const T&? (On the other hand, std::pair<int, int> is probably best passed by value, but param_type would be a const reference.) --Jeffrey Bosboom