The following code generates a segmentation error:
extension Int { static prefix func++(i:Int)->Int{ return i+1; } static prefix func--(i:Int)->Int{ return i-1; } } infix operator <-; class DynamicList<T>: RangeReplaceableCollection, MutableCollection, BidirectionalCollection { var length:Int; var arr:Array<T>?; var startIndex:Int{ return 0; } var endIndex:Int{ return length; } subscript(i:Int)->T{ get{ return arr![i]; } set{ arr![i] = newValue; } } func index(after i: Int) -> Int{ return ++i; } func index(before i: Int) -> Int{ return --i; } required init(){ length = 0; } static func <- (left: inout DynamicList<T>, right: DynamicList<T>){ } /* func replaceSubrange<C>(_ subrange: Range<Self.Index>, with newElements: C) where C : Collection, C.Iterator.Element == Iterator.Element */ func replaceSubrange<C>(_ subrange: Range<DynamicList.Index>, with c: C) where C : Collection, C.Iterator.Element == DynamicList.Iterator.Element{ } } My intent here is to have the generic class `DynamicList<T>` adopt three protocols: `class DynamicList<T>: RangeReplaceableCollection, MutableCollection, BidirectionalCollection` as indicated in the code above but it generates segmentation error. However, when I replace `MutableCollection` with `Collection`, code above complies. If I remove `BidirectionalCollection`, the code above compiles with no segmentation error. Is it not possible to adopt all 3: - RangeReplaceableCollection - MutableCollection - BidirectionalCollection at the same time? Thanks. _______________________________________________ swift-users mailing list swift-users@swift.org https://lists.swift.org/mailman/listinfo/swift-users