build: migrate to C++17

Change-Id: Ic9f09efd20b608bfcb713fd319834b2666cf6242
diff --git a/src/route/fib.cpp b/src/route/fib.cpp
index 2d34a36..0975c20 100644
--- a/src/route/fib.cpp
+++ b/src/route/fib.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2021,  The University of Memphis,
+ * Copyright (c) 2014-2022,  The University of Memphis,
  *                           Regents of the University of California
  *
  * This file is part of NLSR (Named-data Link State Routing).
@@ -24,18 +24,14 @@
 #include "logger.hpp"
 #include "nexthop-list.hpp"
 
-#include <map>
-#include <cmath>
 #include <algorithm>
-#include <iterator>
+#include <cmath>
+#include <map>
 
 namespace nlsr {
 
 INIT_LOGGER(route.Fib);
 
-const std::string Fib::MULTICAST_STRATEGY("ndn:/localhost/nfd/strategy/multicast");
-const std::string Fib::BEST_ROUTE_V2_STRATEGY("ndn:/localhost/nfd/strategy/best-route");
-
 Fib::Fib(ndn::Face& face, ndn::Scheduler& scheduler, AdjacencyList& adjacencyList,
          ConfParameter& conf, ndn::security::KeyChain& keyChain)
   : m_scheduler(scheduler)
@@ -109,12 +105,9 @@
 
     FibEntry entry;
     entry.name = name;
-
     addNextHopsToFibEntryAndNfd(entry, hopsToAdd);
 
-    m_table.emplace(name, std::move(entry));
-
-    entryIt = m_table.find(name);
+    entryIt = m_table.try_emplace(name, std::move(entry)).first;
   }
   // Existing FIB entry that may or may not have nextHops
   else {
@@ -127,7 +120,7 @@
       return;
     }
 
-    FibEntry& entry = (entryIt->second);
+    FibEntry& entry = entryIt->second;
     addNextHopsToFibEntryAndNfd(entry, hopsToAdd);
 
     std::set<NextHop, NextHopUriSortedComparator> hopsToRemove;
@@ -278,7 +271,7 @@
 }
 
 void
-Fib::setStrategy(const ndn::Name& name, const std::string& strategy, uint32_t count)
+Fib::setStrategy(const ndn::Name& name, const ndn::Name& strategy, uint32_t count)
 {
   ndn::nfd::ControlParameters parameters;
   parameters
@@ -311,7 +304,7 @@
 }
 
 void
