build: switch to C++17

Change-Id: Id6217b5c993f3e4726e89773128b565e5f136bb6
diff --git a/tools/ping/client/main.cpp b/tools/ping/client/main.cpp
index f49c972..a37a461 100644
--- a/tools/ping/client/main.cpp
+++ b/tools/ping/client/main.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2021,  Arizona Board of Regents.
+ * Copyright (c) 2014-2022,  Arizona Board of Regents.
  *
  * This file is part of ndn-tools (Named Data Networking Essential Tools).
  * See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -32,9 +32,7 @@
 #include <boost/program_options/parsers.hpp>
 #include <boost/program_options/variables_map.hpp>
 
-namespace ndn {
-namespace ping {
-namespace client {
+namespace ndn::ping::client {
 
 class Runner : noncopyable
 {
@@ -115,25 +113,7 @@
   boost::asio::signal_set m_signalSetQuit;
 };
 
-static time::milliseconds
-getMinimumPingInterval()
-{
-  return time::milliseconds(1);
-}
-
-static time::milliseconds
-getDefaultPingInterval()
-{
-  return time::milliseconds(1000);
-}
-
-static time::milliseconds
-getDefaultPingTimeoutThreshold()
-{
-  return time::milliseconds(4000);
-}
-
-static void
+[[noreturn]] static void
 usage(const boost::program_options::options_description& options)
 {
   std::cout << "Usage: ndnping [options] ndn:/name/prefix\n"
@@ -151,8 +131,8 @@
   Options options;
   options.shouldAllowStaleData = false;
   options.nPings = -1;
-  options.interval = time::milliseconds(getDefaultPingInterval());
-  options.timeout = time::milliseconds(getDefaultPingTimeoutThreshold());
+  options.interval = 1_s;
+  options.timeout = 4_s;
   options.startSeq = 0;
   options.shouldGenerateRandomSeq = true;
   options.shouldPrintTimestamp = false;
@@ -165,9 +145,9 @@
   visibleOptDesc.add_options()
     ("help,h",      "print this message and exit")
     ("version,V",   "display version and exit")
-    ("interval,i",  po::value<time::milliseconds::rep>()->default_value(getDefaultPingInterval().count()),
+    ("interval,i",  po::value<time::milliseconds::rep>()->default_value(options.interval.count()),
                     "ping interval, in milliseconds")
-    ("timeout,o",   po::value<time::milliseconds::rep>()->default_value(getDefaultPingTimeoutThreshold().count()),
+    ("timeout,o",   po::value<time::milliseconds::rep>()->default_value(options.timeout.count()),
                     "ping timeout, in milliseconds")
     ("count,c",     po::value<int>(&options.nPings), "number of pings to send (default = no limit)")
     ("start,n",     po::value<uint64_t>(&options.startSeq),
@@ -212,9 +192,8 @@
     }
 
     options.interval = time::milliseconds(optVm["interval"].as<time::milliseconds::rep>());
-    if (options.interval < getMinimumPingInterval()) {
-      std::cerr << "ERROR: Specified ping interval is less than the minimum "
-                << getMinimumPingInterval() << "\n";
+    if (options.interval < 1_ms) {
+      std::cerr << "ERROR: Specified ping interval is less than the minimum (1 ms)\n";
       usage(visibleOptDesc);
     }
 
@@ -258,9 +237,7 @@
   return Runner(options).run();
 }
 
-} // namespace client
-} // namespace ping
-} // namespace ndn
+} // namespace ndn::ping::client
 
 int
 main(int argc, char* argv[])
diff --git a/tools/ping/client/ping.cpp b/tools/ping/client/ping.cpp
index c52ed10..5ce8765 100644
--- a/tools/ping/client/ping.cpp
+++ b/tools/ping/client/ping.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2021,  Arizona Board of Regents.
+ * Copyright (c) 2014-2022,  Arizona Board of Regents.
  *
  * This file is part of ndn-tools (Named Data Networking Essential Tools).
  * See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -25,15 +25,11 @@
 
 #include <ndn-cxx/util/random.hpp>
 
-namespace ndn {
-namespace ping {
-namespace client {
+namespace ndn::ping::client {
 
 Ping::Ping(Face& face, const Options& options)
   : m_options(options)
-  , m_nSent(0)
   , m_nextSeq(options.startSeq)
-  , m_nOutstanding(0)
   , m_face(face)
   , m_scheduler(m_face.getIoService())
 {
@@ -60,7 +56,6 @@
   BOOST_ASSERT((m_options.nPings < 0) || (m_nSent < m_options.nPings));
 
   Interest interest(makePingName(m_nextSeq));
-  interest.setCanBePrefix(false);
   interest.setMustBeFresh(!m_options.shouldAllowStaleData);
   interest.setInterestLifetime(m_options.timeout);
 
@@ -126,6 +121,4 @@
   return name;
 }
 
-} // namespace client
-} // namespace ping
-} // namespace ndn
+} // namespace ndn::ping::client
diff --git a/tools/ping/client/ping.hpp b/tools/ping/client/ping.hpp
index a44ca0c..f78d761 100644
--- a/tools/ping/client/ping.hpp
+++ b/tools/ping/client/ping.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2015-2021,  Arizona Board of Regents.
+ * Copyright (c) 2015-2022,  Arizona Board of Regents.
  *
  * This file is part of ndn-tools (Named Data Networking Essential Tools).
  * See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -28,14 +28,12 @@
 
 #include <ndn-cxx/util/signal.hpp>
 
-namespace ndn {
-namespace ping {
-namespace client {
+namespace ndn::ping::client {
 
-typedef time::duration<double, time::milliseconds::period> Rtt;
+using Rtt = time::duration<double, time::milliseconds::period>;
 
 /**
- * @brief options for ndnping client
+ * @brief %Options for ndnping client.
  */
 struct Options
 {
@@ -144,16 +142,14 @@
 
 private:
   const Options& m_options;
-  int m_nSent;
+  int m_nSent = 0;
   uint64_t m_nextSeq;
-  int m_nOutstanding;
+  int m_nOutstanding = 0;
   Face& m_face;
   Scheduler m_scheduler;
   scheduler::ScopedEventId m_nextPingEvent;
 };
 
-} // namespace client
-} // namespace ping
-} // namespace ndn
+} // namespace ndn::ping::client
 
 #endif // NDN_TOOLS_PING_CLIENT_PING_HPP
diff --git a/tools/ping/client/statistics-collector.cpp b/tools/ping/client/statistics-collector.cpp
index 6c29405..0b6b39f 100644
--- a/tools/ping/client/statistics-collector.cpp
+++ b/tools/ping/client/statistics-collector.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2015-2021,  Arizona Board of Regents.
+ * Copyright (c) 2015-2022,  Arizona Board of Regents.
  *
  * This file is part of ndn-tools (Named Data Networking Essential Tools).
  * See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -23,21 +23,11 @@
 
 #include "statistics-collector.hpp"
 
-namespace ndn {
-namespace ping {
-namespace client {
+namespace ndn::ping::client {
 
 StatisticsCollector::StatisticsCollector(Ping& ping, const Options& options)
   : m_ping(ping)
   , m_options(options)
-  , m_nSent(0)
-  , m_nReceived(0)
-  , m_nNacked(0)
-  , m_pingStartTime(time::steady_clock::now())
-  , m_minRtt(std::numeric_limits<double>::max())
-  , m_maxRtt(0.0)
-  , m_sumRtt(0.0)
-  , m_sumRttSquared(0.0)
 {
   m_ping.afterData.connect([this] (auto&&, Rtt rtt) { recordData(rtt); });
   m_ping.afterNack.connect([this] (auto&&...) { recordNack(); });
@@ -153,6 +143,4 @@
   return os;
 }
 
-} // namespace client
-} // namespace ping
-} // namespace ndn
+} // namespace ndn::ping::client
diff --git a/tools/ping/client/statistics-collector.hpp b/tools/ping/client/statistics-collector.hpp
index 9622717..1810208 100644
--- a/tools/ping/client/statistics-collector.hpp
+++ b/tools/ping/client/statistics-collector.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2015-2021,  Arizona Board of Regents.
+ * Copyright (c) 2015-2022,  Arizona Board of Regents.
  *
  * This file is part of ndn-tools (Named Data Networking Essential Tools).
  * See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -28,9 +28,7 @@
 
 #include "ping.hpp"
 
-namespace ndn {
-namespace ping {
-namespace client {
+namespace ndn::ping::client {
 
 /**
  * @brief statistics data
@@ -52,6 +50,9 @@
 
   std::ostream&
   printSummary(std::ostream& os) const;
+
+  friend std::ostream&
+  operator<<(std::ostream& os, const Statistics& statistics);
 };
 
 /**
@@ -69,7 +70,7 @@
   /**
    * @brief Compute and return ping statistics as structure
    */
-  Statistics
+  [[nodiscard]] Statistics
   computeStatistics() const;
 
 PUBLIC_WITH_TESTS_ELSE_PRIVATE:
@@ -94,21 +95,16 @@
 private:
   Ping& m_ping;
   const Options& m_options;
-  int m_nSent;
-  int m_nReceived;
-  int m_nNacked;
-  time::steady_clock::time_point m_pingStartTime;
-  double m_minRtt;
-  double m_maxRtt;
-  double m_sumRtt;
-  double m_sumRttSquared;
+  time::steady_clock::time_point m_pingStartTime = time::steady_clock::now();
+  int m_nSent = 0;
+  int m_nReceived = 0;
+  int m_nNacked = 0;
+  double m_minRtt = std::numeric_limits<double>::max();
+  double m_maxRtt = 0.0;
+  double m_sumRtt = 0.0;
+  double m_sumRttSquared = 0.0;
 };
 
-std::ostream&
-operator<<(std::ostream& os, const Statistics& statistics);
-
-} // namespace client
-} // namespace ping
-} // namespace ndn
+} // namespace ndn::ping::client
 
 #endif // NDN_TOOLS_PING_CLIENT_STATISTICS_COLLECTOR_HPP
diff --git a/tools/ping/client/tracer.cpp b/tools/ping/client/tracer.cpp
index 7db5085..7c16a4c 100644
--- a/tools/ping/client/tracer.cpp
+++ b/tools/ping/client/tracer.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2015-2021,  Arizona Board of Regents.
+ * Copyright (c) 2015-2022,  Arizona Board of Regents.
  *
  * This file is part of ndn-tools (Named Data Networking Essential Tools).
  * See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -22,9 +22,7 @@
 
 #include "tracer.hpp"
 
-namespace ndn {
-namespace ping {
-namespace client {
+namespace ndn::ping::client {
 
 Tracer::Tracer(Ping& ping, const Options& options)
   : m_options(options)
@@ -72,6 +70,4 @@
   std::cerr << "ERROR: " << msg << "\n";
 }
 
-} // namespace client
-} // namespace ping
-} // namespace ndn
+} // namespace ndn::ping::client
diff --git a/tools/ping/client/tracer.hpp b/tools/ping/client/tracer.hpp
index b6b4812..c2d375e 100644
--- a/tools/ping/client/tracer.hpp
+++ b/tools/ping/client/tracer.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2015-2021,  Arizona Board of Regents.
+ * Copyright (c) 2015-2022,  Arizona Board of Regents.
  *
  * This file is part of ndn-tools (Named Data Networking Essential Tools).
  * See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -27,9 +27,7 @@
 
 #include "ping.hpp"
 
-namespace ndn {
-namespace ping {
-namespace client {
+namespace ndn::ping::client {
 
 /**
  * @brief prints ping responses and timeouts
@@ -80,8 +78,6 @@
   const Options& m_options;
 };
 
-} // namespace client
-} // namespace ping
-} // namespace ndn
+} // namespace ndn::ping::client
 
 #endif // NDN_TOOLS_PING_CLIENT_TRACER_HPP