Unknown UInt8 parameter in '_specialize attribute': Xcode 9

This code used to build a bit pattern from an array of bits gives me an 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 UInt8 parameter in '_specialize attribute'

Any suggestions / suggestions on this?

+4
source share
1 answer

You just need to include the where clause in your specialization definition like this

@_specialize(where T == UInt8)
+8
source

Source: https://habr.com/ru/post/1679219/


All Articles