Boost logo

Boost :

From: John Maddock (john_at_[hidden])
Date: 2005-03-13 05:57:16

> 1) use reinterpret_cast<> as I proposed, but documenting that it will
> produce a viable hash function only if the underlying implementation
> satisfy certain requirements (each specific implementation /should/
> document the behaviour of reinterpret_cast anyway, so the user may able to
> check)
> 2) provide the hash function (with reintepret_cast<>) only for those
> platforms that we are able to check in advance that will satisfy those
> requirements and make any use of such function produce a static assert for
> all other platforms
> 3) do not provide a hash function for pointers at all
> I would vote for 1, but 2 and 3 also make sense. Is there a fourth choice?

I would also go with (1), and probably a cast to ptrdiff_t is sufficient
(rather than int_max_t).

There is a forth option: treat the pointer as a "bag of bytes" and hash
those bytes, that's completely portable, and no reinterpret_cast is required
(it's probably overkill as well)


Boost list run by bdawes at, gregod at, cpdaniel at, john at