Generic Function

swap(_:_:)

Exchanges the values of the two arguments.

Declaration

func swap<T>(_ a: inout T, _ b: inout T)

Parameters

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

func withUnsafePointer<T, Result>(to: T, (UnsafePointer<T>) -> Result) -> Result

Invokes the given closure with a pointer to the given argument.

func withUnsafePointer<T, Result>(to: inout T, (UnsafePointer<T>) -> Result) -> Result

Invokes the given closure with a pointer to the given argument.

func withUnsafeMutablePointer<T, Result>(to: inout T, (UnsafeMutablePointer<T>) -> Result) -> Result

Calls the given closure with a mutable pointer to the given argument.

func withUnsafeBytes<T, Result>(of: T, (UnsafeRawBufferPointer) -> Result) -> Result

Invokes the given closure with a buffer pointer covering the raw bytes of the given argument.

func withUnsafeBytes<T, Result>(of: inout T, (UnsafeRawBufferPointer) -> Result) -> Result

Invokes the given closure with a buffer pointer covering the raw bytes of the given argument.

func withUnsafeMutableBytes<T, Result>(of: inout T, (UnsafeMutableRawBufferPointer) -> Result) -> Result

Invokes the given closure with a mutable buffer pointer covering the raw bytes of the given argument.