Reduce usage of std::bind()
C++14 lambdas are easier to read, easier to debug,
and can usually be better optimized by the compiler.
Change-Id: I294f275904f91942a8de946fe63e77078a7608a6
diff --git a/daemon/mgmt/rib-manager.cpp b/daemon/mgmt/rib-manager.cpp
index 68b061e..4e444bf 100644
--- a/daemon/mgmt/rib-manager.cpp
+++ b/daemon/mgmt/rib-manager.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2020, Regents of the University of California,
+ * Copyright (c) 2014-2021, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -62,11 +62,11 @@
, m_isLocalhopEnabled(false)
{
registerCommandHandler<ndn::nfd::RibRegisterCommand>("register",
- bind(&RibManager::registerEntry, this, _2, _3, _4, _5));
+ std::bind(&RibManager::registerEntry, this, _2, _3, _4, _5));
registerCommandHandler<ndn::nfd::RibUnregisterCommand>("unregister",
- bind(&RibManager::unregisterEntry, this, _2, _3, _4, _5));
+ std::bind(&RibManager::unregisterEntry, this, _2, _3, _4, _5));
- registerStatusDatasetHandler("list", bind(&RibManager::listEntries, this, _1, _2, _3));
+ registerStatusDatasetHandler("list", std::bind(&RibManager::listEntries, this, _1, _2, _3));
}
void
@@ -104,7 +104,7 @@
}
NFD_LOG_INFO("Start monitoring face create/destroy events");
- m_faceMonitor.onNotification.connect(bind(&RibManager::onNotification, this, _1));
+ m_faceMonitor.onNotification.connect([this] (const auto& notif) { onNotification(notif); });
m_faceMonitor.start();
scheduleActiveFaceFetch(ACTIVE_FACE_FETCH_INTERVAL);
@@ -248,7 +248,7 @@
}
void
-RibManager::unregisterEntry(const Name& topPrefix, const Interest& interest,
+RibManager::unregisterEntry(const Name&, const Interest& interest,
ControlParameters parameters,
const ndn::mgmt::CommandContinuation& done)
{
@@ -265,7 +265,7 @@
}
void
-RibManager::listEntries(const Name& topPrefix, const Interest& interest,
+RibManager::listEntries(const Name&, const Interest& interest,
ndn::mgmt::StatusDatasetContext& context)
{
auto now = time::steady_clock::now();
@@ -304,7 +304,7 @@
}
ndn::mgmt::Authorization
-RibManager::makeAuthorization(const std::string& verb)
+RibManager::makeAuthorization(const std::string&)
{
return [this] (const Name& prefix, const Interest& interest,
const ndn::mgmt::ControlParameters* params,
@@ -316,8 +316,8 @@
auto& validator = prefix == LOCALHOST_TOP_PREFIX ? m_localhostValidator : m_localhopValidator;
validator.validate(interest,
- bind([&interest, this, accept] { extractRequester(interest, accept); }),
- bind([reject] { reject(ndn::mgmt::RejectReply::STATUS403); }));
+ [&interest, accept] (auto&&...) { extractRequester(interest, accept); },
+ [reject] (auto&&...) { reject(ndn::mgmt::RejectReply::STATUS403); });
};
}
@@ -429,8 +429,8 @@
NFD_LOG_DEBUG("Fetching active faces");
m_nfdController.fetch<ndn::nfd::FaceDataset>(
- bind(&RibManager::removeInvalidFaces, this, _1),
- bind(&RibManager::onFetchActiveFacesFailure, this, _1, _2),
+ std::bind(&RibManager::removeInvalidFaces, this, _1),
+ std::bind(&RibManager::onFetchActiveFacesFailure, this, _1, _2),
ndn::nfd::CommandOptions());
}