Closed GoogleCodeExporter closed 9 years ago
Thanks for the suggestion! I don't know that we want to get into the business
of providing compatibility shims. It's nice that the STL separates out the
concept of a hash functor from the hashtable implementation, so we can provide
a new hashtable implementation without needing to worry about the functor. But
as you noticed, it's not super-nice, since the hashtable implementation
actually depends on the API of the hash functor, which differs amongst STLs.
sparse_hash_* and dense_hash_* require a particular API, which we document. So
I'm not sure how much the flexibility you describe would help the program.
Actually, thinking about it a bit more: I'm not a fan of overloading hash<> at
all -- it causes all sorts of problems, like you point out. It's better just
to declare your own functor, however you'd like, and pass it as a template
argument to sparse_hash_set<> or dense_hash_set<>. So I'd rather not add any
functionality that makes it easier to overload hash<>.
Original comment by csilv...@gmail.com
on 8 Jun 2011 at 1:01
You're absolutely 100% right. Providing a user-defined hash function as a
template parameter to the containers works on my compilers, without having to
use any #ifdefs whatsoever.
Original comment by jan.fost...@gmail.com
on 8 Jun 2011 at 7:54
Original issue reported on code.google.com by
jan.fost...@gmail.com
on 7 Jun 2011 at 2:47