@@ -129,25 +129,6 @@ private template canBitwiseHash(T)
129129 }
130130}
131131
132- private template UnqualUnsigned (T) if (__traits(isIntegral, T) && ! is (T == __vector ))
133- {
134- static if (T.sizeof == ubyte .sizeof) alias UnqualUnsigned = ubyte ;
135- else static if (T.sizeof == ushort .sizeof) alias UnqualUnsigned = ushort ;
136- else static if (T.sizeof == uint .sizeof) alias UnqualUnsigned = uint ;
137- else static if (T.sizeof == ulong .sizeof) alias UnqualUnsigned = ulong ;
138- else static if (T.sizeof == ulong .sizeof * 2 )
139- {
140- static assert (T.sizeof == ucent .sizeof);
141- alias UnqualUnsigned = ucent ;
142- }
143- else
144- {
145- static assert (0 , " No known unsigned equivalent of " ~ T.stringof);
146- }
147-
148- static assert (UnqualUnsigned.sizeof == T.sizeof && __traits(isUnsigned, UnqualUnsigned));
149- }
150-
151132// Overly restrictive for simplicity: has false negatives but no false positives.
152133private template useScopeConstPassByValue (T)
153134{
@@ -344,7 +325,7 @@ if (!is(T == enum) && !is(T : typeof(null)) && is(T S: S[]) && !__traits(isStati
344325size_t hashOf (T)(scope const T val) if (! is (T == enum ) && __traits(isArithmetic, T)
345326 && __traits(isIntegral, T) && T.sizeof <= size_t .sizeof && ! is (T == __vector ))
346327{
347- return cast (UnqualUnsigned ! T) val;
328+ return val;
348329}
349330
350331// arithmetic type hash
@@ -371,10 +352,10 @@ size_t hashOf(T)(scope const T val, size_t seed) if (!is(T == enum) && __traits(
371352 enum uint r1 = 31 ;
372353 enum uint r2 = 27 ;
373354 }
374- auto h = c1 * cast (UnqualUnsigned ! T) val;
375- h = (h << r1) | (h >>> (typeof (h) .sizeof * 8 - r1));
355+ size_t h = c1 * val;
356+ h = (h << r1) | (h >>> (size_t .sizeof * 8 - r1));
376357 h = (h * c2) ^ seed;
377- h = (h << r2) | (h >>> (typeof (h) .sizeof * 8 - r2));
358+ h = (h << r2) | (h >>> (size_t .sizeof * 8 - r2));
378359 return h * 5 + c3;
379360}
380361
0 commit comments