
Hello, Given a multi_index_container with 1 hashed unique identity key (kind of unordered set) - is there a "trivial" way to find a value by its hash-code? Currently, I'm using a trick with supplying custom hashing/equality functors, but probably there's some more straightforward way? struct Element {//...}; size_t hash_value(const Element &e) { //... } typedef mi::multi_index_container<Element, mi::indexed_by<mi::hashed_unique<mi::identity<Element> > > ElementSet; struct ElementEq { bool operator()(size_t x, const Element &y) const { return x == boost::hash<Element>()(y); } }; struct ElementHashHasher { std::size_t operator()(size_t x) const { return x; } }; int main() { ElementSet elementSet; //.... // I've got here a hash-value of an element, and I wish to find it in the set. ElementSet::iterator pos = elementSet.find(hashValue, ElementHashHasher(), ElementEq()); } Another way I tried was defining the hash-code as an explicit key: //... mi::hashed_unique< mi::global_fun<const Element&, std::size_t, &hash_value>
//... The problem however is that my hash_value functions are templates, and the above definition is not compiling... Thanks!