mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
That is, if we need a type MyIndex<T> to be a valid ForwardIndex, we should be able to find it in the conformance for BidirectionalIndex, which inherits from ForwardIndex. <rdar://problem/15484898> Swift SVN r11270
17 lines
363 B
Swift
17 lines
363 B
Swift
// Adopt ForwardIndex via BidirectionalIndex.
|
|
struct Counter<T: protocol<RandomAccessIndex, IntegerLiteralConvertible>> : BidirectionalIndex {
|
|
var value = 0
|
|
|
|
func __equal__(rhs: Counter) -> Bool {
|
|
return value == rhs.value
|
|
}
|
|
|
|
func pred() -> Counter {
|
|
return Counter(value - 1)
|
|
}
|
|
|
|
func succ() -> Counter {
|
|
return Counter(value + 1)
|
|
}
|
|
}
|