Skip to content

Commit

Permalink
Merge pull request #2303 from 9rnsr/fix_hash
Browse files Browse the repository at this point in the history
Tweak Tuple and Variant for correct hashing
  • Loading branch information
monarchdodra committed Jul 4, 2014
2 parents 98e5c72 + 0e3e71f commit 520c535
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 17 deletions.
15 changes: 0 additions & 15 deletions std/typecons.d
Original file line number Diff line number Diff line change
Expand Up @@ -478,21 +478,6 @@ template Tuple(Specs...)
field[] = another.field[];
}

/**
* Comparison for equality.
*/
bool opEquals(R)(R rhs)
if (areCompatibleTuples!(typeof(this), R, "=="))
{
return field[] == rhs.field[];
}
/// ditto
bool opEquals(R)(R rhs) const
if (areCompatibleTuples!(typeof(this), R, "=="))
{
return field[] == rhs.field[];
}

/**
* Comparison for ordering.
*/
Expand Down
6 changes: 4 additions & 2 deletions std/variant.d
Original file line number Diff line number Diff line change
Expand Up @@ -674,8 +674,10 @@ public:
* Returns the $(D_PARAM typeid) of the currently held value.
*/

@property TypeInfo type() const
@property TypeInfo type() const nothrow @trusted
{
scope(failure) assert(0);

TypeInfo result;
fptr(OpID.getTypeInfo, null, &result);
return result;
Expand Down Expand Up @@ -872,7 +874,7 @@ public:
* Computes the hash of the held value.
*/

size_t toHash()
size_t toHash() const nothrow @safe
{
return type.getHash(&store);
}
Expand Down

0 comments on commit 520c535

Please sign in to comment.