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/tests/daemon/face/datagram-transport.t.cpp b/tests/daemon/face/datagram-transport.t.cpp
index 6d41a1f..631e394 100644
--- a/tests/daemon/face/datagram-transport.t.cpp
+++ b/tests/daemon/face/datagram-transport.t.cpp
@@ -56,7 +56,7 @@
   std::vector<uint8_t> readBuf(block1.size());
   this->remoteRead(readBuf);
 
-  BOOST_CHECK_EQUAL_COLLECTIONS(readBuf.begin(), readBuf.end(), block1.begin(), block1.end());
+  BOOST_TEST(readBuf == block1, boost::test_tools::per_element());
   BOOST_CHECK_EQUAL(this->transport->getState(), TransportState::UP);
 }
 
diff --git a/tests/daemon/face/generic-link-service.t.cpp b/tests/daemon/face/generic-link-service.t.cpp
index 11aeeb8..e4f0425 100644
--- a/tests/daemon/face/generic-link-service.t.cpp
+++ b/tests/daemon/face/generic-link-service.t.cpp
@@ -229,8 +229,7 @@
 
   auto interest1 = makeInterest("/23Rd9hEiR");
   lp::Packet lpPacket;
-  lpPacket.set<lp::FragmentField>(std::make_pair(
-    interest1->wireEncode().begin(), interest1->wireEncode().end()));
+  lpPacket.set<lp::FragmentField>({interest1->wireEncode().begin(), interest1->wireEncode().end()});
   lpPacket.set<lp::SequenceField>(0); // force LpPacket encoding
 
   transport->receivePacket(lpPacket.wireEncode());
@@ -264,8 +263,7 @@
 
   auto data1 = makeData("/12345689");
   lp::Packet lpPacket;
-  lpPacket.set<lp::FragmentField>(std::make_pair(
-    data1->wireEncode().begin(), data1->wireEncode().end()));
+  lpPacket.set<lp::FragmentField>({data1->wireEncode().begin(), data1->wireEncode().end()});
   lpPacket.set<lp::SequenceField>(0); // force LpPacket encoding
 
   transport->receivePacket(lpPacket.wireEncode());
@@ -282,11 +280,11 @@
   options.allowLocalFields = false;
   initialize(options);
 
-  lp::Nack nack1 = makeNack(*makeInterest("/localhost/test", false, std::nullopt, 323),
-                            lp::NackReason::NO_ROUTE);
+  auto nack1 = makeNack(*makeInterest("/localhost/test", false, std::nullopt, 323),
+                        lp::NackReason::NO_ROUTE);
   lp::Packet lpPacket;
-  lpPacket.set<lp::FragmentField>(std::make_pair(
-    nack1.getInterest().wireEncode().begin(), nack1.getInterest().wireEncode().end()));
+  lpPacket.set<lp::FragmentField>({nack1.getInterest().wireEncode().begin(),
+                                   nack1.getInterest().wireEncode().end()});
   lpPacket.set<lp::NackField>(nack1.getHeader());
 
   transport->receivePacket(lpPacket.wireEncode());
@@ -430,12 +428,9 @@
 
   // fragment the packet
   LpFragmenter fragmenter({});
-  size_t mtu = 100;
-  bool isOk = false;
-  std::vector<lp::Packet> frags;
-  std::tie(isOk, frags) = fragmenter.fragmentPacket(packet, mtu);
+  auto [isOk, frags] = fragmenter.fragmentPacket(packet, 100);
   BOOST_REQUIRE(isOk);