-Fib::scheduleEntryRefresh(FibEntry& entry, const afterRefreshCallback& refreshCallback)
+Fib::scheduleEntryRefresh(FibEntry& entry, const AfterRefreshCallback& refreshCallback)
 {
   NLSR_LOG_DEBUG("Scheduling refresh for " << entry.name <<
                  " Seq Num: " << entry.seqNo <<
@@ -329,7 +322,7 @@
 }
 
 void
-Fib::refreshEntry(const ndn::Name& name, afterRefreshCallback refreshCb)
+Fib::refreshEntry(const ndn::Name& name, AfterRefreshCallback refreshCb)
 {
   auto it = m_table.find(name);
   if (it == m_table.end()) {
diff --git a/src/route/fib.hpp b/src/route/fib.hpp
index 25b5956..e24c61b 100644
--- a/src/route/fib.hpp
+++ b/src/route/fib.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2021,  The University of Memphis,
+ * Copyright (c) 2014-2022,  The University of Memphis,
  *                           Regents of the University of California,
  *                           Arizona Board of Regents.
  *
@@ -31,16 +31,17 @@
 
 namespace nlsr {
 
-typedef NexthopListT<NextHopUriSortedComparator> NextHopsUriSortedSet;
+using NextHopsUriSortedSet = NexthopListT<NextHopUriSortedComparator>;
 
-struct FibEntry {
+struct FibEntry
+{
   ndn::Name name;
   ndn::scheduler::ScopedEventId refreshEventId;
   int32_t seqNo = 1;
   NextHopsUriSortedSet nexthopSet;
 };
 
-typedef std::function<void(FibEntry&)> afterRefreshCallback;
+using AfterRefreshCallback = std::function<void(FibEntry&)>;
 
 class AdjacencyList;
 class ConfParameter;
@@ -135,7 +136,7 @@
                  uint8_t times);
 
   void
-  setStrategy(const ndn::Name& name, const std::string& strategy, uint32_t count);
+  setStrategy(const ndn::Name& name, const ndn::Name& strategy, uint32_t count);
 
   void
   writeLog();
@@ -204,7 +205,7 @@
    * \sa Fib::scheduleLoop
    */
   void
-  scheduleEntryRefresh(FibEntry& entry, const afterRefreshCallback& refreshCb);
+  scheduleEntryRefresh(FibEntry& entry, const AfterRefreshCallback& refreshCb);
 
 private:
   /*! \brief Continue the entry refresh cycle.
@@ -215,12 +216,13 @@
   /*! \brief Refreshes an entry in NFD.
    */
   void
-  refreshEntry(const ndn::Name& name, afterRefreshCallback refreshCb);
+  refreshEntry(const ndn::Name& name, AfterRefreshCallback refreshCb);
 
 public:
-  static const std::string MULTICAST_STRATEGY;
-  static const std::string BEST_ROUTE_V2_STRATEGY;
-  ndn::util::Signal<Fib, const ndn::Name&> onPrefixRegistrationSuccess;
+  static inline const ndn::Name MULTICAST_STRATEGY{"/localhost/nfd/strategy/multicast"};
+  static inline const ndn::Name BEST_ROUTE_STRATEGY{"/localhost/nfd/strategy/best-route"};
+
+  ndn::util::Signal<Fib, ndn::Name> onPrefixRegistrationSuccess;
 
 private:
   ndn::Scheduler& m_scheduler;
diff --git a/src/route/map.cpp b/src/route/map.cpp
index 0aab84f..a1828af 100644
--- a/src/route/map.cpp
+++ b/src/route/map.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2020,  The University of Memphis,
+ * Copyright (c) 2014-2022,  The University of Memphis,
  *                           Regents of the University of California
  *
  * This file is part of NLSR (Named-data Link State Routing).
@@ -44,20 +44,20 @@
   return m_entries.insert(mpe).second;
 }
 
-ndn::optional<ndn::Name>
+std::optional<ndn::Name>
 Map::getRouterNameByMappingNo(int32_t mn) const
 {
   auto&& mappingNumberView = m_entries.get<detail::byMappingNumber>();
   auto it = mappingNumberView.find(mn);
-  return it == mappingNumberView.end() ? ndn::nullopt : ndn::optional<ndn::Name>(it->router);
+  return it == mappingNumberView.end() ? std::nullopt : std::optional(it->router);
 }
 
-ndn::optional<int32_t>
+std::optional<int32_t>
 Map::getMappingNoByRouterName(const ndn::Name& rName)
 {
   auto&& routerNameView = m_entries.get<detail::byRouterName>();
   auto it = routerNameView.find(rName);
-  return it == routerNameView.end() ? ndn::nullopt : ndn::optional<int32_t>(it->mappingNumber);
+  return it == routerNameView.end() ? std::nullopt : std::optional(it->mappingNumber);
 }
 
 void
@@ -66,7 +66,7 @@
   NLSR_LOG_DEBUG("---------------Map----------------------");
   for (const auto& entry : m_entries.get<detail::byRouterName>()) {
     NLSR_LOG_DEBUG("MapEntry: ( Router: " << entry.router << " Mapping No: " <<
-                    entry.mappingNumber << " )");
+                   entry.mappingNumber << " )");
   }
 }
 
diff --git a/src/route/map.hpp b/src/route/map.hpp
index be62d2d..f2e8eae 100644
--- a/src/route/map.hpp
+++ b/src/route/map.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2020,  The University of Memphis,
+ * Copyright (c) 2014-2022,  The University of Memphis,
  *                           Regents of the University of California
  *
  * This file is part of NLSR (Named-data Link State Routing).
@@ -29,9 +29,12 @@
 #include <boost/multi_index/member.hpp>
 #include <boost/multi_index/tag.hpp>
 
+#include <optional>
+
 namespace nlsr {
 
-struct MapEntry {
+struct MapEntry
+{
   ndn::Name router;
   int32_t mappingNumber = -1;
 };
@@ -104,10 +107,10 @@
     }
   }
 
-  ndn::optional<ndn::Name>
+  std::optional<ndn::Name>
   getRouterNameByMappingNo(int32_t mn) const;
 
-  ndn::optional<int32_t>
+  std::optional<int32_t>
   getMappingNoByRouterName(const ndn::Name& rName);
 
   size_t
diff --git a/src/route/name-prefix-table.cpp b/src/route/name-prefix-table.cpp
index deb9af7..3ee9132 100644
--- a/src/route/name-prefix-table.cpp
+++ b/src/route/name-prefix-table.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2021,  The University of Memphis,
+ * Copyright (c) 2014-2022,  The University of Memphis,
  *                           Regents of the University of California,
  *                           Arizona Board of Regents.
  *
@@ -116,15 +116,11 @@
 NamePrefixTable::addEntry(const ndn::Name& name, const ndn::Name& destRouter)
 {
   // Check if the advertised name prefix is in the table already.
-  NptEntryList::iterator nameItr =
-    std::find_if(m_table.begin(),
-                 m_table.end(),
-                 [&] (const std::shared_ptr<NamePrefixTableEntry>& entry) {
-                   return name == entry->getNamePrefix();
-                 });
+  auto nameItr = std::find_if(m_table.begin(), m_table.end(),
+                              [&] (const auto& entry) { return name == entry->getNamePrefix(); });
 
   // Attempt to find a routing table pool entry (RTPE) we can use.
-  RoutingTableEntryPool::iterator rtpeItr = m_rtpool.find(destRouter);
+  auto rtpeItr = m_rtpool.find(destRouter);
 
   // These declarations just to make the compiler happy...
   RoutingTablePoolEntry rtpe;
@@ -196,8 +192,8 @@
   }
 
   // Add the reference to this NPT to the RTPE.
-  rtpePtr->namePrefixTableEntries.emplace(
-    std::make_pair(npte->getNamePrefix(), std::weak_ptr<NamePrefixTableEntry>(npte)));
+  rtpePtr->namePrefixTableEntries.try_emplace(npte->getNamePrefix(),
+                                              std::weak_ptr<NamePrefixTableEntry>(npte));
 }
 
 void
