mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Revert "Revert "[stdlib] Land OptionSetType et. al.""
This recommits r28892, r28894, and r28895; the previous commits should have addressed the previous breakage. Swift SVN r28905
This commit is contained in:
@@ -60,6 +60,29 @@ public protocol _RawOptionSetType : RawRepresentable, Equatable {
|
||||
init(rawValue: RawValue)
|
||||
}
|
||||
|
||||
/// Returns `true` iff `lhs.rawValue == rhs.rawValue`.
|
||||
public func == <
|
||||
T : RawRepresentable where T.RawValue : Equatable
|
||||
>(lhs: T, rhs: T) -> Bool {
|
||||
return lhs.rawValue == rhs.rawValue
|
||||
}
|
||||
|
||||
/// Returns `true` iff `lhs.rawValue != rhs.rawValue`.
|
||||
public func != <
|
||||
T : RawRepresentable where T.RawValue : Equatable
|
||||
>(lhs: T, rhs: T) -> Bool {
|
||||
return lhs.rawValue != rhs.rawValue
|
||||
}
|
||||
|
||||
// This overload is needed for ambiguity resolution against the
|
||||
// implementation of != for T : Equatable
|
||||
/// Returns `true` iff `lhs.rawValue != rhs.rawValue`.
|
||||
public func != <
|
||||
T : Equatable where T : RawRepresentable, T.RawValue : Equatable
|
||||
>(lhs: T, rhs: T) -> Bool {
|
||||
return lhs.rawValue != rhs.rawValue
|
||||
}
|
||||
|
||||
public func == <T : _RawOptionSetType>(a: T, b: T) -> Bool {
|
||||
return a.rawValue == b.rawValue
|
||||
}
|
||||
@@ -77,11 +100,6 @@ public prefix func ~ <T : _RawOptionSetType>(a: T) -> T {
|
||||
return T(rawValue: ~a.rawValue)
|
||||
}
|
||||
|
||||
/// Protocol for C-like option sets.
|
||||
public protocol _OptionSetType {
|
||||
// TODO: implementation, API review
|
||||
}
|
||||
|
||||
/// Protocol for `NS_OPTIONS` imported from Objective-C.
|
||||
public protocol RawOptionSetType : _RawOptionSetType, BitwiseOperationsType,
|
||||
NilLiteralConvertible {
|
||||
|
||||
Reference in New Issue
Block a user