StandardHash.fnv1aCode

Evaluates to D code that implements the calculation of FNV1a of a variable named var with n bytes of size, storing the result in a variable named hashvar. The initial value of hashvar should be fnv1a_init or a previously calculated FNV1a hash.

struct StandardHash
static
template fnv1aCode (
istring hashvar
istring var
size_t n
) {}

Members

Static variables

fnv1aCode
enum istring fnv1aCode;
Undocumented in source.
fnv1aCode
enum istring fnv1aCode;
Undocumented in source.

Examples

Let x be an int variable to calculate the hash value from and result be the result variable:

int x;

hash_t result = fnv1a_init;

Then

fnv1aCode!("result", x.stringof, x.sizeof)

, where x.sizeof is 4, evaluates to

auto __x = cast(ubyte*)&x;

result = (result ^ __x[0LU]) * 1099511628211LU;
result = (result ^ __x[1LU]) * 1099511628211LU;
result = (result ^ __x[2LU]) * 1099511628211LU;
result = (result ^ __x[3LU]) * 1099511628211LU;

Meta