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/fw/access-strategy.cpp b/daemon/fw/access-strategy.cpp
index e1443df..e80c581 100644
--- a/daemon/fw/access-strategy.cpp
+++ b/daemon/fw/access-strategy.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,
@@ -60,8 +60,7 @@
AccessStrategy::afterReceiveInterest(const Interest& interest, const FaceEndpoint& ingress,
const shared_ptr<pit::Entry>& pitEntry)
{
- auto suppressResult = m_retxSuppression.decidePerPitEntry(*pitEntry);
- switch (suppressResult) {
+ switch (auto res = m_retxSuppression.decidePerPitEntry(*pitEntry); res) {
case RetxSuppressionResult::NEW:
return afterReceiveNewInterest(interest, ingress, pitEntry);
case RetxSuppressionResult::FORWARD:
@@ -77,9 +76,7 @@
const shared_ptr<pit::Entry>& pitEntry)
{
const auto& fibEntry = this->lookupFib(*pitEntry);
- Name miName;
- MtInfo* mi = nullptr;
- std::tie(miName, mi) = this->findPrefixMeasurements(*pitEntry);
+ auto [miName, mi] = this->findPrefixMeasurements(*pitEntry);
// has measurements for Interest Name?
if (mi != nullptr) {
@@ -236,10 +233,7 @@
void
AccessStrategy::updateMeasurements(const Face& inFace, const Data& data, time::nanoseconds rtt)
{
- auto ret = m_fit.emplace(std::piecewise_construct,
- std::forward_as_tuple(inFace.getId()),
- std::forward_as_tuple(m_rttEstimatorOpts));
- FaceInfo& fi = ret.first->second;
+ FaceInfo& fi = m_fit.try_emplace(inFace.getId(), m_rttEstimatorOpts).first->second;
fi.rtt.addMeasurement(rtt);
MtInfo* mi = this->addPrefixMeasurements(data);
@@ -257,14 +251,14 @@
{
auto me = this->getMeasurements().findLongestPrefixMatch(pitEntry);
if (me == nullptr) {
- return std::make_tuple(Name(), nullptr);
+ return {Name{}, nullptr};
}
auto mi = me->getStrategyInfo<MtInfo>();
// TODO: after a runtime strategy change, it's possible that a measurements::Entry exists but
// the corresponding MtInfo doesn't exist (mi == nullptr); this case needs another longest
// prefix match until an MtInfo is found.
- return std::make_tuple(me->getName(), mi);
+ return {me->getName(), mi};
}
AccessStrategy::MtInfo*