swap(_:_:)
Exchanges the values of the two arguments.
Declaration
func swap<T>(_ a: inout T, _ b: inout T) where T : ~CopyableParameters
- a:
The first value to swap.
- b:
The second value to swap.
Discussion
The two arguments must not alias each other. To swap two elements of a mutable collection, use the swapAt(_:_:) method of that collection instead of this function.
See Also
Memory Access
withUnsafePointer(to:_:)withUnsafePointer(to:_:)withUnsafeMutablePointer(to:_:)withUnsafeBytes(of:_:)withUnsafeMutableBytes(of:_:)withTemporaryAllocation(byteCount:alignment:_:)withTemporaryAllocation(of:capacity:_:)withUnsafeTemporaryAllocation(of:capacity:_:)withUnsafeTemporaryAllocation(byteCount:alignment:_:)exchange(_:with:)