-  BOOST_CHECK_GT(frags.size(), 1);
+  BOOST_TEST(frags.size() > 1);
 
   // receive the fragments
   for (ssize_t fragIndex = frags.size() - 1; fragIndex >= 0; --fragIndex) {
@@ -970,11 +965,11 @@
   options.allowLocalFields = true;
   initialize(options);
 
-  lp::Nack nack = makeNack(*makeInterest("/localhost/test", false, std::nullopt, 123),
-                           lp::NackReason::NO_ROUTE);
+  auto nack = makeNack(*makeInterest("/localhost/test", false, std::nullopt, 123),
+                       lp::NackReason::NO_ROUTE);
   lp::Packet packet;
-  packet.set<lp::FragmentField>(std::make_pair(
-    nack.getInterest().wireEncode().begin(), nack.getInterest().wireEncode().end()));
+  packet.set<lp::FragmentField>({nack.getInterest().wireEncode().begin(),
+                                 nack.getInterest().wireEncode().end()});
   packet.set<lp::NackField>(nack.getHeader());
   packet.set<lp::NextHopFaceIdField>(1000);
 
@@ -1205,11 +1200,11 @@
 
 BOOST_AUTO_TEST_CASE(ReceiveCongestionMarkNack)
 {
-  lp::Nack nack = makeNack(*makeInterest("/localhost/test", false, std::nullopt, 123),
-                           lp::NackReason::NO_ROUTE);
+  auto nack = makeNack(*makeInterest("/localhost/test", false, std::nullopt, 123),
+                       lp::NackReason::NO_ROUTE);
   lp::Packet packet;
-  packet.set<lp::FragmentField>(std::make_pair(
-    nack.getInterest().wireEncode().begin(), nack.getInterest().wireEncode().end()));
+  packet.set<lp::FragmentField>({nack.getInterest().wireEncode().begin(),
+                                 nack.getInterest().wireEncode().end()});
   packet.set<lp::NackField>(nack.getHeader());
   packet.set<lp::CongestionMarkField>(1);
 
@@ -1310,11 +1305,11 @@
   options.allowSelfLearning = true;
   initialize(options);
 
-  lp::Nack nack = makeNack(*makeInterest("/localhost/test", false, std::nullopt, 123),
-                           lp::NackReason::NO_ROUTE);
+  auto nack = makeNack(*makeInterest("/localhost/test", false, std::nullopt, 123),
+                       lp::NackReason::NO_ROUTE);
   lp::Packet packet;
-  packet.set<lp::FragmentField>(std::make_pair(
-    nack.getInterest().wireEncode().begin(), nack.getInterest().wireEncode().end()));
+  packet.set<lp::FragmentField>({nack.getInterest().wireEncode().begin(),
+                                 nack.getInterest().wireEncode().end()});
   packet.set<lp::NackField>(nack.getHeader());
   packet.set<lp::NonDiscoveryField>(lp::EmptyValue{});
 
@@ -1418,11 +1413,11 @@
   options.allowSelfLearning = true;
   initialize(options);
 
-  lp::Nack nack = makeNack(*makeInterest("/localhost/test", false, std::nullopt, 123),
-                           lp::NackReason::NO_ROUTE);
+  auto nack = makeNack(*makeInterest("/localhost/test", false, std::nullopt, 123),
+                       lp::NackReason::NO_ROUTE);
   lp::Packet packet;
-  packet.set<lp::FragmentField>(std::make_pair(
-    nack.getInterest().wireEncode().begin(), nack.getInterest().wireEncode().end()));
+  packet.set<lp::FragmentField>({nack.getInterest().wireEncode().begin(),
+                                 nack.getInterest().wireEncode().end()});
   packet.set<lp::NackField>(nack.getHeader());
   auto pah = makePrefixAnnHeader("/local/ndn/prefix");
   packet.set<lp::PrefixAnnouncementField>(pah);
diff --git a/tests/daemon/face/lp-fragmenter.t.cpp b/tests/daemon/face/lp-fragmenter.t.cpp
index 30eb8e9..8bd48c2 100644
--- a/tests/daemon/face/lp-fragmenter.t.cpp
+++ b/tests/daemon/face/lp-fragmenter.t.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-2022,  Regents of the University of California,
  *                           Arizona Board of Regents,
  *                           Colorado State University,
  *                           University Pierre & Marie Curie, Sorbonne University,
@@ -52,9 +52,7 @@
   auto data = makeData("/test/data123");
   packet.add<lp::FragmentField>({data->wireEncode().begin(), data->wireEncode().end()});
 
-  bool isOk = false;
-  std::vector<lp::Packet> frags;
-  std::tie(isOk, frags) = fragmenter.fragmentPacket(packet, mtu);
+  auto [isOk, frags] = fragmenter.fragmentPacket(packet, mtu);
   BOOST_REQUIRE(isOk);
   BOOST_REQUIRE_EQUAL(frags.size(), 1);
 
@@ -64,8 +62,7 @@
   BOOST_CHECK(!frags[0].has<lp::FragCountField>());
   BOOST_CHECK_LE(frags[0].wireEncode().size(), mtu);
 
-  ndn::Buffer::const_iterator fragBegin, fragEnd;
-  std::tie(fragBegin, fragEnd) = frags[0].get<lp::FragmentField>();
+  auto [fragBegin, fragEnd] = frags[0].get<lp::FragmentField>();
   BOOST_CHECK_EQUAL_COLLECTIONS(data->wireEncode().begin(), data->wireEncode().end(),
                                 fragBegin, fragEnd);
 }
@@ -80,9 +77,7 @@
   auto data = makeData("/test/data123/123456789/987654321/123456789");
   packet.add<lp::FragmentField>({data->wireEncode().begin(), data->wireEncode().end()});
 
-  bool isOk = false;
-  std::vector<lp::Packet> frags;
-  std::tie(isOk, frags) = fragmenter.fragmentPacket(packet, mtu);
+  auto [isOk, frags] = fragmenter.fragmentPacket(packet, mtu);
   BOOST_REQUIRE(isOk);
   BOOST_REQUIRE_EQUAL(frags.size(), 5);
 
@@ -93,8 +88,7 @@
   BOOST_CHECK_EQUAL(frags[0].get<lp::FragIndexField>(), 0);
   BOOST_CHECK_EQUAL(frags[0].get<lp::FragCountField>(), 5);
   BOOST_CHECK_LE(frags[0].wireEncode().size(), mtu);
-  ndn::Buffer::const_iterator frag0Begin, frag0End;
-  std::tie(frag0Begin, frag0End) = frags[0].get<lp::FragmentField>();
+  auto [frag0Begin, frag0End] = frags[0].get<lp::FragmentField>();
   BOOST_REQUIRE_LE(std::distance(frag0Begin, frag0End), reassembledPayload.size());
   auto reassembledPos = std::copy(frag0Begin, frag0End, reassembledPayload.begin());
 
@@ -103,8 +97,7 @@
   BOOST_CHECK_EQUAL(frags[1].get<lp::FragIndexField>(), 1);
   BOOST_CHECK_EQUAL(frags[1].get<lp::FragCountField>(), 5);
   BOOST_CHECK_LE(frags[1].wireEncode().size(), mtu);
-  ndn::Buffer::const_iterator frag1Begin, frag1End;
-  std::tie(frag1Begin, frag1End) = frags[1].get<lp::FragmentField>();
+  auto [frag1Begin, frag1End] = frags[1].get<lp::FragmentField>();
   BOOST_REQUIRE_LE(std::distance(frag1Begin, frag1End),
                    std::distance(reassembledPos, reassembledPayload.end()));
   reassembledPos = std::copy(frag1Begin, frag1End, reassembledPos);
@@ -114,8 +107,7 @@
   BOOST_CHECK_EQUAL(frags[2].get<lp::FragIndexField>(), 2);
   BOOST_CHECK_EQUAL(frags[2].get<lp::FragCountField>(), 5);
   BOOST_CHECK_LE(frags[2].wireEncode().size(), mtu);
-  ndn::Buffer::const_iterator frag2Begin, frag2End;
-  std::tie(frag2Begin, frag2End) = frags[2].get<lp::FragmentField>();
+  auto [frag2Begin, frag2End] = frags[2].get<lp::FragmentField>();
   BOOST_REQUIRE_LE(std::distance(frag2Begin, frag2End),
                    std::distance(reassembledPos, reassembledPayload.end()));
   reassembledPos = std::copy(frag2Begin, frag2End, reassembledPos);
@@ -125,8 +117,7 @@
   BOOST_CHECK_EQUAL(frags[3].get<lp::FragIndexField>(), 3);
   BOOST_CHECK_EQUAL(frags[3].get<lp::FragCountField>(), 5);
   BOOST_CHECK_LE(frags[3].wireEncode().size(), mtu);
-  ndn::Buffer::const_iterator frag3Begin, frag3End;
-  std::tie(frag3Begin, frag3End) = frags[3].get<lp::FragmentField>();
+  auto [frag3Begin, frag3End] = frags[3].get<lp::FragmentField>();
   BOOST_REQUIRE_LE(std::distance(frag3Begin, frag3End),
                    std::distance(reassembledPos, reassembledPayload.end()));
   reassembledPos = std::copy(frag3Begin, frag3End, reassembledPos);
@@ -136,14 +127,12 @@
   BOOST_CHECK_EQUAL(frags[4].get<lp::FragIndexField>(), 4);
   BOOST_CHECK_EQUAL(frags[4].get<lp::FragCountField>(), 5);
   BOOST_CHECK_LE(frags[4].wireEncode().size(), mtu);
-  ndn::Buffer::const_iterator frag4Begin, frag4End;
-  std::tie(frag4Begin, frag4End) = frags[4].get<lp::FragmentField>();
+  auto [frag4Begin, frag4End] = frags[4].get<lp::FragmentField>();
   BOOST_REQUIRE_LE(std::distance(frag4Begin, frag4End),
                    std::distance(reassembledPos, reassembledPayload.end()));
   std::copy(frag4Begin, frag4End, reassembledPos);
 
-  BOOST_CHECK_EQUAL_COLLECTIONS(data->wireEncode().begin(), data->wireEncode().end(),
-                                reassembledPayload.begin(), reassembledPayload.end());
+  BOOST_TEST(data->wireEncode() == reassembledPayload, boost::test_tools::per_element());
 }
 
 BOOST_AUTO_TEST_CASE(MtuTooSmall)
