I just downloaded Xcode 10.2 beta 4 to start porting my Apps to Swift 5. In Swift 4.x SIMD types like double3 or float4 conformed to the Collection protocol allowing code such as:
let v: double3
var va = v.map({ abs($0) })
let vs = va.sorted()
Is this intentionally in Swift 5 or just not yet finished? I tried to extend SIMD3 generic type in Swift 5 to conform to the Collection protocol but got some errors, I do not know how to solve:
extension SIMD3 : Collection {
public var startIndex: Int {
return 0
}
public var endIndex: Int {
return 2
}
public func index(after i: Int) -> Int {
return i+1
}
}
error: type 'SIMD3<Scalar>' does not conform to protocol 'Collection'
extension SIMD3 : Collection {
^
Swift.Collection:13:20: note: ambiguous inference of associated type 'Indices': 'DefaultIndices<SIMD3<Scalar>>' vs. 'Range<Int>'
associatedtype Indices : Collection = DefaultIndices<Self> where Self.Indices == Self.Indices.SubSequence
^
Swift.Collection:2:27: note: matching requirement 'indices' to this declaration inferred associated type to 'DefaultIndices<SIMD3<Scalar>>'
@inlinable public var indices: DefaultIndices<Self> { get }
^
Swift.SIMD:2:16: note: matching requirement 'indices' to this declaration inferred associated type to 'Range<Int>'
public var indices: Range<Int> { get }
Any help would be appreciated. Best, Fritzt