On Monday 05 October 2015 09:17:45 'Geoffrey Romer' via ISO C++ Standard -
Future Proposals wrote:
> The API for extracting a hash value, and symmetrically the API for
> initializing the HashCode, is deliberately left unspecified.
So if I want to write a new portable container that relies on hashing, I
can't? What's the rationale for that?
> In the case of
> std::hash_code it doesn't matter, because only std::hash needs to be aware
> of those details.
Most definitely not. I started with an example that disagrees with this
perspective.
> Other HashCode types can provide similar functor
> wrappers, or explicitly specify those APIs however they choose.
So if I write my own element type T, I need to specify its hashing function
for std::unordered_map and SomeOtherHash?
> The initialization API is unspecified because it depends on the
> implementation details of the HashCode (e.g. hashing::farmhash needs a
> pointer to its state as an input). The value-extraction API is unspecified
> because it's unsafe: in many cases it will leave the HashCode in an
> unusable state. I solved that in the prototype by making it rvalue-ref
> qualified, but then I realized there's no need to specify it at all
> (particularly when the initialization API is also unspecified), and an
> unspecified API is simpler, safer, and harder to bikeshed.
>
> I had thought I spelled this out in the paper somewhere, but I can't
> immediately find it, so that may be an oversight on my part.
I find that those reasons invalidate the proposal.
If I can't use them in my own hashing container, they're unusable.
--
Thiago Macieira - thiago (AT)
macieira.info - thiago (AT)
kde.org
Software Architect - Intel Open Source Technology Center
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358