Improve and simplify code with modern C++ features
Change-Id: I83bf5513c2a1f90ba5a59e93c473306864b27d94
diff --git a/daemon/face/udp-channel.cpp b/daemon/face/udp-channel.cpp
index 3d6e6b8..b87e697 100644
--- a/daemon/face/udp-channel.cpp
+++ b/daemon/face/udp-channel.cpp
@@ -60,7 +60,7 @@
catch (const boost::system::system_error& e) {
NFD_LOG_CHAN_DEBUG("Face creation for " << remoteEndpoint << " failed: " << e.what());
if (onConnectFailed)
- onConnectFailed(504, std::string("Face creation failed: ") + e.what());
+ onConnectFailed(504, "Face creation failed: "s + e.what());
return;
}
@@ -94,10 +94,9 @@
const FaceCreationFailedCallback& onReceiveFailed)
{
m_socket.async_receive_from(boost::asio::buffer(m_receiveBuffer), m_remoteEndpoint,
- bind(&UdpChannel::handleNewPeer, this,
- boost::asio::placeholders::error,
- boost::asio::placeholders::bytes_transferred,
- onFaceCreated, onReceiveFailed));
+ [=] (auto&&... args) {
+ this->handleNewPeer(std::forward<decltype(args)>(args)..., onFaceCreated, onReceiveFailed);
+ });
}
void
@@ -127,7 +126,7 @@
catch (const boost::system::system_error& e) {
NFD_LOG_CHAN_DEBUG("Face creation for " << m_remoteEndpoint << " failed: " << e.what());
if (onReceiveFailed)
- onReceiveFailed(504, std::string("Face creation failed: ") + e.what());
+ onReceiveFailed(504, "Face creation failed: "s + e.what());
return;
}