This code used for building bit pattern from array of bits gives me error in Xcode 9 (works in 8.3.3)
@_specialize(UInt8)
func integerFrom<T: UnsignedInteger>(_ bits: Array<Bit>) -> T {
var bitPattern: T = 0
for idx in bits.indices {
if bits[idx] == Bit.one {
let bit = T(UIntMax(1) << UIntMax(idx))
bitPattern = bitPattern | bit
}
}
return bitPattern
}
Error
Unknown parameter UInt8 in '_specialize attribute'
Any leads/suggestion on this?
You just need to include a where clause in the specialize definition like this
@_specialize(where T == UInt8)