Boost logo

Boost Users :

Subject: Re: [Boost-users] [Unordered] [Multi-Index] Set lookup from something else than key_type
From: Stefan Strasser (strasser_at_[hidden])
Date: 2009-09-02 08:08:49


Am Wednesday 02 September 2009 12:47:56 schrieb Daniel James:
>
> But those overloads don't always exist. A simple example is:
>
> struct hash {
> std::size_t operator()(std::string const&) const;
> };
>
> struct equals {
> bool operator()(std::string const&, std::string const&) const;
> };
>
> boost::unordered_map<std::string, int, hash, equals> map;
> // ....
> map.find("char array");
>
> A single string object should be created in this case.
>

Boost.Intrusive implements this type of feature in its intrusive unordered
set:
http://www.boost.org/doc/libs/1_40_0/doc/html/boost/intrusive/unordered_set.html#id1057332-bb

and I just recently had to use a unordered_map<key,mapped> instead of a
unordered_set<mapped>, even though the key is obtainable from mapped, because
mapped is not constructible from key.


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