Boost logo

Boost Users :

Subject: Re: [Boost-users] [Unordered] [Multi-Index] Set lookup from something else than key_type
From: joaquin_at_[hidden]
Date: 2009-09-02 04:20:17


Daniel James escribió:
> 2009/9/1 Joaquin M Lopez Munoz <joaquin_at_[hidden]>:
>
>> Dominique Devienne <ddevienne <at> gmail.com> writes:
>>
>>> Any reason why unordered cannot allow similar "compatible key" lookups?
>>>
>> There is no technical reason why Boost.Unordered couldn't
>> provide the compatible key functionality. It just happens not
>> to be a feature condidered in the standard, but if you
>> convince the author to add it as an extension implementing it
>> should be trivial.
>>
>
> AFAICT if the hash function doesn't support the type that you supply
> it will implicitly construct a key for every call to the hash function
> and equality predicate. Which is a problem.
>

Yep, the hash function and equality predicate the user provides have to
have overloads of
operator() for the compatible key as well as the key, as shown in the
example at:

http://www.boost.org/libs/multi_index/doc/tutorial/indices.html#hash_lookup

This way no key is unnecessarily constructed, which is the point of the
compatible key
idea.

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net