refactor: replace all implicit C-style const/const+reinterpret with explicit casts#27126
refactor: replace all implicit C-style const/const+reinterpret with explicit casts#27126PastaPastaPasta wants to merge 1 commit into
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ReviewsSee the guideline for information on the review process. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
0577c0e to
30ac5ae
Compare
| testArgs.SetupArgs({foo, bar}); | ||
| std::string error; | ||
| BOOST_CHECK(testArgs.ParseParameters(4, (char**)argv_test, error)); | ||
| BOOST_CHECK(testArgs.ParseParameters(4, const_cast<char**>(argv_test), error)); |
There was a problem hiding this comment.
Instead of changing one cast to another, it might be better to just use a span? But not sure if such refactoring is still worth it, then
There was a problem hiding this comment.
That might make sense. If I get more time sometime soon, I'll see if I can easily span-ify it. Overall, I prefer no cast over any cast; but if I cannot figure it out for some reason then I think it makes sense to still include it in this PR
There was a problem hiding this comment.
That might make sense. If I get more time sometime soon, I'll see if I can easily span-ify it.
There doesn't seem to be much buy-in to making this change, and there's no real rush in any case, so feel free to look at using the Spans. Could probably mark this as a draft for now, if that is what you're going to look at.
|
This PR does not seem to have conceptual support. Please leave a comment if you would like this to be reopened. |
This PR aims to replace all implicit C-style const (and const+reinterpret) casts with explicit casts to improve the code's readability and maintainability.
Implicit casts can cause subtle issues and can introduce undefined behavior. Explicit casting improves the code's readability and makes it easier to understand the intent of the code. Additionally, it makes it easier for developers to grep for these casts and do more substantial refactoring that may eliminate the need for casting altogether. By doing this change, it will be easier to maintain this code in the future.
Overall, these changes are straightforward and only involve replacing existing code with explicit casts. The changes improve the readability and maintainability of the codebase and do not introduce any new functionality.
Additionally, as this only replaces const_casts; there should be very few (if any) conflicts with other PRs.