|
Boost : |
From: Howard Hinnant (howard.hinnant_at_[hidden])
Date: 2021-10-16 23:16:58
Given two values x and y, if x == y, it is convenient for hash(x) == hash(y).
In this situation, given a floating point value r, complex{r) == r, so it makes sense that hash(complex{r}) == hash(r). This might enable heterogeneous hash table lookup.
Howard
On Oct 16, 2021, at 6:44 PM, Peter Dimov via Boost <boost_at_[hidden]> wrote:
>
> At the moment, boost::hash_value for complex<T> is specified as
>
> When T is a built in type and val.imag() == 0, the result is equal
> to hash_value(val.real()). Otherwise an unspecified value, except
> that equal arguments shall yield the same result.
>
> This is a bit odd; the natural implementation for a two-argument
> point/tuple type is
>
> std::size_t seed = 0;
>
> boost::hash_combine( seed, v.real() );
> boost::hash_combine( seed, v.imag() );
>
> return seed;
>
> Can anyone offer an opinion on whether or why the original behavior
> is preferable?
>
>
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk