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:
Joe Groff
2015-05-22 05:47:29 +00:00
parent eef3fab391
commit d1b6fa32c4
10 changed files with 517 additions and 480 deletions

View File

@@ -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 {