UnsafePointer

struct UnsafePointer<Memory>

A pointer to an object of type Memory. This type provides no automated memory management, and therefore the user must take care to allocate and free memory appropriately.

The pointer should be aligned to alignof(Memory.self).

The pointer can be in one of the following states:

  • memory is not allocated (for example, pointer is null, or memory has been deallocated previously);

  • memory is allocated, but value has not been initialized;

  • memory is allocated and value is initialized.

Inheritance BidirectionalIndexType, CVarArgType, Comparable, CustomDebugStringConvertible, Equatable, ForwardIndexType, Hashable, NilLiteralConvertible, RandomAccessIndexType, Strideable, _Incrementable, _PointerType, _RandomAccessAmbiguity, _Reflectable, _Strideable View Protocol Hierarchy →
Associated Types
Distance = Int
Import import Swift

Initializers

init()

Construct a null pointer.

Declaration

init()
init(_: COpaquePointer)

Convert from an opaque C pointer to a typed pointer.

This is a fundamentally unsafe conversion.

Declaration

init(_ other: COpaquePointer)
init<U>(_: UnsafeMutablePointer<U>)

Convert from an UnsafeMutablePointer of a different type.

This is a fundamentally unsafe conversion.

Declaration

init<U>(_ from: UnsafeMutablePointer<U>)
init<U>(_: UnsafePointer<U>)

Convert from a UnsafePointer of a different type.

This is a fundamentally unsafe conversion.

Declaration

init<U>(_ from: UnsafePointer<U>)
init(bitPattern: Int)

Construct an UnsafePointer from a given address in memory.

This is a fundamentally unsafe conversion.

Declaration

init(bitPattern: Int)
init(bitPattern: UInt)

Construct an UnsafePointer from a given address in memory.

This is a fundamentally unsafe conversion.

Declaration

init(bitPattern: UInt)
init(nilLiteral:)

Create an instance initialized with nil.

Declaration

init(nilLiteral: ())

Instance Variables

var debugDescription: String

A textual representation of self, suitable for debugging.

Declaration

var debugDescription: String { get }
var hashValue: Int

The hash value.

Axiom: x == y implies x.hashValue == y.hashValue.

Note: The hash value is not guaranteed to be stable across different invocations of the same program. Do not persist the hash value across program runs.

Declaration

var hashValue: Int { get }
var memory: Memory

Access the underlying raw memory, getting values.

Declaration

var memory: Memory { get }

Subscripts

subscript(_: Int)

Declaration

subscript(i: Int) -> Memory { get }

Instance Methods

func advancedBy(_:)

Declaration

func advancedBy(n: Int) -> UnsafePointer<Memory>

Declared In

UnsafePointer, RandomAccessIndexType, BidirectionalIndexType, _RandomAccessAmbiguity, ForwardIndexType
func advancedBy(_:limit:)

Declaration

func advancedBy(n: UnsafePointer<Memory>.Distance, limit: UnsafePointer<Memory>) -> UnsafePointer<Memory>

Declared In

RandomAccessIndexType, BidirectionalIndexType, ForwardIndexType
func distanceTo(_:)

Declaration

func distanceTo(x: UnsafePointer<Memory>) -> Int

Declared In

UnsafePointer, RandomAccessIndexType, BidirectionalIndexType, ForwardIndexType
func predecessor()

Returns the previous consecutive value before self.

Requires: The previous value is representable.

Declaration

func predecessor() -> UnsafePointer<Memory>
func stride(through:by:)

Return the sequence of values (start, start + stride, start + stride + stride, ... last) where last is the last value in the progression less than or equal to end.

Note: There is no guarantee that end is an element of the sequence.

Declaration

func stride(through end: UnsafePointer<Memory>, by stride: UnsafePointer<Memory>.Stride) -> StrideThrough<UnsafePointer<Memory>>

Declared In

RandomAccessIndexType, Strideable
func stride(to:by:)

Return the sequence of values (self, self + stride, self + stride + stride, ... last) where last is the last value in the progression that is less than end.

Declaration

func stride(to end: UnsafePointer<Memory>, by stride: UnsafePointer<Memory>.Stride) -> StrideTo<UnsafePointer<Memory>>

Declared In

RandomAccessIndexType, Strideable
func successor()

Returns the next consecutive value after self.

Requires: The next value is representable.

Declaration

func successor() -> UnsafePointer<Memory>