DIRECTOR: Really fix warning #4722
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The purpose of
Common::remove_const(andstd::remove_constoutside of ScummVM` is not to remove the const specifier from a variable, but to remove it from a type and define a non-const type in the process. It is typically use in template code, such as this example given by @lephilousophe on Discord (thanks, that saved me the trouble of creating one myself 😄 ):The previous commit to fix the warning thus did not fix anything as the code was still doing a C cast from a const type to a non-const one to remove the const specifier from the byte array. The proper way to fix that warning is to use a const_cast, as done in this pull request.
The main reason I am not committing this directly and opening a pull request is to give it more visibility, as I am sure more developers might be confused by the purpose of
Common::remove_constand use it incorrectly .