
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.... 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.