@@ -206,27 +202,23 @@
   NLSR_LOG_DEBUG("Removing origin: " << destRouter << " from " << name);
 
   // Fetch an iterator to the appropriate pair object in the pool.
-  RoutingTableEntryPool::iterator rtpeItr = m_rtpool.find(destRouter);
+  auto rtpeItr = m_rtpool.find(destRouter);
 
   // Simple error checking to prevent any unusual behavior in the case
   // that we try to remove an entry that isn't there.
   if (rtpeItr == m_rtpool.end()) {
     NLSR_LOG_DEBUG("No entry for origin: " << destRouter
-               << " found, so it cannot be removed from prefix: "
-               << name);
+                   << " found, so it cannot be removed from prefix: " << name);
     return;
   }
   std::shared_ptr<RoutingTablePoolEntry> rtpePtr = rtpeItr->second;
 
   // Ensure that the entry exists
-  NptEntryList::iterator nameItr =
-    std::find_if(m_table.begin(), m_table.end(),
-                 [&] (const std::shared_ptr<NamePrefixTableEntry>& entry) {
-                   return entry->getNamePrefix() == name;
-                 });
+  auto nameItr = std::find_if(m_table.begin(), m_table.end(),
+                              [&] (const auto& entry) { return entry->getNamePrefix() == name; });
   if (nameItr != m_table.end()) {
     NLSR_LOG_TRACE("Removing origin: " << rtpePtr->getDestination()
-               << " from prefix: " << **nameItr);
+                   << " from prefix: " << **nameItr);
 
     // Rather than iterating through the whole list periodically, just
     // delete them here if they have no references.
