
"Dave Harris" <brangdon@cix.compulink.co.uk> wrote in message news:memo.518849@cix.compulink.co.uk... | In-Reply-To: <d1409a$kc1$1@sea.gmane.org> | daniel@calamity.org.uk (Daniel James) wrote (abridged): | > If Thorsten writes ptr_unordered_set<base> then there might be a | > problem with boost::hash<base>. Although it will equally apply to | > std::equal_to<base>. | | Absolutely. In general when writing hash_value() you need to look at the | corresponding equality operator. For example: | | bool Derived::operator==( const Base &base ) const { | if (Base::operator==( base )) | if (const Derived *p = dynamic_cast( const Derived * >(&base)) | if (m_value == p->m_value) | return true; | return false; | } | | Ideally we look at this and we decide there ought to be something in the | hash_value which corresponds to the dynamic_cast. But what? are you saying we don't want to hash a Base* as a void*, but use object properties instead? -Thorsten