|
Boost : |
From: JOAQUIN LOPEZ MU?Z (joaquin_at_[hidden])
Date: 2005-03-10 17:19:16
----- Mensaje original -----
De: Peter Dimov <pdimov_at_[hidden]>
Fecha: Jueves, Marzo 10, 2005 10:35 pm
Asunto: Re: [boost] Re: Re: Re: [review] hash functions
> JOAQUIN LOPEZ MU?Z wrote:
> >
> > Maybe the following approach could be taken to
> > allow for alternative implementations to be plugged into
> > the framework: [...]
>
> > unordered_set<my_type,boost::hash<my_type,crypto_impl> > us;
>
> The proposal is not a framework, it contains two simple tools for
> constructing hash_value overloads for compound types and a suite
> of
> _default_ hash functions.
>
> Alternative implementations (who may or may not use the supplied
> tools) are
> supported by unordered_set by simply using
>
> unordered_set< my_type, my_hash > us;
>
> There's no need to plug them in.
The idea is that you can alter only some part of the
hashing scheme and benefit of the preexisting definitions:
template<typename It>
std::size_t hash_range(It first,It last,crypto_impl)
{
...
}
// third_party_type is an external type with its own
// hash_value overload
unordered_set<
std::vector<third_party_type>,
boost::hash<std::vector<third_party_type>, crypto_impl>
> us;
// here, we automatically get an impl of hashing for
// strings using the crypto_impl hash_range
unordered_set<
std::string,
boost::hash<std::string, crypto_impl>
> us2;
But I won't defend this to death :) I just felt like
throwing the idea in.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk