File tree Expand file tree Collapse file tree 1 file changed +6
-0
lines changed
Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ proc toUncheckedArray*[T](a: ptr T): ptr UncheckedArray[T] {.inline.} =
1717 cast [ptr UncheckedArray [T]](a)
1818
1919template `+` * [T](p: ptr T, off: int ): ptr T =
20+ # # Unsafe.
2021 runnableExamples:
2122 var a = @ [10 , 11 , 12 ]
2223 let pa = a[0 ].addr
@@ -28,18 +29,23 @@ template `+`*[T](p: ptr T, off: int): ptr T =
2829 cast [ptr T](cast [ByteAddress ](p) +% off * sizeof (T))
2930
3031template `-` * [T](p: ptr T, off: int ): ptr T =
32+ # # Unsafe.
3133 type T = typeof (p[])
3234 cast [ptr T](cast [ByteAddress ](p) -% off * sizeof (T))
3335
3436template `[]` * [T](p: ptr T, off: int ): T =
37+ # # Unsafe.
3538 (p + off )[]
3639
3740template `[]=` * [T](p: ptr T, off: int , val: T) =
41+ # # Unsafe.
3842 (p + off )[] = val
3943
4044proc `+=` * [T](p: var ptr T, off: int ) {.inline .} =
45+ # # Unsafe.
4146 # not a template to avoid double evaluation issues
4247 p = p + off
4348
4449proc `-=` * [T](p: var ptr T, off: int ) {.inline .} =
50+ # # Unsafe.
4551 p = p - off
You can’t perform that action at this time.
0 commit comments