Util/fnv1a.hpp File Reference

fnv1a.hpp File Reference
#include <stddef.h>

Functions

size_t fnv1a_hash_bytes (const unsigned char *first, size_t count)
 From https://github.com/Microsoft/VCSamples/tree/master/VC2015Samples/_Hash_seq:

The internal hash function std::_Hash_seq(const unsigned char *), used to implement std::hash on some string types, was visible in recent versions of the Standard Library is not anymore visible (VC2017 15.3)

To remove this dependency, add the header (fnv1a.hpp) to any affected code, and then find and replace _Hash_seq by fnv1a_hash_bytes. More...
 

Function Documentation

size_t fnv1a_hash_bytes ( const unsigned char *  first,
size_t  count 
)
inline

From https://github.com/Microsoft/VCSamples/tree/master/VC2015Samples/_Hash_seq:

The internal hash function std::_Hash_seq(const unsigned char *), used to implement std::hash on some string types, was visible in recent versions of the Standard Library is not anymore visible (VC2017 15.3)

To remove this dependency, add the header (fnv1a.hpp) to any affected code, and then find and replace _Hash_seq by fnv1a_hash_bytes.

You'll get identical behavior to the internal implementation in _Hash_seq.

48  {
49  #if defined(_WIN64)
50  static_assert(sizeof(size_t) == 8, "This code is for 64-bit size_t.");
51  const size_t fnv_offset_basis = 14695981039346656037ULL;
52  const size_t fnv_prime = 1099511628211ULL;
53 
54  #else /* defined(_WIN64) */
55  static_assert(sizeof(size_t) == 4, "This code is for 32-bit size_t.");
56  const size_t fnv_offset_basis = 2166136261U;
57  const size_t fnv_prime = 16777619U;
58  #endif /* defined(_WIN64) */
59 
60  size_t result = fnv_offset_basis;
61  for (size_t next = 0; next < count; ++next)
62  { // fold in another byte
63  result ^= (size_t)first[next];
64  result *= fnv_prime;
65  }
66  return (result);
67 }
MAXMEM_EXTERN_C UtilExport size_t(__cdecl *MAX_msize)(void *memblock)