Skip to content

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

Merged
merged 1 commit into from
Dec 22, 2024
Merged

remove most ptr_fun #277

merged 1 commit into from
Dec 22, 2024

Conversation

neheb
Copy link
Contributor

@neheb neheb commented Dec 18, 2024

Removed in C++17

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);
Copy link
Owner

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.

Copy link
Contributor Author

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

Copy link
Owner

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.

Copy link
Contributor Author

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.

@@ -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);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use lambda.

Copy link
Contributor Author

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]>
@rakshasa rakshasa merged commit e1a40ff into rakshasa:master Dec 22, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants