
On 12.05.2011 12:58, Dominik Steenken wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Hello everyone,
i am having a bit of a problem using boost/hash in combination with boost/shared_ptr. Essentially, what i want when i hash a shared_ptr object is to hash the object it points to. So i wrote a template function to that effect, i.e.
inline std::size_t hash_value(boost::shared_ptr<const IHashable> obj) { return obj->hash_value(); }
where IHashable is an interface forcing the existence of the hash_value() function. Now i am getting compiler errors because apparently there is an implicit conversion to bool from boost::shared_ptr<T> and obviously there is a hash function for bool. Thus, something like
boost::shared_ptr<IHashable> p(new something()); boost::hasher<something> hasher; std::size_t hash = hasher(p);
is now ambiguous.
Add
inline std::size_t hash_value(boost::shared_ptr<IHashable> obj)
{
return hash_value(static_cast