Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace reinterpret_cast with static_cast. #181

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

DoctorNoobingstoneIPresume

Conversion between pointers of unrelated types Source and Target can be done with static_cast => IMO should be done with static_cast (in order not to give the impression that reinterpret_cast really is needed):

T *ptr_target = static_cast <T *> (static_cast <void *> (ptr_source));

IMO reinterpret_cast should be used for pointer-to-integral and integral-to-pointer conversions (only).

Conversion between pointers of unrelated types `Source` and `Target`
can be done with `static_cast` => IMO should be done with `static_cast`
(in order not to give the impression that `reinterpret_cast` really is needed):

  `T *ptr_target = static_cast <T *> (static_cast <void *> (ptr_source));`

IMO `reinterpret_cast` should be used for pointer-to-integral and integral-to-pointer
conversions (only).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant