build: switch to C++17

Change-Id: Ie68020a04b7e20b74778b6d0370544ded55c5e26
diff --git a/tests/daemon/face/channel-fixture.hpp b/tests/daemon/face/channel-fixture.hpp
index 31a9439..c3d07c6 100644
--- a/tests/daemon/face/channel-fixture.hpp
+++ b/tests/daemon/face/channel-fixture.hpp
@@ -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,
@@ -43,8 +43,7 @@
 template<class ChannelT, class EndpointT>
 class ChannelFixture : public GlobalIoFixture
 {
-  static_assert(std::is_base_of<Channel, ChannelT>::value,
-                "ChannelFixture must be instantiated with a type derived from Channel");
+  static_assert(std::is_base_of_v<Channel, ChannelT>);
 
 public:
   virtual
@@ -71,14 +70,15 @@
   }
 
   virtual shared_ptr<ChannelT>
-  makeChannel(const boost::asio::ip::address&, uint16_t port = 0, optional<size_t> mtu = nullopt)
+  makeChannel(const boost::asio::ip::address&, uint16_t port = 0,
+              std::optional<size_t> mtu = std::nullopt)
   {
     BOOST_FAIL("Unimplemented");
     return nullptr;
   }
 
   void
-  listen(const boost::asio::ip::address& addr, optional<size_t> mtu = nullopt)
+  listen(const boost::asio::ip::address& addr, std::optional<size_t> mtu = std::nullopt)
   {
     listenerEp = EndpointT{addr, 7030};
     listenerChannel = makeChannel(addr, 7030, mtu);
diff --git a/tests/daemon/face/face.t.cpp b/tests/daemon/face/face.t.cpp
index 641088f..bcaa90a 100644
--- a/tests/daemon/face/face.t.cpp
+++ b/tests/daemon/face/face.t.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,
@@ -114,7 +114,7 @@
   }
 
   for (size_t i = 0; i < nInNacks; ++i) {
-    face1->receiveNack(makeNack(*makeInterest("/StnEVTj4Ex", false, nullopt, 561),
+    face1->receiveNack(makeNack(*makeInterest("/StnEVTj4Ex", false, std::nullopt, 561),
                                 lp::NackReason::CONGESTION), 0);
   }
 
@@ -127,7 +127,7 @@
   }
 
   for (size_t i = 0; i < nOutNacks; ++i) {
-    face1->sendNack(makeNack(*makeInterest("/9xK6FbwIBM", false, nullopt, 365),
+    face1->sendNack(makeNack(*makeInterest("/9xK6FbwIBM", false, std::nullopt, 365),
                              lp::NackReason::CONGESTION));
   }
 
diff --git a/tests/daemon/face/factory-test-common.hpp b/tests/daemon/face/factory-test-common.hpp
index f92d388..4e65d34 100644
--- a/tests/daemon/face/factory-test-common.hpp
+++ b/tests/daemon/face/factory-test-common.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2018,  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,
@@ -44,7 +44,7 @@
 inline void
 createFace(ProtocolFactory& factory,
            const FaceUri& remoteUri,
-           const optional<FaceUri>& localUri,
+           const std::optional<FaceUri>& localUri,
            const FaceParams& params,
            const CreateFaceExpectedResult& expected,
            const std::function<void(const Face&)>& extraChecks = nullptr)
diff --git a/tests/daemon/face/generic-link-service.t.cpp b/tests/daemon/face/generic-link-service.t.cpp
index 219154e..11aeeb8 100644
--- a/tests/daemon/face/generic-link-service.t.cpp
+++ b/tests/daemon/face/generic-link-service.t.cpp
@@ -193,7 +193,7 @@
   options.allowLocalFields = false;
   initialize(options);
 
-  auto nack1 = makeNack(*makeInterest("/localhost/test", false, nullopt, 323),
+  auto nack1 = makeNack(*makeInterest("/localhost/test", false, std::nullopt, 323),
                         lp::NackReason::NO_ROUTE);
   face->sendNack(nack1);
 
@@ -282,7 +282,7 @@
   options.allowLocalFields = false;
   initialize(options);
 
-  lp::Nack nack1 = makeNack(*makeInterest("/localhost/test", false, nullopt, 323),
+  lp::Nack nack1 = makeNack(*makeInterest("/localhost/test", false, std::nullopt, 323),
                             lp::NackReason::NO_ROUTE);
   lp::Packet lpPacket;
   lpPacket.set<lp::FragmentField>(std::make_pair(
@@ -538,7 +538,7 @@
   options.reliabilityOptions.isEnabled = true;
   initialize(options);
 
-  auto nack1 = makeNack(*makeInterest("/localhost/test", false, nullopt, 323),
+  auto nack1 = makeNack(*makeInterest("/localhost/test", false, std::nullopt, 323),
                         lp::NackReason::NO_ROUTE);
   face->sendNack(nack1);
 
@@ -970,7 +970,7 @@
   options.allowLocalFields = true;
   initialize(options);
 
-  lp::Nack nack = makeNack(*makeInterest("/localhost/test", false, nullopt, 123),
+  lp::Nack nack = makeNack(*makeInterest("/localhost/test", false, std::nullopt, 123),
                            lp::NackReason::NO_ROUTE);
   lp::Packet packet;
   packet.set<lp::FragmentField>(std::make_pair(
@@ -1030,7 +1030,7 @@
   options.allowLocalFields = true;
   initialize(options);
 
-  lp::Nack nack = makeNack(*makeInterest("/localhost/test", false, nullopt, 123),
+  lp::Nack nack = makeNack(*makeInterest("/localhost/test", false, std::nullopt, 123),
                            lp::NackReason::NO_ROUTE);
   lp::Packet packet(nack.getInterest().wireEncode());
   packet.set<lp::NackField>(nack.getHeader());
@@ -1122,7 +1122,7 @@
   options.allowLocalFields = true;
   initialize(options);
 
-  lp::Nack nack = makeNack(*makeInterest("/TPAhdiHz", false, nullopt, 278),
+  lp::Nack nack = makeNack(*makeInterest("/TPAhdiHz", false, std::nullopt, 278),
                            lp::NackReason::CONGESTION);
   lp::Packet packet(nack.getInterest().wireEncode());
   packet.set<lp::NackField>(nack.getHeader());
@@ -1163,7 +1163,7 @@
 
 BOOST_AUTO_TEST_CASE(SendCongestionMarkNack)
 {
-  lp::Nack nack = makeNack(*makeInterest("/localhost/test", false, nullopt, 123),
+  lp::Nack nack = makeNack(*makeInterest("/localhost/test", false, std::nullopt, 123),
                            lp::NackReason::NO_ROUTE);
   nack.setTag(make_shared<lp::CongestionMarkTag>(std::numeric_limits<uint64_t>::max()));
 
@@ -1205,7 +1205,7 @@
 
 BOOST_AUTO_TEST_CASE(ReceiveCongestionMarkNack)
 {
-  lp::Nack nack = makeNack(*makeInterest("/localhost/test", false, nullopt, 123),
+  lp::Nack nack = makeNack(*makeInterest("/localhost/test", false, std::nullopt, 123),
                            lp::NackReason::NO_ROUTE);
   lp::Packet packet;
   packet.set<lp::FragmentField>(std::make_pair(
@@ -1310,7 +1310,7 @@
   options.allowSelfLearning = true;
   initialize(options);
 
-  lp::Nack nack = makeNack(*makeInterest("/localhost/test", false, nullopt, 123),
+  lp::Nack nack = makeNack(*makeInterest("/localhost/test", false, std::nullopt, 123),
                            lp::NackReason::NO_ROUTE);
   lp::Packet packet;
   packet.set<lp::FragmentField>(std::make_pair(
@@ -1418,7 +1418,7 @@
   options.allowSelfLearning = true;
   initialize(options);
 
-  lp::Nack nack = makeNack(*makeInterest("/localhost/test", false, nullopt, 123),
+  lp::Nack nack = makeNack(*makeInterest("/localhost/test", false, std::nullopt, 123),
                            lp::NackReason::NO_ROUTE);
   lp::Packet packet;
   packet.set<lp::FragmentField>(std::make_pair(
diff --git a/tests/daemon/face/lp-reliability.t.cpp b/tests/daemon/face/lp-reliability.t.cpp
index e3a84c9..526708f 100644
--- a/tests/daemon/face/lp-reliability.t.cpp
+++ b/tests/daemon/face/lp-reliability.t.cpp
@@ -33,6 +33,7 @@
 #include "dummy-transport.hpp"
 
 #include <cstring>
+#include <unordered_set>
 
 namespace nfd {
 namespace face {
diff --git a/tests/daemon/face/tcp-channel-fixture.hpp b/tests/daemon/face/tcp-channel-fixture.hpp
index ca0f28e..ab8d431 100644
--- a/tests/daemon/face/tcp-channel-fixture.hpp
+++ b/tests/daemon/face/tcp-channel-fixture.hpp
@@ -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,
@@ -44,7 +44,8 @@
   }
 
   shared_ptr<TcpChannel>
-  makeChannel(const boost::asio::ip::address& addr, uint16_t port = 0, optional<size_t> mtu = nullopt) final
+  makeChannel(const boost::asio::ip::address& addr, uint16_t port = 0,
+              std::optional<size_t> mtu = std::nullopt) final
   {
     if (port == 0)
       port = getNextPort();
diff --git a/tests/daemon/face/test-netif.cpp b/tests/daemon/face/test-netif.cpp
index d97ce47..36719ad 100644
--- a/tests/daemon/face/test-netif.cpp
+++ b/tests/daemon/face/test-netif.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,
@@ -44,7 +44,7 @@
 std::vector<shared_ptr<const NetworkInterface>>
 collectNetworkInterfaces(bool allowCached)
 {
-  static optional<std::vector<shared_ptr<const NetworkInterface>>> cached;
+  static std::optional<std::vector<shared_ptr<const NetworkInterface>>> cached;
   if (!allowCached || !cached) {
     NetworkMonitor netmon(getGlobalIoService());
     cached = enumerateNetworkInterfaces(netmon);
diff --git a/tests/daemon/face/udp-channel-fixture.hpp b/tests/daemon/face/udp-channel-fixture.hpp
index 6f57b90..ac30738 100644
--- a/tests/daemon/face/udp-channel-fixture.hpp
+++ b/tests/daemon/face/udp-channel-fixture.hpp
@@ -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,
@@ -39,12 +39,14 @@
 {
 protected:
   shared_ptr<UdpChannel>
-  makeChannel(const boost::asio::ip::address& addr, uint16_t port = 0, optional<size_t> mtu = nullopt) final
+  makeChannel(const boost::asio::ip::address& addr, uint16_t port = 0,
+              std::optional<size_t> mtu = std::nullopt) final
   {
     if (port == 0)
       port = getNextPort();
 
-    return std::make_shared<UdpChannel>(udp::Endpoint(addr, port), 2_s, false, mtu.value_or(ndn::MAX_NDN_PACKET_SIZE));
+    return std::make_shared<UdpChannel>(udp::Endpoint(addr, port), 2_s, false,
+                                        mtu.value_or(ndn::MAX_NDN_PACKET_SIZE));
   }
 
   void
diff --git a/tests/daemon/face/websocket-channel-fixture.hpp b/tests/daemon/face/websocket-channel-fixture.hpp
index 3072992..62c717b 100644
--- a/tests/daemon/face/websocket-channel-fixture.hpp
+++ b/tests/daemon/face/websocket-channel-fixture.hpp
@@ -39,7 +39,7 @@
 protected:
   shared_ptr<WebSocketChannel>
   makeChannel(const boost::asio::ip::address& addr, uint16_t port = 0,
-              optional<size_t> mtu = nullopt) final
+              std::optional<size_t> mtu = std::nullopt) final
   {
     if (port == 0)
       port = getNextPort();
diff --git a/tests/daemon/fw/algorithm.t.cpp b/tests/daemon/fw/algorithm.t.cpp
index 4a86d78..d0bd2f0 100644
--- a/tests/daemon/fw/algorithm.t.cpp
+++ b/tests/daemon/fw/algorithm.t.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,
@@ -155,7 +155,7 @@
   auto face2 = make_shared<DummyFace>();
   auto face3 = make_shared<DummyFace>();
 
-  auto interest = makeInterest("/totzXG0d", false, nullopt, 29321);
+  auto interest = makeInterest("/totzXG0d", false, std::nullopt, 29321);
   pit::Entry entry(*interest);
   BOOST_CHECK_EQUAL(hasPendingOutRecords(entry), false);
 
diff --git a/tests/daemon/fw/choose-strategy.hpp b/tests/daemon/fw/choose-strategy.hpp
index 0da7b84..cfb5ee6 100644
--- a/tests/daemon/fw/choose-strategy.hpp
+++ b/tests/daemon/fw/choose-strategy.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,
@@ -48,7 +48,7 @@
  *  \return a reference to the strategy
  */
 template<typename S>
-typename std::enable_if<std::is_base_of<fw::Strategy, S>::value, S&>::type
+std::enable_if_t<std::is_base_of_v<fw::Strategy, S>, S&>
 choose(Forwarder& forwarder, const Name& prefix = "/",
        const Name& instanceName = S::getStrategyName())
 {
diff --git a/tests/daemon/fw/forwarder.t.cpp b/tests/daemon/fw/forwarder.t.cpp
index 5fb2776..eef2cea 100644
--- a/tests/daemon/fw/forwarder.t.cpp
+++ b/tests/daemon/fw/forwarder.t.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,
@@ -160,17 +160,17 @@
   auto face2 = addFace();
 
   Pit& pit = forwarder.getPit();
-  auto interestA1 = makeInterest("/A", false, nullopt, 8378);
+  auto interestA1 = makeInterest("/A", false, std::nullopt, 8378);
   auto pitA = pit.insert(*interestA1).first;
   pitA->insertOrUpdateInRecord(*face1, *interestA1);
 
-  auto interestA2 = makeInterest("/A", false, nullopt, 1698);
+  auto interestA2 = makeInterest("/A", false, std::nullopt, 1698);
   auto outA2 = forwarder.onOutgoingInterest(*interestA2, *face2, pitA);
   BOOST_REQUIRE(outA2 != nullptr);
   BOOST_CHECK_EQUAL(outA2->getLastNonce(), 1698);
 
   // This packet will be dropped because HopLimit=0
-  auto interestA3 = makeInterest("/A", false, nullopt, 9876);
+  auto interestA3 = makeInterest("/A", false, std::nullopt, 9876);
   interestA3->setHopLimit(0);
   auto outA3 = forwarder.onOutgoingInterest(*interestA3, *face2, pitA);
   BOOST_CHECK(outA3 == nullptr);
@@ -468,10 +468,10 @@
   Pit& pit = forwarder.getPit();
 
   // dispatch to the correct strategy
-  auto interest1 = makeInterest("/A/AYJqayrzF", false, nullopt, 562);
+  auto interest1 = makeInterest("/A/AYJqayrzF", false, std::nullopt, 562);
   auto pit1 = pit.insert(*interest1).first;
   pit1->insertOrUpdateOutRecord(*face1, *interest1);
-  auto interest2 = makeInterest("/B/EVyP73ru", false, nullopt, 221);
+  auto interest2 = makeInterest("/B/EVyP73ru", false, std::nullopt, 221);
   auto pit2 = pit.insert(*interest2).first;
   pit2->insertOrUpdateOutRecord(*face1, *interest2);
 
@@ -496,7 +496,7 @@
   BOOST_CHECK_EQUAL(outRecord1->getIncomingNack()->getReason(), lp::NackReason::CONGESTION);
 
   // drop if no PIT entry
-  auto nack3 = makeNack(*makeInterest("/yEcw5HhdM", false, nullopt, 243), lp::NackReason::CONGESTION);
+  auto nack3 = makeNack(*makeInterest("/yEcw5HhdM", false, std::nullopt, 243), lp::NackReason::CONGESTION);
   strategyA.afterReceiveNack_count = 0;
   strategyB.afterReceiveNack_count = 0;
   forwarder.onIncomingNack(nack3, FaceEndpoint(*face1, 0));
@@ -504,7 +504,7 @@
   BOOST_CHECK_EQUAL(strategyB.afterReceiveNack_count, 0);
 
   // drop if no out-record
-  auto interest4 = makeInterest("/Etab4KpY", false, nullopt, 157);
+  auto interest4 = makeInterest("/Etab4KpY", false, std::nullopt, 157);
   auto pit4 = pit.insert(*interest4).first;
   pit4->insertOrUpdateOutRecord(*face1, *interest4);
 
@@ -516,7 +516,7 @@
   BOOST_CHECK_EQUAL(strategyB.afterReceiveNack_count, 0);
 
   // drop if Nonce does not match out-record
-  auto nack4b = makeNack(*makeInterest("/Etab4KpY", false, nullopt, 294), lp::NackReason::CONGESTION);
+  auto nack4b = makeNack(*makeInterest("/Etab4KpY", false, std::nullopt, 294), lp::NackReason::CONGESTION);
   strategyA.afterReceiveNack_count = 0;
   strategyB.afterReceiveNack_count = 0;
   forwarder.onIncomingNack(nack4b, FaceEndpoint(*face1, 0));
@@ -549,7 +549,7 @@
   nackHeader.setReason(lp::NackReason::CONGESTION);
 
   // don't send Nack if there's no in-record
-  auto interest1 = makeInterest("/fM5IVEtC", false, nullopt, 719);
+  auto interest1 = makeInterest("/fM5IVEtC", false, std::nullopt, 719);
   auto pit1 = pit.insert(*interest1).first;
   pit1->insertOrUpdateInRecord(*face1, *interest1);
 
@@ -558,10 +558,10 @@
   BOOST_CHECK_EQUAL(face2->sentNacks.size(), 0);
 
   // send Nack with correct Nonce
-  auto interest2a = makeInterest("/Vi8tRm9MG3", false, nullopt, 152);
+  auto interest2a = makeInterest("/Vi8tRm9MG3", false, std::nullopt, 152);
   auto pit2 = pit.insert(*interest2a).first;
   pit2->insertOrUpdateInRecord(*face1, *interest2a);
-  auto interest2b = makeInterest("/Vi8tRm9MG3", false, nullopt, 808);
+  auto interest2b = makeInterest("/Vi8tRm9MG3", false, std::nullopt, 808);
   pit2->insertOrUpdateInRecord(*face2, *interest2b);
   face1->sentNacks.clear();
   face2->sentNacks.clear();
@@ -588,7 +588,7 @@
   BOOST_CHECK(inRecord2b == pit2->in_end());
 
   // don't send Nack to multi-access face
-  auto interest2c = makeInterest("/Vi8tRm9MG3", false, nullopt, 228);
+  auto interest2c = makeInterest("/Vi8tRm9MG3", false, std::nullopt, 228);
   pit2->insertOrUpdateInRecord(*face3, *interest2c);
 
   face3->sentNacks.clear();
@@ -596,7 +596,7 @@
   BOOST_CHECK_EQUAL(face3->sentNacks.size(), 0);
 
   // don't send Nack to face with invalid ID
-  auto interest1b = makeInterest("/fM5IVEtC", false, nullopt, 553);
+  auto interest1b = makeInterest("/fM5IVEtC", false, std::nullopt, 553);
   pit1->insertOrUpdateInRecord(*face4, *interest1b);
 
   face4->sentNacks.clear();
@@ -620,19 +620,19 @@
 
   // receive Interest on face1
   face1->sentNacks.clear();
-  auto interest1a = makeInterest("/zT4XwK0Hnx/28JBUvbEzc", false, nullopt, 732);
+  auto interest1a = makeInterest("/zT4XwK0Hnx/28JBUvbEzc", false, std::nullopt, 732);
   face1->receiveInterest(*interest1a, 0);
   BOOST_CHECK(face1->sentNacks.empty());
 
   // receive Interest with duplicate Nonce on face1: legit retransmission
   face1->sentNacks.clear();
-  auto interest1b = makeInterest("/zT4XwK0Hnx/28JBUvbEzc", false, nullopt, 732);
+  auto interest1b = makeInterest("/zT4XwK0Hnx/28JBUvbEzc", false, std::nullopt, 732);
   face1->receiveInterest(*interest1b, 0);
   BOOST_CHECK(face1->sentNacks.empty());
 
   // receive Interest with duplicate Nonce on face2
   face2->sentNacks.clear();
-  auto interest2a = makeInterest("/zT4XwK0Hnx/28JBUvbEzc", false, nullopt, 732);
+  auto interest2a = makeInterest("/zT4XwK0Hnx/28JBUvbEzc", false, std::nullopt, 732);
   face2->receiveInterest(*interest2a, 0);
   BOOST_REQUIRE_EQUAL(face2->sentNacks.size(), 1);
   BOOST_CHECK_EQUAL(face2->sentNacks.back().getInterest().wireEncode(), interest2a->wireEncode());
@@ -640,13 +640,13 @@
 
   // receive Interest with new Nonce on face2
   face2->sentNacks.clear();
-  auto interest2b = makeInterest("/zT4XwK0Hnx/28JBUvbEzc", false, nullopt, 944);
+  auto interest2b = makeInterest("/zT4XwK0Hnx/28JBUvbEzc", false, std::nullopt, 944);
   face2->receiveInterest(*interest2b, 0);
   BOOST_CHECK(face2->sentNacks.empty());
 
   // receive Interest with duplicate Nonce on face3, don't send Nack to multi-access face
   face3->sentNacks.clear();
-  auto interest3a = makeInterest("/zT4XwK0Hnx/28JBUvbEzc", false, nullopt, 732);
+  auto interest3a = makeInterest("/zT4XwK0Hnx/28JBUvbEzc", false, std::nullopt, 732);
   face3->receiveInterest(*interest3a, 0);
   BOOST_CHECK(face3->sentNacks.empty());
 }
diff --git a/tests/daemon/fw/strategy-nack-return.t.cpp b/tests/daemon/fw/strategy-nack-return.t.cpp
index 73db46c..a091fb5 100644
--- a/tests/daemon/fw/strategy-nack-return.t.cpp
+++ b/tests/daemon/fw/strategy-nack-return.t.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,
@@ -97,8 +97,8 @@
   this->fib.addOrUpdateNextHop(fibEntry, *this->face4, 20);
   this->fib.addOrUpdateNextHop(fibEntry, *this->face5, 30);
 
-  auto interest1 = makeInterest("/McQYjMbm", false, nullopt, 992);
-  auto interest2 = makeInterest("/McQYjMbm", false, nullopt, 114);
+  auto interest1 = makeInterest("/McQYjMbm", false, std::nullopt, 992);
+  auto interest2 = makeInterest("/McQYjMbm", false, std::nullopt, 114);
   shared_ptr<pit::Entry> pitEntry = this->pit.insert(*interest1).first;
   pitEntry->insertOrUpdateInRecord(*this->face1, *interest1);
   pitEntry->insertOrUpdateInRecord(*this->face2, *interest2);
@@ -136,7 +136,7 @@
   this->fib.addOrUpdateNextHop(fibEntry, *this->face4, 20);
   this->fib.addOrUpdateNextHop(fibEntry, *this->face5, 30);
 
-  auto interest1 = makeInterest("/aS9FAyUV19", false, nullopt, 286);
+  auto interest1 = makeInterest("/aS9FAyUV19", false, std::nullopt, 286);
   shared_ptr<pit::Entry> pitEntry = this->pit.insert(*interest1).first;
   pitEntry->insertOrUpdateInRecord(*this->face1, *interest1);
   pitEntry->insertOrUpdateOutRecord(*this->face3, *interest1);
@@ -178,7 +178,7 @@
   pitEntry->insertOrUpdateOutRecord(*this->face3, *interest1);
 
   this->advanceClocks(300_ms);
-  auto interest2 = makeInterest("/sIYw0TXWDj", false, nullopt, 223);
+  auto interest2 = makeInterest("/sIYw0TXWDj", false, std::nullopt, 223);
   pitEntry->insertOrUpdateInRecord(*this->face1, *interest2);
   pitEntry->insertOrUpdateOutRecord(*this->face4, *interest2);
 
@@ -325,7 +325,7 @@
   fib.addOrUpdateNextHop(fibEntry, *face4, 20);
   fib.addOrUpdateNextHop(fibEntry, *face5, 30);
 
-  auto interest1 = makeInterest("/F6sEwB24I", false, nullopt, 282);
+  auto interest1 = makeInterest("/F6sEwB24I", false, std::nullopt, 282);
   shared_ptr<pit::Entry> pitEntry = pit.insert(*interest1).first;
   pitEntry->insertOrUpdateInRecord(*face1, *interest1);
   pitEntry->insertOrUpdateOutRecord(*face3, *interest1);
diff --git a/tests/daemon/fw/strategy-scope-control.t.cpp b/tests/daemon/fw/strategy-scope-control.t.cpp
index 6fd052e..86e9540 100644
--- a/tests/daemon/fw/strategy-scope-control.t.cpp
+++ b/tests/daemon/fw/strategy-scope-control.t.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,
@@ -229,7 +229,7 @@
   this->fib.addOrUpdateNextHop(*fibEntry, *this->localFace4, 10);
   this->fib.addOrUpdateNextHop(*fibEntry, *this->nonLocalFace2, 20);
 
-  auto interest = makeInterest("/localhost/A/1", false, nullopt, 1460);
+  auto interest = makeInterest("/localhost/A/1", false, std::nullopt, 1460);
   shared_ptr<pit::Entry> pitEntry = this->pit.insert(*interest).first;
   pitEntry->insertOrUpdateInRecord(*this->localFace3, *interest);
   lp::Nack nack = makeNack(*interest, lp::NackReason::NO_ROUTE);
@@ -254,7 +254,7 @@
   this->fib.addOrUpdateNextHop(*fibEntry, *this->localFace4, 10);
   this->fib.addOrUpdateNextHop(*fibEntry, *this->nonLocalFace2, 20);
 
-  auto interest = makeInterest("/localhop/A/1", false, nullopt, 1377);
+  auto interest = makeInterest("/localhop/A/1", false, std::nullopt, 1377);
   shared_ptr<pit::Entry> pitEntry = this->pit.insert(*interest).first;
   pitEntry->insertOrUpdateInRecord(*this->nonLocalFace1, *interest);
   lp::Nack nack = makeNack(*interest, lp::NackReason::NO_ROUTE);
diff --git a/tests/daemon/mgmt/face-manager-update-face.t.cpp b/tests/daemon/mgmt/face-manager-update-face.t.cpp
index 7b3859f..89031fd 100644
--- a/tests/daemon/mgmt/face-manager-update-face.t.cpp
+++ b/tests/daemon/mgmt/face-manager-update-face.t.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,
@@ -54,8 +54,8 @@
   void
   createFace(const std::string& uri = "tcp4://127.0.0.1:26363",
              ndn::nfd::FacePersistency persistency = ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
-             optional<time::nanoseconds> baseCongestionMarkingInterval = nullopt,
-             optional<uint64_t> defaultCongestionThreshold = nullopt,
+             std::optional<time::nanoseconds> baseCongestionMarkingInterval = std::nullopt,
+             std::optional<uint64_t> defaultCongestionThreshold = std::nullopt,
              bool enableLocalFields = false,
              bool enableReliability = false,
              boost::logic::tribool enableCongestionMarking = boost::logic::indeterminate)
diff --git a/tests/daemon/mgmt/fib-manager.t.cpp b/tests/daemon/mgmt/fib-manager.t.cpp
index 048f76d..6131670 100644
--- a/tests/daemon/mgmt/fib-manager.t.cpp
+++ b/tests/daemon/mgmt/fib-manager.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,
@@ -95,9 +95,9 @@
    */
   CheckNextHopResult
   checkNextHop(const Name& prefix,
-               optional<size_t> expectedNNextHops = nullopt,
-               optional<FaceId> faceId = nullopt,
-               optional<uint64_t> expectedCost = nullopt) const
+               std::optional<size_t> expectedNNextHops = std::nullopt,
+               std::optional<FaceId> faceId = std::nullopt,
+               std::optional<uint64_t> expectedCost = std::nullopt) const
   {
     const fib::Entry* entry = m_fib.findExactMatch(prefix);
     if (entry == nullptr) {
@@ -128,7 +128,7 @@
   FibManager m_manager;
 };
 
-std::ostream&
+static std::ostream&
 operator<<(std::ostream& os, FibManagerFixture::CheckNextHopResult result)
 {
   switch (result) {
@@ -163,7 +163,8 @@
                     CheckResponseResult::OK);
 
   // double check that the next hop was not added
-  BOOST_CHECK_EQUAL(checkNextHop("/hello", nullopt, nullopt, 101), CheckNextHopResult::NO_FIB_ENTRY);
+  BOOST_CHECK_EQUAL(checkNextHop("/hello", std::nullopt, std::nullopt, 101),
+                    CheckNextHopResult::NO_FIB_ENTRY);
 }
 
 BOOST_AUTO_TEST_CASE(NameTooLong)
@@ -388,12 +389,12 @@
   testRemoveNextHop(makeParameters("/hello", face2 + 100));
   BOOST_REQUIRE_EQUAL(m_responses.size(), 1); // face does not exist
   BOOST_CHECK_EQUAL(checkResponse(0, expectedName, expectedResponse), CheckResponseResult::OK);
-  BOOST_CHECK_EQUAL(checkNextHop("/hello", nullopt, face2 + 100), CheckNextHopResult::NO_NEXTHOP);
+  BOOST_CHECK_EQUAL(checkNextHop("/hello", std::nullopt, face2 + 100), CheckNextHopResult::NO_NEXTHOP);
 
   testRemoveNextHop(makeParameters("/hello", face2));
   BOOST_REQUIRE_EQUAL(m_responses.size(), 1); // record does not exist
   BOOST_CHECK_EQUAL(checkResponse(0, expectedName, expectedResponse), CheckResponseResult::OK);
-  BOOST_CHECK_EQUAL(checkNextHop("/hello", nullopt, face2), CheckNextHopResult::NO_NEXTHOP);
+  BOOST_CHECK_EQUAL(checkNextHop("/hello", std::nullopt, face2), CheckNextHopResult::NO_NEXTHOP);
 }
 
 BOOST_AUTO_TEST_SUITE_END() // RemoveNextHop
diff --git a/tests/daemon/mgmt/rib-manager-sl-announce.t.cpp b/tests/daemon/mgmt/rib-manager-sl-announce.t.cpp
index 597bad4..4d15659 100644
--- a/tests/daemon/mgmt/rib-manager-sl-announce.t.cpp
+++ b/tests/daemon/mgmt/rib-manager-sl-announce.t.cpp
@@ -91,7 +91,7 @@
   SlAnnounceResult
   slAnnounceSync(const ndn::PrefixAnnouncement& pa, uint64_t faceId, time::milliseconds maxLifetime)
   {
-    optional<SlAnnounceResult> result;
+    std::optional<SlAnnounceResult> result;
     manager->slAnnounce(pa, faceId, maxLifetime,
       [&] (RibManager::SlAnnounceResult res) {
         BOOST_CHECK(!result);
@@ -108,7 +108,7 @@
   SlAnnounceResult
   slRenewSync(const Name& name, uint64_t faceId, time::milliseconds maxLifetime)
   {
-    optional<SlAnnounceResult> result;
+    std::optional<SlAnnounceResult> result;
     manager->slRenew(name, faceId, maxLifetime,
       [&] (RibManager::SlAnnounceResult res) {
         BOOST_CHECK(!result);
@@ -122,19 +122,19 @@
 
   /** \brief Invoke manager->slFindAnn and wait for result.
    */
-  optional<ndn::PrefixAnnouncement>
+  std::optional<ndn::PrefixAnnouncement>
   slFindAnnSync(const Name& name)
   {
-    optional<optional<ndn::PrefixAnnouncement>> result;
+    std::optional<std::optional<ndn::PrefixAnnouncement>> result;
     manager->slFindAnn(name,
-      [&] (optional<ndn::PrefixAnnouncement> found) {
+      [&] (std::optional<ndn::PrefixAnnouncement> found) {
         BOOST_CHECK(!result);
         result = found;
       });
 
     g_io.poll();
     BOOST_CHECK(result);
-    return result.value_or(nullopt);
+    return result.value_or(std::nullopt);
   }
 
   /** \brief Lookup a route with PREFIXANN origin.
diff --git a/tests/daemon/mgmt/rib-manager.t.cpp b/tests/daemon/mgmt/rib-manager.t.cpp
index d23eb70..682eb30 100644
--- a/tests/daemon/mgmt/rib-manager.t.cpp
+++ b/tests/daemon/mgmt/rib-manager.t.cpp
@@ -448,7 +448,7 @@
     rib::Route route;
     route.faceId = ++faceId;
     route.cost = route.faceId * 10;
-    route.expires = nullopt;
+    route.expires = std::nullopt;
     return route;
   };
 
diff --git a/tests/daemon/rib/readvertise/client-to-nlsr-readvertise-policy.t.cpp b/tests/daemon/rib/readvertise/client-to-nlsr-readvertise-policy.t.cpp
index 6b67702..b804725 100644
--- a/tests/daemon/rib/readvertise/client-to-nlsr-readvertise-policy.t.cpp
+++ b/tests/daemon/rib/readvertise/client-to-nlsr-readvertise-policy.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,
@@ -47,7 +47,7 @@
   RibRouteRef rrr{entry, routeIt};
 
   ClientToNlsrReadvertisePolicy policy;
-  optional<ReadvertiseAction> action = policy.handleNewRoute(rrr);
+  std::optional<ReadvertiseAction> action = policy.handleNewRoute(rrr);
 
   BOOST_REQUIRE(action);
   BOOST_CHECK_EQUAL(action->prefix, "/test/A");
@@ -64,7 +64,7 @@
   RibRouteRef rrr{entry, routeIt};
 
   ClientToNlsrReadvertisePolicy policy;
-  optional<ReadvertiseAction> action = policy.handleNewRoute(rrr);
+  std::optional<ReadvertiseAction> action = policy.handleNewRoute(rrr);
 
   BOOST_CHECK(!action);
 }
diff --git a/tests/daemon/rib/readvertise/host-to-gateway-readvertise-policy.t.cpp b/tests/daemon/rib/readvertise/host-to-gateway-readvertise-policy.t.cpp
index c0d088a..c3682dd 100644
--- a/tests/daemon/rib/readvertise/host-to-gateway-readvertise-policy.t.cpp
+++ b/tests/daemon/rib/readvertise/host-to-gateway-readvertise-policy.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,
@@ -65,7 +65,7 @@
   BOOST_REQUIRE(m_keyChain.createIdentity("/A/B"));
   BOOST_REQUIRE(m_keyChain.createIdentity("/C/nrd"));
 
-  auto test = [this] (Name routeName, optional<ReadvertiseAction> expectedAction) {
+  auto test = [this] (Name routeName, std::optional<ReadvertiseAction> expectedAction) {
     auto policy = makePolicy();
     auto action = policy->handleNewRoute(makeNewRoute(routeName));
 
@@ -79,7 +79,7 @@
     }
   };
 
-  test("/D/app", nullopt);
+  test("/D/app", std::nullopt);
   test("/A/B/app", ReadvertiseAction{"/A", ndn::security::signingByIdentity("/A")});
   test("/C/nrd", ReadvertiseAction{"/C", ndn::security::signingByIdentity("/C/nrd")});
 }
diff --git a/tests/daemon/rib/readvertise/readvertise.t.cpp b/tests/daemon/rib/readvertise/readvertise.t.cpp
index 89ae410..8916c00 100644
--- a/tests/daemon/rib/readvertise/readvertise.t.cpp
+++ b/tests/daemon/rib/readvertise/readvertise.t.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,
@@ -43,7 +43,7 @@
 class DummyReadvertisePolicy : public ReadvertisePolicy
 {
 public:
-  optional<ReadvertiseAction>
+  std::optional<ReadvertiseAction>
   handleNewRoute(const RibRouteRef&) const override
   {
     return this->decision;
@@ -56,7 +56,7 @@
   }
 
 public:
-  optional<ReadvertiseAction> decision;
+  std::optional<ReadvertiseAction> decision;
 };
 
 class DummyReadvertiseDestination : public ReadvertiseDestination
@@ -196,7 +196,7 @@
 
 BOOST_AUTO_TEST_CASE(NoAdvertise)
 {
-  policy->decision = nullopt;
+  policy->decision = std::nullopt;
 
   this->insertRoute("/A/1", 1, ndn::nfd::ROUTE_ORIGIN_CLIENT);
   this->insertRoute("/A/2", 1, ndn::nfd::ROUTE_ORIGIN_CLIENT);
diff --git a/tests/daemon/rib/rib.t.cpp b/tests/daemon/rib/rib.t.cpp
index 7de4ebe..cc96e79 100644
--- a/tests/daemon/rib/rib.t.cpp
+++ b/tests/daemon/rib/rib.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,
@@ -300,17 +300,17 @@
 
   Route root = createRoute(1, 20);
   Name name1("/");
-  root.expires = nullopt;
+  root.expires = std::nullopt;
   rib.insert(name1, root);
 
   Route route1 = createRoute(2, 20);
   Name name2("/hello");
-  route1.expires = nullopt;
+  route1.expires = std::nullopt;
   rib.insert(name2, route1);
 
   Route route2 = createRoute(3, 20);
   Name name3("/hello/world");
-  route2.expires = nullopt;
+  route2.expires = std::nullopt;
   rib.insert(name3, route2);
 
   const std::string ribStr = std::string(R"TEXT(
diff --git a/tests/daemon/rib/route.t.cpp b/tests/daemon/rib/route.t.cpp
index b6e0ddb..011ce7e 100644
--- a/tests/daemon/rib/route.t.cpp
+++ b/tests/daemon/rib/route.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,
@@ -118,9 +118,9 @@
   BOOST_CHECK_NE(a, b);
   a.cost = 103;
 
-  b.expires = nullopt;
+  b.expires = std::nullopt;
   BOOST_CHECK_NE(a, b);
-  a.expires = nullopt;
+  a.expires = std::nullopt;
 
   BOOST_CHECK_EQUAL(a, b);
 }
@@ -149,7 +149,7 @@
                     "Route(faceid: 4980, origin: static, cost: 2312, flags: 0x1, expires in: "
                     "791214234 milliseconds)");
 
-  r.expires = nullopt;
+  r.expires = std::nullopt;
   BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(r),
                     "Route(faceid: 4980, origin: static, cost: 2312, flags: 0x1, never expires)");
 
diff --git a/tests/daemon/table/cs-fixture.hpp b/tests/daemon/table/cs-fixture.hpp
index 0dced9c..82fbb7e 100644
--- a/tests/daemon/table/cs-fixture.hpp
+++ b/tests/daemon/table/cs-fixture.hpp
@@ -92,12 +92,12 @@
   size_t
   erase(const Name& prefix, size_t limit)
   {
-    optional<size_t> nErased;
-    cs.erase(prefix, limit, [&] (size_t nErased1) { nErased = nErased1; });
+    std::optional<size_t> nErased;
+    cs.erase(prefix, limit, [&] (size_t n) { nErased = n; });
 
     // current Cs::erase implementation is synchronous
     // if callback was not invoked, bad_optional_access would occur
-    return *nErased;
+    return nErased.value();
   }
 
 protected:
diff --git a/tests/daemon/table/name-tree.t.cpp b/tests/daemon/table/name-tree.t.cpp
index d51474d..2649834 100644
--- a/tests/daemon/table/name-tree.t.cpp
+++ b/tests/daemon/table/name-tree.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,
@@ -28,6 +28,8 @@
 #include "tests/test-common.hpp"
 #include "tests/daemon/global-io-fixture.hpp"
 
+#include <unordered_set>
+
 namespace nfd {
 namespace name_tree {
 namespace tests {
diff --git a/tests/daemon/table/pit-entry.t.cpp b/tests/daemon/table/pit-entry.t.cpp
index d5b71fc..6f97a1c 100644
--- a/tests/daemon/table/pit-entry.t.cpp
+++ b/tests/daemon/table/pit-entry.t.cpp
@@ -51,7 +51,7 @@
   auto interest1 = makeInterest("/B");
   BOOST_CHECK_EQUAL(entry.canMatch(*interest1), false);
 
-  auto interest2 = makeInterest("/A", false, nullopt, 27956);
+  auto interest2 = makeInterest("/A", false, std::nullopt, 27956);
   BOOST_CHECK_EQUAL(entry.canMatch(*interest2), true);
 
   auto interest3 = makeInterest("/A", false, 6210_ms);
diff --git a/tests/daemon/table/pit.t.cpp b/tests/daemon/table/pit.t.cpp
index ca9ac3c..03438d4 100644
--- a/tests/daemon/table/pit.t.cpp
+++ b/tests/daemon/table/pit.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,
@@ -70,7 +70,7 @@
   bool isNew = false;
 
   // base
-  auto interestA = makeInterest(name1, false, nullopt, 2148);
+  auto interestA = makeInterest(name1, false, std::nullopt, 2148);
   std::tie(entry, isNew) = pit.insert(*interestA);
   BOOST_CHECK_EQUAL(isNew, true);
   BOOST_CHECK_EQUAL(pit.size(), 1);