The compiler chooses the version that matches in the context:
uchar c = *var.ptr();
const uchar *p = var.ptr();
*var.ptr() = c;
uchar *p = var.ptr();
It is not really necessary to provide the
const
version but it is recommended, good style, and prevents from changing values inadvertently where this is checked at compile time:
const uchar *p = var.ptr();
*p = c;