File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments