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/rib/readvertise/host-to-gateway-readvertise-policy.cpp b/daemon/rib/readvertise/host-to-gateway-readvertise-policy.cpp
index 89f11fd..5aa6e3b 100644
--- a/daemon/rib/readvertise/host-to-gateway-readvertise-policy.cpp
+++ b/daemon/rib/readvertise/host-to-gateway-readvertise-policy.cpp
@@ -33,8 +33,8 @@
namespace nfd {
namespace rib {
-static const name::Component IGNORE_COMPONENT("nrd");
-static const time::seconds DEFAULT_REFRESH_INTERVAL = 25_s;
+const name::Component IGNORE_COMPONENT("nrd");
+const time::seconds DEFAULT_REFRESH_INTERVAL = 25_s;
HostToGatewayReadvertisePolicy::HostToGatewayReadvertisePolicy(const ndn::KeyChain& keyChain,
const ConfigSection& section)
diff --git a/daemon/rib/readvertise/readvertise.cpp b/daemon/rib/readvertise/readvertise.cpp
index addad72..ded568d 100644
--- a/daemon/rib/readvertise/readvertise.cpp
+++ b/daemon/rib/readvertise/readvertise.cpp
@@ -34,8 +34,8 @@
NFD_LOG_INIT(Readvertise);
-const time::milliseconds Readvertise::RETRY_DELAY_MIN = 50_s;
-const time::milliseconds Readvertise::RETRY_DELAY_MAX = 1_h;
+constexpr time::milliseconds RETRY_DELAY_MIN = 50_s;
+constexpr time::milliseconds RETRY_DELAY_MAX = 1_h;
static time::milliseconds
randomizeTimer(time::milliseconds baseTimer)
@@ -74,20 +74,16 @@
return;
}
- ReadvertisedRouteContainer::iterator rrIt;
- bool isNew = false;
- std::tie(rrIt, isNew) = m_rrs.emplace(action->prefix);
-
- if (!isNew && rrIt->signer != action->signer) {
+ auto [rrIt, isNewRr] = m_rrs.emplace(action->prefix);
+ if (!isNewRr && rrIt->signer != action->signer) {
NFD_LOG_WARN("add-route " << ribRoute.entry->getName() << '(' << ribRoute.route->faceId <<
- ',' << ribRoute.route->origin << ") readvertising-as " << action->prefix <<
+ ',' << ribRoute.route->origin << ") readvertising-as " << action->prefix <<
" old-signer " << rrIt->signer << " new-signer " << action->signer);
}
rrIt->signer = action->signer;
- RouteRrIndex::iterator indexIt;
- std::tie(indexIt, isNew) = m_routeToRr.emplace(ribRoute, rrIt);
- BOOST_ASSERT(isNew);
+ bool isNewInMap = m_routeToRr.try_emplace(ribRoute, rrIt).second;
+ BOOST_VERIFY(isNewInMap);
if (rrIt->nRibRoutes++ > 0) {
NFD_LOG_DEBUG("add-route " << ribRoute.entry->getName() << '(' << ribRoute.route->faceId <<
diff --git a/daemon/rib/readvertise/readvertise.hpp b/daemon/rib/readvertise/readvertise.hpp
index 871702f..aeaa823 100644
--- a/daemon/rib/readvertise/readvertise.hpp
+++ b/daemon/rib/readvertise/readvertise.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2019, 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,
@@ -68,18 +68,14 @@
withdraw(ReadvertisedRouteContainer::iterator rrIt);
private:
- /** \brief maps from RIB route to readvertised route derived from RIB route(s)
- */
- using RouteRrIndex = std::map<RibRouteRef, ReadvertisedRouteContainer::iterator>;
-
- static const time::milliseconds RETRY_DELAY_MIN;
- static const time::milliseconds RETRY_DELAY_MAX;
-
unique_ptr<ReadvertisePolicy> m_policy;
unique_ptr<ReadvertiseDestination> m_destination;
ReadvertisedRouteContainer m_rrs;
- RouteRrIndex m_routeToRr;
+ /**
+ * \brief maps from RIB route to readvertised route derived from RIB route(s)
+ */
+ std::map<RibRouteRef, ReadvertisedRouteContainer::iterator> m_routeToRr;
signal::ScopedConnection m_addRouteConn;
signal::ScopedConnection m_removeRouteConn;