//===--- MixedStringNSStringOperations.swift.gyb --------------*- swift -*-===// // // This source file is part of the Swift.org open source project // // Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See http://swift.org/LICENSE.txt for license information // See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// // // Mixed-type comparisons between String and NSString. // % for op in [ '==', '!=', '<', '<=', '>=', '>' ]: @transparent public func ${op} (lhs: String, rhs: NSString) -> Bool { // FIXME(performance): constructing a temporary string is extremely // wasteful and inefficient. return lhs ${op} (rhs as String) } @transparent public func ${op} (lhs: NSString, rhs: String) -> Bool { // FIXME(performance): constructing a temporary string is extremely // wasteful and inefficient. return (lhs as String) ${op} rhs } % end public func != (lhs: String, rhs: String) -> Bool { // FIXME(performance): constructing a temporary string is extremely // wasteful and inefficient. return !(lhs == rhs) } public func <= (lhs: String, rhs: String) -> Bool { // FIXME(performance): constructing a temporary string is extremely // wasteful and inefficient. return !(rhs < lhs) } public func >= (lhs: String, rhs: String) -> Bool { // FIXME(performance): constructing a temporary string is extremely // wasteful and inefficient. return !(lhs < rhs) } public func > (lhs: String, rhs: String) -> Bool { // FIXME(performance): constructing a temporary string is extremely // wasteful and inefficient. return rhs < lhs } // This overload is required to disambiguate homogeneous NSString/NSString // comparisons in non-generic code. @transparent public func == (lhs: NSString, rhs: NSString) -> Bool { return lhs as NSObject == rhs as NSObject } // This overload is required to disambiguate homogeneous NSString/NSString // comparisons in non-generic code. @transparent public func != (lhs: NSString, rhs: NSString) -> Bool { return !(lhs == rhs) }