-
-
Notifications
You must be signed in to change notification settings - Fork 222
remove most ptr_fun #277
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
remove most ptr_fun #277
Conversation
src/protocol/handshake_manager.cc
Outdated
bool | ||
HandshakeManager::find(const rak::socket_address& sa) { | ||
return std::find_if(base_type::begin(), base_type::end(), std::bind1st(handshake_manager_equal(), &sa)) != base_type::end(); | ||
auto f = [&sa](const Handshake* p2) { return p2->peer_info() && sa == *rak::socket_address::cast_from(p2->peer_info()->socket_address()); }; | ||
return std::any_of(base_type::begin(), base_type::end(), f); |
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.
Wrong style, should not use an intermediate function variable.
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.
It’s pretty long though
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.
It should be multiple lines, and is what I find to be the best style for these cases.
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.
Done. clang-format seems happy.
src/protocol/handshake_manager.cc
Outdated
@@ -77,7 +72,7 @@ HandshakeManager::erase_download(DownloadMain* info) { | |||
return info != h->download(); | |||
}); | |||
|
|||
std::for_each(split, base_type::end(), std::ptr_fun(&handshake_manager_delete_handshake)); | |||
std::for_each(split, base_type::end(), &handshake_manager_delete_handshake); |
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.
Use lambda.
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.
Done.
Removed in C++17 Signed-off-by: Rosen Penev <[email protected]>
Removed in C++17