Boost logo

Boost Users :

Subject: Re: [Boost-users] [Unordered] template find() request
From: Daniel James (daniel_james_at_[hidden])
Date: 2009-03-09 03:58:44


2009/3/9 <joaquin_at_[hidden]>:
>
>> This raises the question: what is either_hash::argument_type ?  But it
>> seems this is not used by boost::unordered_set .  It should probably be
>> std::string to match the underlying hash table.
>> Would it make sense to change find() to template <class query_type>
>> const_iterator find(const query_type& q) const ?
>
> FWIW, Boost.MultiIndex hashed indices do have a notion of "compatible keys"
> allowing for
> such heterogeneous lookup operations:
>
> http://www.boost.org/libs/multi_index/doc/tutorial/indices.html#hash_lookup
> http://www.boost.org/libs/multi_index/doc/reference/hash_indices.html#lookup

In the equivalent to this case:

    boost::unordered_set<std::string> set;

    // ....

    set.find("x");

Is a std::string constructed for every hash and equality call? I can't
see a way to avoid that without introducing a traits class.

Daniel


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