-
Notifications
You must be signed in to change notification settings - Fork 282
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
More migration to size_t #2145
More migration to size_t #2145
Conversation
This pull request introduces 6 alerts when merging b20e073 into 7aae68e - view on LGTM.com new alerts:
|
Seems good at first glance. I do wonder whether or not static_cast is needlessly verbose. In my code I prefer to use functional casts, eg. size_t(x). |
Whenever you use C++ it is better to use the C++ casts because they just do what you specify. The usage of C-style casts can be actually dangerous in some cases, because they try to do different kind of casts in a determined order. You can find more information here: Anyways, as I mentioned in this PR and in others, the intention is to remove as many static_casts as possible from the codebase. They are normally a code smell indicating that a better data model could reduce the need of them. |
I like Rosen's idea to use function casts. The static cast syntax is ugly and the C cast is hackery. |
Well, the function cast is the same as a C cast. Just looks less ugly and avoids the C cast clang-tidy warning. I like using it for simple types like size_t where the compiler's not really going to do anything strange. |
The equivalent of a cast in Pascal was I read an interview with Stroudstup and he said something like "C++20 is the language I set out the make in the first place". I wonder if it will be as nice as Pascal. |
Codecov Report
@@ Coverage Diff @@
## main #2145 +/- ##
==========================================
- Coverage 63.31% 63.27% -0.05%
==========================================
Files 97 97
Lines 19152 19159 +7
Branches 9724 9721 -3
==========================================
- Hits 12127 12123 -4
- Misses 4762 4778 +16
+ Partials 2263 2258 -5
Continue to review full report at Codecov.
|
This pull request introduces 4 alerts when merging 4355d63 into 173ebb2 - view on LGTM.com new alerts:
|
The PR is now ready for review after I fixed problems reported by the CI jobs. @neheb & @clanmills , IMHO I think that the discussion about the casting style is offtopic (This PR is probably not the best place to discuss such things. I am actually mostly removing casts here). Feel free to open another issue or trigger this conversation in the team chat. |
You're quite right, @piponazo. Apologies for the noise. |
No worries, I appreciate interesting discussions in the right channels 😁 |
Continuation of the work done to avoid some of the static_casts we have around the code base. See other recent PRs: #2118 #2109 #2062