
On Wed, Sep 2, 2009 at 2:17 PM, Joaquin M Lopez Munoz
[...] The net effect is that we pass from one implicit conversion when invoking find() to multiple implicit conversions inside find() code.
Ah yes, that's unfortunate. Thanks for making that clear.
A "simple" solution is to not overload, and rename the find() overload
into find_compatible_key(another_type) to remove this possibility, while
not having to provide explicitly the hash/pred to find(ckey,hash,pred):
typedef boost::unordered_set<
my_type, hash_by_uid
my_type_set;
my_type::uid_t some_uid = ...; const my_type_set& set = ...; my_type_set::iterator found1 = set.find( some_uid, my_type_set::hasher(), my_type_set::key_equal() ); my_type_set::iterator found2 = set.find_compatible_key(some_uid); assert(found1 == found2); The 1-arg find_compatible_key(compatible_key_t) assumes appropriate overloads for compatible_key_t in hash/pred, and delegates to the containers hash/pred and the 3-arg find(). Can even be a free template function in fact. --DD