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/tools/nfdc/command-arguments.hpp b/tools/nfdc/command-arguments.hpp
index 164a672..1d0c9bd 100644
--- a/tools/nfdc/command-arguments.hpp
+++ b/tools/nfdc/command-arguments.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, 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,
@@ -30,6 +30,7 @@
#include "status-report.hpp"
#include <ndn-cxx/encoding/nfd-constants.hpp>
+#include <ndn-cxx/util/any.hpp>
#include <boost/logic/tribool.hpp>
diff --git a/tools/nfdc/face-module.cpp b/tools/nfdc/face-module.cpp
index e46279d2..18862aa 100644
--- a/tools/nfdc/face-module.cpp
+++ b/tools/nfdc/face-module.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,
@@ -236,7 +236,7 @@
if (isChangingParams) {
ctx.controller.start<ndn::nfd::FaceUpdateCommand>(
params,
- bind(updateFace, respParams, _1),
+ [=, &updateFace] (const auto& cp) { updateFace(respParams, cp); },
ctx.makeCommandFailureHandler("updating face"),
ctx.makeCommandOptions());
}
diff --git a/tools/nfdc/format-helpers.cpp b/tools/nfdc/format-helpers.cpp
index fa72512..a207bf8 100644
--- a/tools/nfdc/format-helpers.cpp
+++ b/tools/nfdc/format-helpers.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, 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,
@@ -110,9 +110,9 @@
}
std::string
-formatTimestamp(time::system_clock::TimePoint t)
+formatTimestamp(time::system_clock::time_point t)
{
- return time::toString(t, "%Y-%m-%dT%H:%M:%S%F");
+ return time::toIsoExtendedString(t);
}
} // namespace xml
@@ -199,7 +199,7 @@
}
std::string
-formatTimestamp(time::system_clock::TimePoint t)
+formatTimestamp(time::system_clock::time_point t)
{
return time::toIsoString(t);
}
diff --git a/tools/nfdc/format-helpers.hpp b/tools/nfdc/format-helpers.hpp
index 1ee88ee..95f3310 100644
--- a/tools/nfdc/format-helpers.hpp
+++ b/tools/nfdc/format-helpers.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, 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,
@@ -73,7 +73,7 @@
* Definition of this format: https://www.w3.org/TR/xmlschema11-2/#dateTime
*/
std::string
-formatTimestamp(time::system_clock::TimePoint t);
+formatTimestamp(time::system_clock::time_point t);
} // namespace xml
@@ -262,7 +262,7 @@
}
std::string
-formatTimestamp(time::system_clock::TimePoint t);
+formatTimestamp(time::system_clock::time_point t);
} // namespace text
diff --git a/tools/nfdc/forwarder-general-module.cpp b/tools/nfdc/forwarder-general-module.cpp
index 417b346..1542b9f 100644
--- a/tools/nfdc/forwarder-general-module.cpp
+++ b/tools/nfdc/forwarder-general-module.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, 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,
@@ -46,7 +46,7 @@
onFailure, options);
}
-static time::system_clock::Duration
+static auto
calculateUptime(const ForwarderStatus& status)
{
return status.getCurrentTimestamp() - status.getStartTimestamp();
diff --git a/tools/nfdc/status.cpp b/tools/nfdc/status.cpp
index 441c3a9..a338b1d 100644
--- a/tools/nfdc/status.cpp
+++ b/tools/nfdc/status.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,
@@ -128,25 +128,29 @@
CommandDefinition defStatusShow("status", "show");
defStatusShow
.setTitle("print general status");
- parser.addCommand(defStatusShow, bind(&reportStatusSingleSection, _1, &StatusReportOptions::wantForwarderGeneral));
+ parser.addCommand(defStatusShow,
+ std::bind(&reportStatusSingleSection, _1, &StatusReportOptions::wantForwarderGeneral));
parser.addAlias("status", "show", "");
CommandDefinition defChannelList("channel", "list");
defChannelList
.setTitle("print channel list");
- parser.addCommand(defChannelList, bind(&reportStatusSingleSection, _1, &StatusReportOptions::wantChannels));
+ parser.addCommand(defChannelList,
+ std::bind(&reportStatusSingleSection, _1, &StatusReportOptions::wantChannels));
parser.addAlias("channel", "list", "");
CommandDefinition defFibList("fib", "list");
defFibList
.setTitle("print FIB entries");
- parser.addCommand(defFibList, bind(&reportStatusSingleSection, _1, &StatusReportOptions::wantFib));
+ parser.addCommand(defFibList,
+ std::bind(&reportStatusSingleSection, _1, &StatusReportOptions::wantFib));
parser.addAlias("fib", "list", "");
CommandDefinition defCsInfo("cs", "info");
defCsInfo
.setTitle("print CS information");
- parser.addCommand(defCsInfo, bind(&reportStatusSingleSection, _1, &StatusReportOptions::wantCs));
+ parser.addCommand(defCsInfo,
+ std::bind(&reportStatusSingleSection, _1, &StatusReportOptions::wantCs));
parser.addAlias("cs", "info", "");
}