How to perform pointer arithmetic?

Viewed 76

I'm new to the Carbon language, how to perform pointer arithmetic? Is this even possible?

p = p + 1;

=>

COMPILATION ERROR: <source>:11: type error in `+`:
could not find implementation of interface AddWith(U = i32) for i32*
Compiler returned: 1
1 Answers

Carbon does not support pointer arithmetic. The only two operations are

  • dereference (*p gives the l-value p points to),
  • address-of (&v gives the address of l-value v).

More detail is available in carbon design notes.

Related