File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1168,12 +1168,12 @@ if (distinctFieldNames!(Specs))
11681168 Returns:
11691169 A `size_t` representing the hash of this `Tuple`.
11701170 */
1171- size_t toHash () const nothrow @safe
1171+ size_t toHash () const nothrow @trusted
11721172 {
11731173 size_t h = 0 ;
11741174 static foreach (i, T; Types)
11751175 {{
1176- const k = typeid (T).getHash((() @trusted => cast ( const void * ) & field[i])() );
1176+ const k = hashOf( field[i]);
11771177 static if (i == 0 )
11781178 h = k;
11791179 else
@@ -1473,6 +1473,19 @@ if (distinctFieldNames!(Specs))
14731473 assert (t == AliasSeq! (1 , Bad(1 ), " asdf" ));
14741474}
14751475
1476+ // Ensure Tuple.toHash works
1477+ @safe unittest
1478+ {
1479+ Tuple ! (int , int ) point;
1480+ assert (point.toHash == typeof (point).init.toHash);
1481+ assert (tuple(1 , 2 ) != point);
1482+ assert (tuple(1 , 2 ) == tuple(1 , 2 ));
1483+ point[0 ] = 1 ;
1484+ assert (tuple(1 , 2 ) != point);
1485+ point[1 ] = 2 ;
1486+ assert (tuple(1 , 2 ) == point);
1487+ }
1488+
14761489/**
14771490 Creates a copy of a $(LREF Tuple) with its fields in _reverse order.
14781491
You can’t perform that action at this time.
0 commit comments