@@ -56,7 +56,7 @@ size_t hashOf(T)(auto ref T val, size_t seed = 0) if (!is(T == enum) && __traits
56
56
}
57
57
58
58
// dynamic array hash
59
- size_t hashOf (T)(auto ref T val, size_t seed = 0 )
59
+ size_t hashOf (T)(T val, size_t seed = 0 )
60
60
if (! is (T == enum ) && ! is (T : typeof (null )) && is (T S: S[]) && ! __traits(isStaticArray, T)
61
61
&& ! is (T == struct ) && ! is (T == class ) && ! is (T == union ))
62
62
{
@@ -101,13 +101,14 @@ if (!is(T == enum) && !is(T : typeof(null)) && is(T S: S[]) && !__traits(isStati
101
101
102
102
// arithmetic type hash
103
103
@trusted @nogc nothrow pure
104
- size_t hashOf (T)(auto ref T val, size_t seed = 0 ) if (! is (T == enum ) && __traits(isArithmetic, T))
104
+ size_t hashOf (T)(scope const T val, size_t seed = 0 ) if (! is (T == enum ) && __traits(isArithmetic, T))
105
105
{
106
106
static if (__traits(isFloating, val))
107
107
{
108
108
static if (floatCoalesceZeroes || floatCoalesceNaNs)
109
109
{
110
- auto data = val;
110
+ import core.internal.traits : Unqual;
111
+ Unqual! T data = val;
111
112
// Zero coalescing not supported for deprecated complex types.
112
113
static if (floatCoalesceZeroes && is (typeof (data = 0 )))
113
114
if (data == 0 ) data = 0 ; // +0.0 and -0.0 become the same.
@@ -170,14 +171,14 @@ size_t hashOf(T)(auto ref T val, size_t seed = 0) if (!is(T == enum) && __traits
170
171
171
172
// typeof(null) hash. CTFE supported
172
173
@trusted @nogc nothrow pure
173
- size_t hashOf (T)(auto ref T val, size_t seed = 0 ) if (! is (T == enum ) && is (T : typeof (null )))
174
+ size_t hashOf (T)(scope const T val, size_t seed = 0 ) if (! is (T == enum ) && is (T : typeof (null )))
174
175
{
175
176
return hashOf (cast (void * )null , seed);
176
177
}
177
178
178
179
// Pointers hash. CTFE unsupported if not null
179
180
@trusted @nogc nothrow pure
180
- size_t hashOf (T)(auto ref T val, size_t seed = 0 )
181
+ size_t hashOf (T)(scope const T val, size_t seed = 0 )
181
182
if (! is (T == enum ) && is (T V : V* ) && ! is (T : typeof (null ))
182
183
&& ! is (T == struct ) && ! is (T == class ) && ! is (T == union ))
183
184
{
@@ -256,21 +257,21 @@ nothrow pure @safe unittest // issue 19005
256
257
257
258
// delegate hash. CTFE unsupported
258
259
@trusted @nogc nothrow pure
259
- size_t hashOf (T)(auto ref T val, size_t seed = 0 ) if (! is (T == enum ) && is (T == delegate ))
260
+ size_t hashOf (T)(scope const T val, size_t seed = 0 ) if (! is (T == enum ) && is (T == delegate ))
260
261
{
261
262
assert (! __ctfe, " unable to compute hash of " ~ T.stringof);
262
263
const (ubyte )[] bytes = (cast (const (ubyte )* )&val)[0 .. T.sizeof];
263
264
return bytesHashAlignedBy! T(bytes, seed);
264
265
}
265
266
266
267
// class or interface hash. CTFE depends on toHash
267
- size_t hashOf (T)(auto ref T val, size_t seed = 0 ) if (! is (T == enum ) && is (T == interface ) || is (T == class ))
268
+ size_t hashOf (T)(T val, size_t seed = 0 ) if (! is (T == enum ) && is (T == interface ) || is (T == class ))
268
269
{
269
270
return hashOf (val ? (cast (Object )val).toHash() : 0 , seed);
270
271
}
271
272
272
273
// associative array hash. CTFE depends on base types
273
- size_t hashOf (T)(auto ref T aa, size_t seed = 0 ) if (! is (T == enum ) && __traits(isAssociativeArray, T))
274
+ size_t hashOf (T)(T aa, size_t seed = 0 ) if (! is (T == enum ) && __traits(isAssociativeArray, T))
274
275
{
275
276
if (! aa.length) return hashOf(0 , seed);
276
277
size_t h = 0 ;
@@ -544,7 +545,7 @@ nothrow pure @system unittest // issue 18918
544
545
545
546
// This overload is for backwards compatibility.
546
547
@system pure nothrow @nogc
547
- size_t bytesHash (const (void )* buf, size_t len, size_t seed)
548
+ size_t bytesHash (scope const (void )* buf, size_t len, size_t seed)
548
549
{
549
550
return bytesHashAlignedBy! ubyte ((cast (const (ubyte )* ) buf)[0 .. len], seed);
550
551
}
0 commit comments