Skip to content

Commit

Permalink
Merge pull request #217 from RazvanN7/Fix_hash
Browse files Browse the repository at this point in the history
Add toHash method for struct runtime/object/ValType
  • Loading branch information
maximecb committed Jun 7, 2019
2 parents 90e2ee8 + ff99bb8 commit 1b4e5d8
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions source/runtime/object.d
Expand Up @@ -303,6 +303,17 @@ struct ValType
return true;
}

// Hashing operator that does memberwise hashing
size_t toHash() const nothrow
{
size_t h = 0;
foreach(i, T; typeof(this.tupleof))
{
h = h * 33 + typeid(T).getHash(cast(const void*)&this.tupleof[i]);
}
return h;
}

/**
Compute the union with another type
*/
Expand Down

0 comments on commit 1b4e5d8

Please sign in to comment.