Use more C++17 features

Mainly structured bindings, inline variables, and class template
argument deduction, plus many more smaller things.

Change-Id: I810d17e0adb470426e4e30c898e03b3140ad052f
diff --git a/daemon/mgmt/cs-manager.cpp b/daemon/mgmt/cs-manager.cpp
index eaf2cda..36d7014 100644
--- a/daemon/mgmt/cs-manager.cpp
+++ b/daemon/mgmt/cs-manager.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2021,  Regents of the University of California,
+ * Copyright (c) 2014-2022,  Regents of the University of California,
  *                           Arizona Board of Regents,
  *                           Colorado State University,
  *                           University Pierre & Marie Curie, Sorbonne University,
@@ -31,8 +31,6 @@
 
 namespace nfd {
 
-constexpr size_t CsManager::ERASE_LIMIT;
-
 CsManager::CsManager(Cs& cs, const ForwarderCounters& fwCounters,
                      Dispatcher& dispatcher, CommandAuthenticator& authenticator)
   : ManagerBase("cs", dispatcher, authenticator)
@@ -101,8 +99,7 @@
 }
 
 void
-CsManager::serveInfo(const Name& topPrefix, const Interest& interest,
-                     ndn::mgmt::StatusDatasetContext& context) const
+CsManager::serveInfo(const Name&, const Interest&, ndn::mgmt::StatusDatasetContext& context) const
 {
   ndn::nfd::CsInfo info;
   info.setCapacity(m_cs.getLimit());
diff --git a/daemon/mgmt/face-manager.cpp b/daemon/mgmt/face-manager.cpp
index 839a6fb..cc89061 100644
--- a/daemon/mgmt/face-manager.cpp
+++ b/daemon/mgmt/face-manager.cpp
@@ -260,7 +260,7 @@
                         const ndn::mgmt::CommandContinuation& done)
 {
   FaceId faceId = parameters.getFaceId();
-  if (faceId == 0) { // Self-update
+  if (faceId == face::INVALID_FACEID) { // Self-update
     auto incomingFaceIdTag = interest.getTag<lp::IncomingFaceIdTag>();
     if (incomingFaceIdTag == nullptr) {
       NFD_LOG_TRACE("unable to determine face for self-update");
diff --git a/daemon/mgmt/fib-manager.cpp b/daemon/mgmt/fib-manager.cpp
index f8a99d8..474d616 100644
--- a/daemon/mgmt/fib-manager.cpp
+++ b/daemon/mgmt/fib-manager.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2021,  Regents of the University of California,
+ * Copyright (c) 2014-2022,  Regents of the University of California,
  *                           Arizona Board of Regents,
  *                           Colorado State University,
  *                           University Pierre & Marie Curie, Sorbonne University,
@@ -53,7 +53,7 @@
 }
 
 void
-FibManager::addNextHop(const Name& topPrefix, const Interest& interest,
+FibManager::addNextHop(const Name&, const Interest& interest,
                        ControlParameters parameters,
                        const ndn::mgmt::CommandContinuation& done)
 {
@@ -84,7 +84,7 @@
 }
 
 void
-FibManager::removeNextHop(const Name& topPrefix, const Interest& interest,
+FibManager::removeNextHop(const Name&, const Interest& interest,
                           ControlParameters parameters,
                           const ndn::mgmt::CommandContinuation& done)
 {
@@ -121,7 +121,7 @@
 }
 
 void
-FibManager::listEntries(const Name& topPrefix, const Interest& interest,
+FibManager::listEntries(const Name&, const Interest&,
                         ndn::mgmt::StatusDatasetContext& context)
 {
   for (const auto& entry : m_fib) {
@@ -142,9 +142,9 @@
 void
 FibManager::setFaceForSelfRegistration(const Interest& request, ControlParameters& parameters)
 {
-  bool isSelfRegistration = (parameters.getFaceId() == 0);
+  bool isSelfRegistration = parameters.getFaceId() == face::INVALID_FACEID;
   if (isSelfRegistration) {
-    shared_ptr<lp::IncomingFaceIdTag> incomingFaceIdTag = request.getTag<lp::IncomingFaceIdTag>();
+    auto incomingFaceIdTag = request.getTag<lp::IncomingFaceIdTag>();
     // NDNLPv2 says "application MUST be prepared to receive a packet without IncomingFaceId field",
     // but it's fine to assert IncomingFaceId is available, because InternalFace lives inside NFD
     // and is initialized synchronously with IncomingFaceId field enabled.
diff --git a/daemon/mgmt/rib-manager.cpp b/daemon/mgmt/rib-manager.cpp
index d66baea..24d52b7 100644
--- a/daemon/mgmt/rib-manager.cpp
+++ b/daemon/mgmt/rib-manager.cpp
@@ -42,11 +42,9 @@
 
 NFD_LOG_INIT(RibManager);
 
-static const std::string MGMT_MODULE_NAME = "rib";
-static const Name LOCALHOST_TOP_PREFIX = "/localhost/nfd";
-static const time::seconds ACTIVE_FACE_FETCH_INTERVAL = 5_min;
-
-const Name RibManager::LOCALHOP_TOP_PREFIX = "/localhop/nfd";
+const std::string MGMT_MODULE_NAME = "rib";
+const Name LOCALHOST_TOP_PREFIX = "/localhost/nfd";
+const time::seconds ACTIVE_FACE_FETCH_INTERVAL = 5_min;
 
 RibManager::RibManager(rib::Rib& rib, ndn::Face& face, ndn::KeyChain& keyChain,
                        ndn::nfd::Controller& nfdController, Dispatcher& dispatcher)
diff --git a/daemon/mgmt/rib-manager.hpp b/daemon/mgmt/rib-manager.hpp
index ac2a324..ec2394d 100644
--- a/daemon/mgmt/rib-manager.hpp
+++ b/daemon/mgmt/rib-manager.hpp
@@ -240,7 +240,7 @@
   onNotification(const ndn::nfd::FaceEventNotification& notification);
 
 public:
-  static const Name LOCALHOP_TOP_PREFIX;
+  static inline const Name LOCALHOP_TOP_PREFIX{"/localhop/nfd"};
 
 private:
   rib::Rib& m_rib;
diff --git a/daemon/mgmt/strategy-choice-manager.cpp b/daemon/mgmt/strategy-choice-manager.cpp
index 9be09d2..ea0c056 100644
--- a/daemon/mgmt/strategy-choice-manager.cpp
+++ b/daemon/mgmt/strategy-choice-manager.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2021,  Regents of the University of California,
+ * Copyright (c) 2014-2022,  Regents of the University of California,
  *                           Arizona Board of Regents,
  *                           Colorado State University,
  *                           University Pierre & Marie Curie, Sorbonne University,
@@ -63,9 +63,7 @@
   }
 
   NFD_LOG_DEBUG("strategy-choice/set(" << prefix << "," << strategy << "): OK");
-  bool hasEntry = false;
-  Name instanceName;
-  std::tie(hasEntry, instanceName) = m_table.get(prefix);
+  auto [hasEntry, instanceName] = m_table.get(prefix);
   BOOST_ASSERT_MSG(hasEntry, "StrategyChoice entry must exist after StrategyChoice::insert");
   parameters.setStrategy(instanceName);
   return done(ControlResponse(200, "OK").setBody(parameters.wireEncode()));
diff --git a/daemon/mgmt/tables-config-section.cpp b/daemon/mgmt/tables-config-section.cpp
index f6adced..f693a73 100644
--- a/daemon/mgmt/tables-config-section.cpp
+++ b/daemon/mgmt/tables-config-section.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2021,  Regents of the University of California,
+ * Copyright (c) 2014-2022,  Regents of the University of California,
  *                           Arizona Board of Regents,
  *                           Colorado State University,
  *                           University Pierre & Marie Curie, Sorbonne University,
@@ -28,7 +28,7 @@
 
 namespace nfd {
 
-const size_t DEFAULT_CS_MAX_PACKETS = 65536;
+constexpr size_t DEFAULT_CS_MAX_PACKETS = 65536;
 
 TablesConfigSection::TablesConfigSection(Forwarder& forwarder)
   : m_forwarder(forwarder)
@@ -118,22 +118,19 @@
 void
 TablesConfigSection::processStrategyChoiceSection(const ConfigSection& section, bool isDryRun)
 {
-  using fw::Strategy;
-
   std::map<Name, Name> choices;
   for (const auto& prefixAndStrategy : section) {
     Name prefix(prefixAndStrategy.first);
     Name strategy(prefixAndStrategy.second.get_value<std::string>());
 
-    if (!Strategy::canCreate(strategy)) {
-      NDN_THROW(ConfigFile::Error(
-        "Unknown strategy '" + prefixAndStrategy.second.get_value<std::string>() +
-        "' for prefix '" + prefix.toUri() + "' in section 'strategy_choice'"));
+    if (!fw::Strategy::canCreate(strategy)) {
+      NDN_THROW(ConfigFile::Error("Unknown strategy '" + prefixAndStrategy.second.get_value<std::string>() +
+                                  "' for prefix '" + prefix.toUri() + "' in section 'strategy_choice'"));
     }
 
-    if (!choices.emplace(prefix, strategy).second) {
-      NDN_THROW(ConfigFile::Error(
-        "Duplicate strategy choice for prefix '" + prefix.toUri() + "' in section 'strategy_choice'"));
+    if (!choices.try_emplace(prefix, std::move(strategy)).second) {
+      NDN_THROW(ConfigFile::Error("Duplicate strategy choice for prefix '" + prefix.toUri() +
+                                  "' in section 'strategy_choice'"));
     }
   }