Make hash_combine accept a configurable hash function
authorDavid Vickrey <davidvickrey@fb.com>
Mon, 11 Mar 2013 22:34:18 +0000 (15:34 -0700)
committerJordan DeLong <jdelong@fb.com>
Tue, 19 Mar 2013 00:09:06 +0000 (17:09 -0700)
commite4f530f84abb296327f2e8d986a38fce660dcd71
treedc3ad61246415103a1a378fd5636bb11c6f84cb4
parent9fb46d14d4fbfb7e1506e925b19498aa4cbf6f2a
Make hash_combine accept a configurable hash function

Summary:
std::hash is not awesome and not configurable.  Typical cases you might want to customize are:
string: I happen to know that fnv isn't super awesome, for example, and that's what folly uses for std::hash fbstring.
pointers: you may want to hash the contents of the pointer instead of the address for certain types.

This is a very simple diff that lets you do that.  It provides StdHasher that passes through to std::hash and uses that for hash_combine, so this should be 100% backward compatible.

Test Plan: test_hash.  I will add another test for using a hasher besides StdHasher shortly.

Reviewed By: delong.j@fb.com

FB internal diff: D733899
folly/Hash.h
folly/test/HashTest.cpp