
On 31 January 2012 19:28, Andrey Semashev <andrey.semashev@gmail.com> wrote:
On Tuesday, January 31, 2012 18:55:21 Daniel James wrote:
so it must be the container's responsibility, since the container must work well with any hash function that meets these requirements.
Wrong, there's no such requirement. It must work, not necessarilly well.
Wow. I give up.
And for standard types I would expect std::hash to do the right thing. I know, the standard doesn't spell out that explicitly (which is a bad thing), but this is how it works in practice (from my experience).
From libc++:
template <> struct _LIBCPP_VISIBLE hash<int> : public unary_function<int, size_t> { _LIBCPP_INLINE_VISIBILITY size_t operator()(int __v) const _NOEXCEPT {return static_cast<size_t>(__v);} }; Last time I tried it, libstdc++ was similar. I do want the containers to work well with popular implementations of std::hash.