Skip to content

Commit

Permalink
Disabled toHash in -betterC for now
Browse files Browse the repository at this point in the history
TypeInfo is part of DRuntime.
See: #5952

Replaced `toHash` with a parameter-less template for codegen on demand.
  • Loading branch information
wilzbach committed Jul 19, 2018
1 parent 552d139 commit b5970ce
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions std/typecons.d
Original file line number Diff line number Diff line change
Expand Up @@ -1169,12 +1169,12 @@ if (distinctFieldNames!(Specs))
Returns:
A `size_t` representing the hash of this `Tuple`.
*/
size_t toHash() const nothrow @safe
size_t toHash() const nothrow @trusted
{
size_t h = 0;
static foreach (i, T; Types)
{{
const k = typeid(T).getHash((() @trusted => cast(const void*) &field[i])());
const k = hashOf(field[i]);
static if (i == 0)
h = k;
else
Expand Down Expand Up @@ -1474,6 +1474,19 @@ if (distinctFieldNames!(Specs))
assert(t == AliasSeq!(1, Bad(1), "asdf"));
}

// Ensure Tuple.toHash works
@safe unittest
{
Tuple!(int, int) point;
assert(point.toHash == typeof(point).init.toHash);
assert(tuple(1, 2) != point);
assert(tuple(1, 2) == tuple(1, 2));
point[0] = 1;
assert(tuple(1, 2) != point);
point[1] = 2;
assert(tuple(1, 2) == point);
}

/**
Creates a copy of a $(LREF Tuple) with its fields in _reverse order.
Expand Down

0 comments on commit b5970ce

Please sign in to comment.