nondescript/pointerutils.nim

9 lines
238 B
Nim

template padd*[T](x: ptr T, num: int): ptr T =
cast[ptr T](cast[int](x) + num)
template psub*[T](x: ptr T, num: int): ptr T =
cast[ptr T](cast[int](x) - num)
template pdiff*[T](x: ptr T, y: ptr): int =
cast[int](x) - cast[int](y)