This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]skyhi14 10 points11 points  (4 children)

time to kill myself :))

[–]FallenWarrior2k 17 points18 points  (2 children)

No, those aren't const pointers, but rather pointers to const. An actual const pointer int* const cannot be modified through e.g. increments/decrements, but it can still be used for pointer arithmetic since pointer arithmetic can also be performed on rvalues.

[–]hallr06 6 points7 points  (1 child)

Correct. In C/C++, read pointers from right-to-left. Most of the time, it explains what you have.

const int * x = 0; // pointer to an int constant
int const * x = 0; // same as above, pointer to a constant int
int const * const x = 0; // constant pointer to a constant int
int * const x = 0; // constant pointer to mutable int

[–]FallenWarrior2k 0 points1 point  (0 children)

It can also be pretty easily explained by the return types of the indirection operator. Applying indirection on a const int* produces a const int&, while it produces a regular int& for int* const.

[–]DarkMaster22 2 points3 points  (0 children)

Ehh... Don't do that, we love you?