@@ -251,20 +243,20 @@
     //
     if ((*nameItr)->getRteListSize() == 0) {
       NLSR_LOG_TRACE(**nameItr << " has no routing table entries;"
-                 << " removing from table and FIB");
+                     << " removing from table and FIB");
       m_table.erase(nameItr);
       m_fib.remove(name);
     }
     else {
       NLSR_LOG_TRACE(**nameItr << " has other routing table entries;"
-                 << " updating FIB with next hops");
+                     << " updating FIB with next hops");
       (*nameItr)->generateNhlfromRteList();
       m_fib.update(name, (*nameItr)->getNexthopList());
     }
   }
   else {
     NLSR_LOG_DEBUG("Attempted to remove origin: " << rtpePtr->getDestination()
-               << " from non-existent prefix: " << name);
+                   << " from non-existent prefix: " << name);
   }
 }
 
@@ -305,33 +297,30 @@
   }
 }
 
-  // Inserts the routing table pool entry into the NPT's RTE storage
-  // pool.  This cannot fail, so the pool is guaranteed to contain the
-  // item after this occurs.
+// Inserts the routing table pool entry into the NPT's RTE storage
+// pool.  This cannot fail, so the pool is guaranteed to contain the
+// item after this occurs.
 std::shared_ptr<RoutingTablePoolEntry>
 NamePrefixTable::addRtpeToPool(RoutingTablePoolEntry& rtpe)
 {
-  RoutingTableEntryPool::iterator poolItr =
-    m_rtpool.insert(std::make_pair(rtpe.getDestination(),
-                                   std::make_shared<RoutingTablePoolEntry>
-                                   (rtpe)))
-    .first;
-  return poolItr->second;
+  auto poolIt = m_rtpool.try_emplace(rtpe.getDestination(),
+                                     std::make_shared<RoutingTablePoolEntry>(rtpe)).first;
+  return poolIt->second;
 }
 
-  // Removes the routing table pool entry from the storage pool. The
-  // postconditions of this function are guaranteed to include that
-  // the storage pool does not contain such an item. Additionally,
-  // this function cannot fail, but nonetheless debug information is
-  // given in the case that this function is called with an entry that
-  // isn't in the pool.
+// Removes the routing table pool entry from the storage pool. The
+// postconditions of this function are guaranteed to include that
+// the storage pool does not contain such an item. Additionally,
+// this function cannot fail, but nonetheless debug information is
+// given in the case that this function is called with an entry that
+// isn't in the pool.
 void
 NamePrefixTable::deleteRtpeFromPool(std::shared_ptr<RoutingTablePoolEntry> rtpePtr)
 {
   if (m_rtpool.erase(rtpePtr->getDestination()) != 1) {
     NLSR_LOG_DEBUG("Attempted to delete non-existent origin: "
-               << rtpePtr->getDestination()
-               << " from NPT routing table entry storage pool.");
+                   << rtpePtr->getDestination()
+                   << " from NPT routing table entry storage pool.");
   }
 }
 
diff --git a/src/route/nexthop.cpp b/src/route/nexthop.cpp
index bdb0bde..a5f10ba 100644
--- a/src/route/nexthop.cpp
+++ b/src/route/nexthop.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2021,  The University of Memphis,
+ * Copyright (c) 2014-2022,  The University of Memphis,
  *                           Regents of the University of California
  *
  * This file is part of NLSR (Named-data Link State Routing).
