
Alexander Nasonov wrote:
That's not quite right. For example
#include <iostream> #include <boost/functional/hash.hpp>
struct Base { bool operator==(Base) const { return true; } };
std::size_t hash_value(Base) { return 0; // Base has no state }
struct Derived : Base { int dummy; bool operator==(Derived other) const { return dummy == other.dummy; } };
OK, I thought you meant something else. It seems to me that in this case, hash_value(Base) is a part of Base's interface - so any class that derives from it should take it into account. It also appears that Base wasn't really designed for derivation (despite its name ;), and it's generally a bad idea to derive from such classes. I guess that's a bit of a cop out answer, but this is more of a problem with the way the derivation is done than Boost.Hash itself. What I should do, is add some documentation about using Boost.Hash with class inheritance. I'll try to do that soon-ish. What do you think about having a macro to disable the extensions? Am I right in thinking that your main concern is that the extensions are in Boost.TR1? Sorry for the late reply, Daniel