diff --git a/tests/daemon/face/lp-reliability.t.cpp b/tests/daemon/face/lp-reliability.t.cpp
index 526708f..0d891e0 100644
--- a/tests/daemon/face/lp-reliability.t.cpp
+++ b/tests/daemon/face/lp-reliability.t.cpp
@@ -140,8 +140,7 @@
   getPktNum(const lp::Packet& pkt)
   {
     BOOST_REQUIRE(pkt.has<lp::FragmentField>());
-    ndn::Buffer::const_iterator begin, end;
-    std::tie(begin, end) = pkt.get<lp::FragmentField>();
+    auto [begin, end] = pkt.get<lp::FragmentField>();
     if (std::distance(begin, end) < 4) {
       return 0;
     }
diff --git a/tests/daemon/face/tcp-transport.t.cpp b/tests/daemon/face/tcp-transport.t.cpp
index 1ad0b70..c01aaef 100644
--- a/tests/daemon/face/tcp-transport.t.cpp
+++ b/tests/daemon/face/tcp-transport.t.cpp
@@ -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,
@@ -187,14 +187,14 @@
   // measure retry intervals
   auto retryTime1 = time::steady_clock::now();
 
-  auto expectedWait1 = TcpTransport::s_initialReconnectWait;
+  auto expectedWait1 = TcpTransport::INITIAL_RECONNECT_DELAY;
   BOOST_REQUIRE_EQUAL(this->limitedIo.run(2, expectedWait1 + 1_s), // add some slack
                       LimitedIo::EXCEED_OPS);
   auto retryTime2 = time::steady_clock::now();
   BOOST_CHECK_EQUAL(transportObserver->getState(), TransportState::DOWN);
 
   auto expectedWait2 = time::duration_cast<time::nanoseconds>(expectedWait1 *
-                                                              TcpTransport::s_reconnectWaitMultiplier);
+                                                              TcpTransport::RECONNECT_DELAY_MULTIPLIER);
   BOOST_REQUIRE_EQUAL(this->limitedIo.run(2, expectedWait2 + 1_s), // add some slack
                       LimitedIo::EXCEED_OPS);
   auto retryTime3 = time::steady_clock::now();