@@ -31,11 +31,11 @@
 {
   size_t totalLength = 0;
 
-  totalLength += ndn::encoding::prependDoubleBlock(block, ndn::tlv::nlsr::CostDouble, m_routeCost);
-  totalLength += ndn::encoding::prependStringBlock(block, ndn::tlv::nlsr::Uri, m_connectingFaceUri);
+  totalLength += ndn::encoding::prependDoubleBlock(block, nlsr::tlv::CostDouble, m_routeCost);
+  totalLength += ndn::encoding::prependStringBlock(block, nlsr::tlv::Uri, m_connectingFaceUri);
 
   totalLength += block.prependVarNumber(totalLength);
-  totalLength += block.prependVarNumber(ndn::tlv::nlsr::NextHop);
+  totalLength += block.prependVarNumber(nlsr::tlv::NextHop);
 
   return totalLength;
 }
@@ -68,7 +68,7 @@
 
   m_wire = wire;
 
-  if (m_wire.type() != ndn::tlv::nlsr::NextHop) {
+  if (m_wire.type() != nlsr::tlv::NextHop) {
     NDN_THROW(Error("NextHop", m_wire.type()));
   }
 
@@ -76,7 +76,7 @@
 
   auto val = m_wire.elements_begin();
 
-  if (val != m_wire.elements_end() && val->type() == ndn::tlv::nlsr::Uri) {
+  if (val != m_wire.elements_end() && val->type() == nlsr::tlv::Uri) {
     m_connectingFaceUri = ndn::encoding::readString(*val);
     ++val;
   }
@@ -84,7 +84,7 @@
     NDN_THROW(Error("Missing required Uri field"));
   }
 
-  if (val != m_wire.elements_end() && val->type() == ndn::tlv::nlsr::CostDouble) {
+  if (val != m_wire.elements_end() && val->type() == nlsr::tlv::CostDouble) {
     m_routeCost = ndn::encoding::readDouble(*val);
     ++val;
   }
diff --git a/src/route/nexthop.hpp b/src/route/nexthop.hpp
index 4443a9e..77bc8b1 100644
--- a/src/route/nexthop.hpp
+++ b/src/route/nexthop.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2021,  The University of Memphis,
+ * Copyright (c) 2014-2022,  The University of Memphis,
  *                           Regents of the University of California
  *
  * This file is part of NLSR (Named-data Link State Routing).
@@ -142,7 +142,7 @@
 
       e.g  costs 12.34 and 12.35 will be installed into NFD's FIB as 12340 and 12350
   */
-  static const uint64_t HYPERBOLIC_COST_ADJUSTMENT_FACTOR = 1000;
+  static constexpr uint64_t HYPERBOLIC_COST_ADJUSTMENT_FACTOR = 1000;
 };
 
 NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(NextHop);
diff --git a/src/route/routing-table-calculator.cpp b/src/route/routing-table-calculator.cpp
index 2d283eb..34bcfb6 100644
--- a/src/route/routing-table-calculator.cpp
+++ b/src/route/routing-table-calculator.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2020,  The University of Memphis,
+ * Copyright (c) 2014-2022,  The University of Memphis,
  *                           Regents of the University of California,
  *                           Arizona Board of Regents.
  *
@@ -27,18 +27,20 @@
 #include "logger.hpp"
 #include "adjacent.hpp"
 
-#include <boost/math/constants/constants.hpp>
-#include <ndn-cxx/util/logger.hpp>
 #include <cmath>
+#include <boost/lexical_cast.hpp>
+#include <ndn-cxx/util/logger.hpp>
 
 namespace nlsr {
 
 INIT_LOGGER(route.RoutingTableCalculator);
 
-const int LinkStateRoutingTableCalculator::EMPTY_PARENT = -12345;
-const double LinkStateRoutingTableCalculator::INF_DISTANCE = 2147483647;
-const int LinkStateRoutingTableCalculator::NO_MAPPING_NUM = -1;
-const int LinkStateRoutingTableCalculator::NO_NEXT_HOP = -12345;
+const int EMPTY_PARENT = -12345;
+const double INF_DISTANCE = 2147483647;
+const int NO_MAPPING_NUM = -1;
+const int NO_NEXT_HOP = -12345;
+const double UNKNOWN_DISTANCE = -1.0;
+const double UNKNOWN_RADIUS   = -1.0;
 
 void
 RoutingTableCalculator::allocateAdjMatrix()
@@ -67,17 +69,16 @@
   auto lsaRange = lsdb.getLsdbIterator<AdjLsa>();
   for (auto lsaIt = lsaRange.first; lsaIt != lsaRange.second; ++lsaIt) {
     auto adjLsa = std::static_pointer_cast<AdjLsa>(*lsaIt);
-    ndn::optional<int32_t> row = pMap.getMappingNoByRouterName(adjLsa->getOriginRouter());
+    auto row = pMap.getMappingNoByRouterName(adjLsa->getOriginRouter());
 
     std::list<Adjacent> adl = adjLsa->getAdl().getAdjList();
     // For each adjacency represented in the LSA
     for (const auto& adjacent : adl) {
-      ndn::optional<int32_t> col = pMap.getMappingNoByRouterName(adjacent.getName());
+      auto col = pMap.getMappingNoByRouterName(adjacent.getName());
       double cost = adjacent.getLinkCost();
 
       if (row && col && *row < static_cast<int32_t>(m_nRouters)
-          && *col < static_cast<int32_t>(m_nRouters))
-      {
+          && *col < static_cast<int32_t>(m_nRouters)) {
         adjMatrix[*row][*col] = cost;
       }
     }
@@ -143,7 +144,7 @@
   for (size_t i = 0; i < m_nRouters; i++) {
     std::string line;
     for (size_t j = 0; j < m_nRouters; j++) {
-      if (adjMatrix[i][j] == LinkStateRoutingTableCalculator::NO_NEXT_HOP) {
+      if (adjMatrix[i][j] == NO_NEXT_HOP) {
         line += "0 ";
       }
       else {
@@ -240,8 +241,7 @@
   initMatrix();
   makeAdjMatrix(lsdb, pMap);
   writeAdjMatrixLog(pMap);
-  ndn::optional<int32_t> sourceRouter =
-    pMap.getMappingNoByRouterName(confParam.getRouterPrefix());
+  auto sourceRouter = pMap.getMappingNoByRouterName(confParam.getRouterPrefix());
   allocateParent(); // These two matrices are used in Dijkstra's algorithm.
   allocateDistance(); //
   // We only bother to do the calculation if we have a router by that name.
@@ -346,14 +346,13 @@
         // Fetch its distance
         double routeCost = m_distance[i];
         // Fetch its actual name
-        ndn::optional<ndn::Name> nextHopRouterName= pMap.getRouterNameByMappingNo(nextHopRouter);
+        auto nextHopRouterName = pMap.getRouterNameByMappingNo(nextHopRouter);
         if (nextHopRouterName) {
           std::string nextHopFace =
             adjacencies.getAdjacent(*nextHopRouterName).getFaceUri().toString();
           // Add next hop to routing table
           NextHop nh(nextHopFace, routeCost);
           rt.addNextHop(*(pMap.getRouterNameByMappingNo(i)), nh);
-
         }
       }
     }
@@ -427,18 +426,13 @@
   delete [] m_distance;
 }
 
-const double HyperbolicRoutingCalculator::MATH_PI = boost::math::constants::pi<double>();
-
-const double HyperbolicRoutingCalculator::UNKNOWN_DISTANCE = -1.0;
-const double HyperbolicRoutingCalculator::UNKNOWN_RADIUS   = -1.0;
-
 void
 HyperbolicRoutingCalculator::calculatePath(Map& map, RoutingTable& rt,
                                            Lsdb& lsdb, AdjacencyList& adjacencies)
 {
   NLSR_LOG_TRACE("Calculating hyperbolic paths");
 
-  ndn::optional<int32_t> thisRouter = map.getMappingNoByRouterName(m_thisRouterName);
+  auto thisRouter = map.getMappingNoByRouterName(m_thisRouterName);
 
   // Iterate over directly connected neighbors
   std::list<Adjacent> neighbors = adjacencies.getAdjList();
@@ -462,8 +456,7 @@
     // Install nexthops for this router to the neighbor; direct neighbors have a 0 cost link
     addNextHop(srcRouterName, srcFaceUri, 0, rt);
 
-    ndn::optional<int32_t> src = map.getMappingNoByRouterName(srcRouterName);
-
+    auto src = map.getMappingNoByRouterName(srcRouterName);
     if (!src) {
       NLSR_LOG_WARN(adj->getName() << " does not exist in the router map!");
       continue;
@@ -474,7 +467,7 @@
       // Don't calculate nexthops to this router or from a router to itself
       if (thisRouter && dest != *thisRouter && dest != *src) {
 
-        ndn::optional<ndn::Name> destRouterName = map.getRouterNameByMappingNo(dest);
+        auto destRouterName = map.getRouterNameByMappingNo(dest);
         if (destRouterName) {
           double distance = getHyperbolicDistance(lsdb, srcRouterName, *destRouterName);
 
@@ -551,6 +544,7 @@
       }
     }
   }
+
   if (angleVectorI[angleVectorI.size()-1] > 2.*M_PI ||
       angleVectorI[angleVectorI.size()-1] < 0.0) {
     NLSR_LOG_ERROR("Angle not within [0, 2PI]");
diff --git a/src/route/routing-table-calculator.hpp b/src/route/routing-table-calculator.hpp
index b497c06..749c5b8 100644
--- a/src/route/routing-table-calculator.hpp
+++ b/src/route/routing-table-calculator.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2021,  The University of Memphis,
+ * Copyright (c) 2014-2022,  The University of Memphis,
  *                           Regents of the University of California
  *
  * This file is part of NLSR (Named-data Link State Routing).
@@ -27,8 +27,6 @@
 #include "lsdb.hpp"
 #include "conf-parameter.hpp"
 
-#include <list>
-
 namespace nlsr {
 
 class Map;
@@ -193,13 +191,6 @@
 private:
   int* m_parent;
   double* m_distance;
-
-  static const int EMPTY_PARENT;
-  static const double INF_DISTANCE;
-  static const int NO_MAPPING_NUM;
-public:
-  static const int NO_NEXT_HOP;
-
 };
 
 class AdjacencyList;
@@ -236,10 +227,6 @@
   const size_t m_nRouters;
   const bool m_isDryRun;
   const ndn::Name m_thisRouterName;
-
-  static const double MATH_PI;
-  static const double UNKNOWN_DISTANCE;
-  static const double UNKNOWN_RADIUS;
 };
 
 } // namespace nlsr
diff --git a/src/route/routing-table-entry.cpp b/src/route/routing-table-entry.cpp
index 950240e..45307b2 100644
--- a/src/route/routing-table-entry.cpp
+++ b/src/route/routing-table-entry.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2021,  The University of Memphis,
+ * Copyright (c) 2014-2022,  The University of Memphis,
  *                           Regents of the University of California
  *
  * This file is part of NLSR (Named-data Link State Routing).
@@ -37,7 +37,7 @@
   totalLength += m_destination.wireEncode(block);
 
   totalLength += block.prependVarNumber(totalLength);
-  totalLength += block.prependVarNumber(ndn::tlv::nlsr::RoutingTableEntry);
+  totalLength += block.prependVarNumber(nlsr::tlv::RoutingTableEntry);
 
   return totalLength;
 }
@@ -69,7 +69,7 @@
 
   m_wire = wire;
 
-  if (m_wire.type() != ndn::tlv::nlsr::RoutingTableEntry) {
+  if (m_wire.type() != nlsr::tlv::RoutingTableEntry) {
     NDN_THROW(Error("RoutingTableEntry", m_wire.type()));
   }
 
@@ -85,7 +85,7 @@
   }
 
   for (; val != m_wire.elements_end(); ++val) {
-    if (val->type() == ndn::tlv::nlsr::NextHop) {
+    if (val->type() == nlsr::tlv::NextHop) {
       m_nexthopList.addNextHop(NextHop(*val));
     }
     else {
diff --git a/src/route/routing-table-pool-entry.hpp b/src/route/routing-table-pool-entry.hpp
index 48212c3..148d2c9 100644
--- a/src/route/routing-table-pool-entry.hpp
+++ b/src/route/routing-table-pool-entry.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2020,  The University of Memphis,
+/*
+ * Copyright (c) 2014-2022,  The University of Memphis,
  *                           Regents of the University of California
  *
  * This file is part of NLSR (Named-data Link State Routing).
@@ -16,8 +16,7 @@
  *
  * You should have received a copy of the GNU General Public License along with
  * NLSR, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
- *
- **/
+ */
 
 #ifndef NLSR_ROUTING_TABLE_POOL_ENTRY_HPP
 #define NLSR_ROUTING_TABLE_POOL_ENTRY_HPP
@@ -41,6 +40,7 @@
  * maintain a collection of RoutingTablePoolEntries. Then, this new
  * class can be associated with the name prefixes instead of the
  * original entries, which provides a minimal memory solution.
+ *
  * \sa NamePrefixTable
  */
 class NamePrefixTableEntry;
@@ -48,13 +48,7 @@
 class RoutingTablePoolEntry : public RoutingTableEntry
 {
 public:
-  RoutingTablePoolEntry()
-  {
-  }
-
-  ~RoutingTablePoolEntry()
-  {
-  }
+  RoutingTablePoolEntry() = default;
 
   RoutingTablePoolEntry(const ndn::Name& dest)
   {
@@ -76,7 +70,7 @@
   }
 
   uint64_t
-  getUseCount()
+  getUseCount() const
   {
     return m_useCount;
   }
@@ -99,16 +93,14 @@
   void
   setNexthopList(NexthopList nhl)
   {
-    m_nexthopList = nhl;
+    m_nexthopList = std::move(nhl);
   }
 
 public:
-  std::unordered_map<ndn::Name, std::weak_ptr<NamePrefixTableEntry>>
-    namePrefixTableEntries;
+  std::unordered_map<ndn::Name, std::weak_ptr<NamePrefixTableEntry>> namePrefixTableEntries;
 
 private:
   uint64_t m_useCount;
-
 };
 
 bool
diff --git a/src/route/routing-table.cpp b/src/route/routing-table.cpp
index c06b429..7fd8a7a 100644
--- a/src/route/routing-table.cpp
+++ b/src/route/routing-table.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2021,  The University of Memphis,
+ * Copyright (c) 2014-2022,  The University of Memphis,
  *                           Regents of the University of California
  *
  * This file is part of NLSR (Named-data Link State Routing).
@@ -262,7 +262,7 @@
   }
 
   totalLength += block.prependVarNumber(totalLength);
-  totalLength += block.prependVarNumber(ndn::tlv::nlsr::RoutingTable);
+  totalLength += block.prependVarNumber(nlsr::tlv::RoutingTable);
 
   return totalLength;
 }
@@ -294,7 +294,7 @@
 
   m_wire = wire;
 
-  if (m_wire.type() != ndn::tlv::nlsr::RoutingTable) {
+  if (m_wire.type() != nlsr::tlv::RoutingTable) {
     NDN_THROW(Error("RoutingTable", m_wire.type()));
   }
 
@@ -302,7 +302,7 @@
   auto val = m_wire.elements_begin();
 
   std::set<ndn::Name> destinations;
-  for (; val != m_wire.elements_end() && val->type() == ndn::tlv::nlsr::RoutingTableEntry; ++val) {
+  for (; val != m_wire.elements_end() && val->type() == nlsr::tlv::RoutingTableEntry; ++val) {
     auto entry = RoutingTableEntry(*val);
 
     if (destinations.emplace(entry.getDestination()).second) {