-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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 std::bind with lambdas #4017
Conversation
problem solved with Fix potential bad weak_ptr usage commitSorry to bother but I've been testing the changes a bit more and I ran into a problem, I don't know if it's due to my custom sources or if this could also be happening in TFS. Everything compiles successfully, you can even enter with any player, however when disconnecting the player this error can happen, when I place a breakpoint here it increases the probability that the error will not occur Note: In fact, if I do it, I go through the interruption points very slowly, clicking the Continue button every 5 seconds or more, there is no problem. Basically the call stack is as follows: ProtocolGame::logout |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, I feel like we should have a style where the lambda body is always on its own lines, some of those "short" one-liners are actually long eye sores, is there a formatting standard we can adopt, since lambdas are not common in the codebase yet?
@DSpeichert that's definitely what I'm doing next. I spoke to @EPuncker about a standard code style + static analysis + unit testing, however that would be a separate PR |
Pull Request Prelude
Changes Proposed
std::bind is bad for several reasons:
(source)
See also detailed explanation by Jason Turner.
Additionally, move non-trivial types into lambdas to avoid expensive copies for temporary values, and used lambdas where we tried to work around
std::bind
's lack of flexibility.