mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[stdlib] Nest some additional operators (#9646)
This commit is contained in:
@@ -469,6 +469,14 @@ public struct AutoreleasingUnsafeMutablePointer<Pointee /* TODO : class */>
|
|||||||
guard let unwrapped = from else { return nil }
|
guard let unwrapped = from else { return nil }
|
||||||
self.init(unwrapped)
|
self.init(unwrapped)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@_transparent
|
||||||
|
public static func == (
|
||||||
|
lhs: AutoreleasingUnsafeMutablePointer,
|
||||||
|
rhs: AutoreleasingUnsafeMutablePointer
|
||||||
|
) -> Bool {
|
||||||
|
return Bool(Builtin.cmp_eq_RawPointer(lhs._rawValue, rhs._rawValue))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension UnsafeMutableRawPointer {
|
extension UnsafeMutableRawPointer {
|
||||||
@@ -523,14 +531,6 @@ extension AutoreleasingUnsafeMutablePointer : CustomDebugStringConvertible {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@_transparent
|
|
||||||
public func == <Pointee>(
|
|
||||||
lhs: AutoreleasingUnsafeMutablePointer<Pointee>,
|
|
||||||
rhs: AutoreleasingUnsafeMutablePointer<Pointee>
|
|
||||||
) -> Bool {
|
|
||||||
return Bool(Builtin.cmp_eq_RawPointer(lhs._rawValue, rhs._rawValue))
|
|
||||||
}
|
|
||||||
|
|
||||||
@_fixed_layout
|
@_fixed_layout
|
||||||
@_versioned
|
@_versioned
|
||||||
internal struct _CocoaFastEnumerationStackBuf {
|
internal struct _CocoaFastEnumerationStackBuf {
|
||||||
|
|||||||
@@ -103,20 +103,18 @@ extension LazySequenceProtocol {
|
|||||||
public struct LazyDropWhileIndex<Base : Collection> : Comparable {
|
public struct LazyDropWhileIndex<Base : Collection> : Comparable {
|
||||||
/// The position corresponding to `self` in the underlying collection.
|
/// The position corresponding to `self` in the underlying collection.
|
||||||
public let base: Base.Index
|
public let base: Base.Index
|
||||||
}
|
|
||||||
|
|
||||||
public func == <Base>(
|
public static func == (
|
||||||
lhs: LazyDropWhileIndex<Base>,
|
lhs: LazyDropWhileIndex, rhs: LazyDropWhileIndex
|
||||||
rhs: LazyDropWhileIndex<Base>
|
) -> Bool {
|
||||||
) -> Bool {
|
return lhs.base == rhs.base
|
||||||
return lhs.base == rhs.base
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public func < <Base>(
|
public static func < (
|
||||||
lhs: LazyDropWhileIndex<Base>,
|
lhs: LazyDropWhileIndex, rhs: LazyDropWhileIndex
|
||||||
rhs: LazyDropWhileIndex<Base>
|
) -> Bool {
|
||||||
) -> Bool {
|
return lhs.base < rhs.base
|
||||||
return lhs.base < rhs.base
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
% for Traversal in ['Forward', 'Bidirectional']:
|
% for Traversal in ['Forward', 'Bidirectional']:
|
||||||
|
|||||||
@@ -1424,12 +1424,12 @@ public enum FloatingPointRoundingRule {
|
|||||||
case awayFromZero
|
case awayFromZero
|
||||||
}
|
}
|
||||||
|
|
||||||
@_transparent
|
|
||||||
public func == <T : FloatingPoint>(lhs: T, rhs: T) -> Bool {
|
|
||||||
return lhs.isEqual(to: rhs)
|
|
||||||
}
|
|
||||||
|
|
||||||
extension FloatingPoint {
|
extension FloatingPoint {
|
||||||
|
@_transparent
|
||||||
|
public static func == (lhs: Self, rhs: Self) -> Bool {
|
||||||
|
return lhs.isEqual(to: rhs)
|
||||||
|
}
|
||||||
|
|
||||||
@_transparent
|
@_transparent
|
||||||
public static func < (lhs: Self, rhs: Self) -> Bool {
|
public static func < (lhs: Self, rhs: Self) -> Bool {
|
||||||
return lhs.isLess(than: rhs)
|
return lhs.isLess(than: rhs)
|
||||||
|
|||||||
@@ -428,14 +428,13 @@ public struct ManagedBufferPointer<Header, Element> : Equatable {
|
|||||||
toAlignment: MemoryLayout<Element>.alignment)
|
toAlignment: MemoryLayout<Element>.alignment)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal var _nativeBuffer: Builtin.NativeObject
|
public static func == (
|
||||||
}
|
lhs: ManagedBufferPointer, rhs: ManagedBufferPointer
|
||||||
|
) -> Bool {
|
||||||
|
return lhs._address == rhs._address
|
||||||
|
}
|
||||||
|
|
||||||
public func == <Header, Element>(
|
internal var _nativeBuffer: Builtin.NativeObject
|
||||||
lhs: ManagedBufferPointer<Header, Element>,
|
|
||||||
rhs: ManagedBufferPointer<Header, Element>
|
|
||||||
) -> Bool {
|
|
||||||
return lhs._address == rhs._address
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: when our calling convention changes to pass self at +0,
|
// FIXME: when our calling convention changes to pass self at +0,
|
||||||
|
|||||||
@@ -111,33 +111,31 @@ public struct LazyPrefixWhileIndex<Base : Collection> : Comparable {
|
|||||||
internal init(endOf: Base) {
|
internal init(endOf: Base) {
|
||||||
self._value = .pastEnd
|
self._value = .pastEnd
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public func == <Base>(
|
public static func == (
|
||||||
lhs: LazyPrefixWhileIndex<Base>,
|
lhs: LazyPrefixWhileIndex, rhs: LazyPrefixWhileIndex
|
||||||
rhs: LazyPrefixWhileIndex<Base>
|
) -> Bool {
|
||||||
) -> Bool {
|
switch (lhs._value, rhs._value) {
|
||||||
switch (lhs._value, rhs._value) {
|
case let (.index(l), .index(r)):
|
||||||
case let (.index(l), .index(r)):
|
return l == r
|
||||||
return l == r
|
case (.pastEnd, .pastEnd):
|
||||||
case (.pastEnd, .pastEnd):
|
return true
|
||||||
return true
|
default:
|
||||||
default:
|
return false
|
||||||
return false
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public func < <Base>(
|
public static func < (
|
||||||
lhs: LazyPrefixWhileIndex<Base>,
|
lhs: LazyPrefixWhileIndex, rhs: LazyPrefixWhileIndex
|
||||||
rhs: LazyPrefixWhileIndex<Base>
|
) -> Bool {
|
||||||
) -> Bool {
|
switch (lhs._value, rhs._value) {
|
||||||
switch (lhs._value, rhs._value) {
|
case let (.index(l), .index(r)):
|
||||||
case let (.index(l), .index(r)):
|
return l < r
|
||||||
return l < r
|
case (.index, .pastEnd):
|
||||||
case (.index, .pastEnd):
|
return true
|
||||||
return true
|
default:
|
||||||
default:
|
return false
|
||||||
return false
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,15 +55,16 @@ public protocol ${Self} : ${Conformance} {
|
|||||||
|
|
||||||
% end
|
% end
|
||||||
|
|
||||||
/// Compare two `Strideable`s.
|
extension Strideable {
|
||||||
@_inlineable
|
@_inlineable
|
||||||
public func < <T : Strideable>(x: T, y: T) -> Bool {
|
public static func < (x: Self, y: Self) -> Bool {
|
||||||
return x.distance(to: y) > 0
|
return x.distance(to: y) > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@_inlineable
|
@_inlineable
|
||||||
public func == <T : Strideable>(x: T, y: T) -> Bool {
|
public static func == (x: Self, y: Self) -> Bool {
|
||||||
return x.distance(to: y) == 0
|
return x.distance(to: y) == 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|||||||
Reference in New Issue
Block a user