Skip to content

Commit b5970ce

Browse files
committed
Disabled toHash in -betterC for now
TypeInfo is part of DRuntime. See: #5952 Replaced `toHash` with a parameter-less template for codegen on demand.
1 parent 552d139 commit b5970ce

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

std/typecons.d

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,12 +1169,12 @@ if (distinctFieldNames!(Specs))
11691169
Returns:
11701170
A `size_t` representing the hash of this `Tuple`.
11711171
*/
1172-
size_t toHash() const nothrow @safe
1172+
size_t toHash() const nothrow @trusted
11731173
{
11741174
size_t h = 0;
11751175
static foreach (i, T; Types)
11761176
{{
1177-
const k = typeid(T).getHash((() @trusted => cast(const void*) &field[i])());
1177+
const k = hashOf(field[i]);
11781178
static if (i == 0)
11791179
h = k;
11801180
else
@@ -1474,6 +1474,19 @@ if (distinctFieldNames!(Specs))
14741474
assert(t == AliasSeq!(1, Bad(1), "asdf"));
14751475
}
14761476

1477+
// Ensure Tuple.toHash works
1478+
@safe unittest
1479+
{
1480+
Tuple!(int, int) point;
1481+
assert(point.toHash == typeof(point).init.toHash);
1482+
assert(tuple(1, 2) != point);
1483+
assert(tuple(1, 2) == tuple(1, 2));
1484+
point[0] = 1;
1485+
assert(tuple(1, 2) != point);
1486+
point[1] = 2;
1487+
assert(tuple(1, 2) == point);
1488+
}
1489+
14771490
/**
14781491
Creates a copy of a $(LREF Tuple) with its fields in _reverse order.
14791492

0 commit comments

Comments
 (0)