UnsafePointer

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
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<U>(_: UnsafeMutablePointer<U>)

Convert from an UnsafeMutablePointer of a different type.

This is a fundamentally unsafe conversion.

Declaration

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

Convert from a UnsafePointer of a different type.

This is a fundamentally unsafe conversion.

Declaration

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(_:limit:)

Declaration

Declared In

RandomAccessIndexType, BidirectionalIndexType, ForwardIndexType
func predecessor()

Returns the previous consecutive value before self.

Requires: The previous value is representable.

Declaration

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

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

Declared In

RandomAccessIndexType, Strideable
func successor()

Returns the next consecutive value after self.

Requires: The next value is representable.

Declaration

3 inherited items hidden. (Show all)