
On 6 July 2010 13:52, Igor R <boost.lists@gmail.com> wrote:
One idea is to patch the boost headers to add a hash function for each of the smart pointer types (as per the example above) but there must be a better answer than this?
Technically, you can define hash functions in your own headers, in boost namespace (that's what I do). I'm not sure about legal aspects of this though.
It's open source, so really it's up to you. Although I'd suggest that if you have adapted a boost class, it'd be a good idea to submit a patch to the appropriate maintainer. boost::shared_ptr should be pretty simple, something like (untested): namespace boost { template <typename T> std::size_t hash_value(boost::shared_ptr<T> const& x) { boost::hash<T*> hash_ptr; return hash_ptr(x.get()); } } Daniel