common: stop importing std::{bind,ref,cref} into namespace ndn
And reduce the usage of std::bind() throughout the codebase.
C++14 lambdas are easier to understand for humans and more
likely to be optimized by the compiler.
Change-Id: Ia59fad34539710f8801c52914896ce426fb7e538
diff --git a/tests/unit/mgmt/dispatcher.t.cpp b/tests/unit/mgmt/dispatcher.t.cpp
index a6054c2..7827516 100644
--- a/tests/unit/mgmt/dispatcher.t.cpp
+++ b/tests/unit/mgmt/dispatcher.t.cpp
@@ -31,6 +31,7 @@
namespace tests {
using namespace ndn::tests;
+using std::bind;
class DispatcherFixture : public IoKeyChainFixture
{
diff --git a/tests/unit/mgmt/nfd/controller-fixture.hpp b/tests/unit/mgmt/nfd/controller-fixture.hpp
index 77c7620..764ff41 100644
--- a/tests/unit/mgmt/nfd/controller-fixture.hpp
+++ b/tests/unit/mgmt/nfd/controller-fixture.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2020 Regents of the University of California.
+ * Copyright (c) 2013-2021 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -42,8 +42,8 @@
: face(m_io, m_keyChain)
, m_validator(true)
, controller(face, m_keyChain, m_validator)
- , commandFailCallback(bind(&ControllerFixture::recordCommandFail, this, _1))
- , datasetFailCallback(bind(&ControllerFixture::recordDatasetFail, this, _1, _2))
+ , commandFailCallback([this] (const auto& resp) { failCodes.push_back(resp.getCode()); })
+ , datasetFailCallback([this] (auto code, const auto&) { failCodes.push_back(code); })
{
m_keyChain.setDefaultIdentity(m_keyChain.createIdentity("/localhost/ControllerFixture"));
}
@@ -59,19 +59,6 @@
m_validator.getPolicy().setResult(shouldAccept);
}
-private:
- void
- recordCommandFail(const ControlResponse& response)
- {
- failCodes.push_back(response.getCode());
- }
-
- void
- recordDatasetFail(uint32_t code, const std::string& reason)
- {
- failCodes.push_back(code);
- }
-
protected:
ndn::util::DummyClientFace face;
DummyValidator m_validator;
diff --git a/tests/unit/mgmt/nfd/controller.t.cpp b/tests/unit/mgmt/nfd/controller.t.cpp
index b0a5838..83deb23 100644
--- a/tests/unit/mgmt/nfd/controller.t.cpp
+++ b/tests/unit/mgmt/nfd/controller.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2020 Regents of the University of California.
+ * Copyright (c) 2013-2021 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -37,11 +37,6 @@
class CommandFixture : public ControllerFixture
{
protected:
- CommandFixture()
- : succeedCallback(bind(&CommandFixture::succeed, this, _1))
- {
- }
-
void
respond(const ControlResponse& responsePayload)
{
@@ -51,15 +46,10 @@
this->advanceClocks(1_ms);
}
-private:
- void
- succeed(const ControlParameters& parameters)
- {
- succeeds.push_back(parameters);
- }
-
protected:
- Controller::CommandSucceedCallback succeedCallback;
+ Controller::CommandSucceedCallback succeedCallback = [this] (const auto& params) {
+ succeeds.push_back(params);
+ };
std::vector<ControlParameters> succeeds;
};
diff --git a/tests/unit/mgmt/status-dataset-context.t.cpp b/tests/unit/mgmt/status-dataset-context.t.cpp
index 58c8382..6d1e0b9 100644
--- a/tests/unit/mgmt/status-dataset-context.t.cpp
+++ b/tests/unit/mgmt/status-dataset-context.t.cpp
@@ -229,13 +229,7 @@
class AbnormalStateTestFixture
{
protected:
- AbnormalStateTestFixture()
- : context(Interest("/abnormal-state"), bind([]{}), bind([]{}))
- {
- }
-
-protected:
- StatusDatasetContext context;
+ StatusDatasetContext context{Interest("/abnormal-state"), [] (auto&&...) {}, [] (auto&&...) {}};
};
BOOST_FIXTURE_TEST_SUITE(AbnormalState, AbnormalStateTestFixture)