@@ -210,7 +210,7 @@
   this->startAccept(remoteEp);
 
   auto expectedWait3 = time::duration_cast<time::nanoseconds>(expectedWait2 *
-                                                              TcpTransport::s_reconnectWaitMultiplier);
+                                                              TcpTransport::RECONNECT_DELAY_MULTIPLIER);
   BOOST_REQUIRE_EQUAL(this->limitedIo.run(3, // reconnect, handleReconnect, async_accept
                                           expectedWait3 + 1_s), LimitedIo::EXCEED_OPS);
   BOOST_CHECK_EQUAL(transportObserver->getState(), TransportState::UP);
diff --git a/tests/daemon/face/unicast-udp-transport.t.cpp b/tests/daemon/face/unicast-udp-transport.t.cpp
index e5962db..24d47fd 100644
--- a/tests/daemon/face/unicast-udp-transport.t.cpp
+++ b/tests/daemon/face/unicast-udp-transport.t.cpp
@@ -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,
@@ -162,7 +162,7 @@
     });
   BOOST_REQUIRE_EQUAL(limitedIo.run(1, 1_s), LimitedIo::EXCEED_OPS);
 
-  BOOST_CHECK_EQUAL_COLLECTIONS(readBuf.begin(), readBuf.end(), block1.begin(), block1.end());
+  BOOST_TEST(readBuf == block1, boost::test_tools::per_element());
 
   Block block2 = ndn::encoding::makeStringBlock(301, "world");
   ndn::Buffer buf(block2.begin(), block2.end());