Useful yes, but he C++ language's rules are very strict, limited, and complex regarding casting pointers, especially if you then dereference the pointer. I even strive to stay on the conservative side of those rules.
-
You can cast a pointer to a void * type and then cast it back to the original pointer type. After doing so, you may safely dereference it.
-
You can safely cast a pointer to a byte pointer (i.e. uint8_t * or unsigned char *). You may then dereference the byte pointer to read or write the underlying bytes that make up the object to which the original pointer was pointing.
-
You may not dereference the null pointer (obviously).
That’s basically all I ever do with pointer casting as I think it keeps me safely within the rules.