|
Boost Users : |
Subject: Re: [Boost-users] [Unordered] [Multi-Index] Set lookup from something else than key_type
From: Dominique Devienne (ddevienne_at_[hidden])
Date: 2009-09-02 14:56:37
On Wed, Sep 2, 2009 at 7:23 AM, Daniel James<daniel_james_at_[hidden]> wrote:
>> template<
>> typename CompatibleKey,typename CompatibleHash,typename CompatiblePred
>> >
>> iterator find(
>> const CompatibleKey& k,
>> const CompatibleHash& hash,const CompatiblePred& eq)const;
>>
>> which is a pure extension without backwards compatibility problems. This
>> is seemingly what Boost.Intrusive is doing.
>
> Yes, I think I'll add that to the new version which should be released
> in 1.41 or 1.42.
This would indeed cleanly solve my problem.
FTR, I tend to lean on Joaquín's side of the argument. If the provided
explicit Hash/Pred template parameters of unordered_set do provide overloads
for compatible keys, then it's "by design" that find() should use them.
If previous code that was relying on an implicit conversion to key_type
starts using added overload on Pred/Hash, this simply means that the
container designer made this choice explicitly, and I don't see why that
a bad thing. After all the overloads were added for avoiding the key
creation, which is exactly what I was trying to do here.
In Joaquín's proposal, all clients using find() implicitly start using the
optimized find() avoiding the key_type conversion once the container
is modified and the client code is recompiled. No code necessary.
That's a good thing to me. But that's just me ;) --DD
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