cast<Y extends RType> method

MemoryPointer<Y> cast<Y extends RType>()

Reinterprets this pointer as pointing to Y instead of X.

Same address/offset, no copy, no runtime check, purely a compile-time relabeling of what the memory is assumed to contain. The caller is responsible for Y actually matching the underlying data.

Implementation

MemoryPointer<Y> cast<Y extends RType>() => this as MemoryPointer<Y>;