build: switch to C++17

Change-Id: Ie68020a04b7e20b74778b6d0370544ded55c5e26
diff --git a/daemon/face/ethernet-channel.cpp b/daemon/face/ethernet-channel.cpp
index 5f3f295..fae9af2 100644
--- a/daemon/face/ethernet-channel.cpp
+++ b/daemon/face/ethernet-channel.cpp
@@ -207,7 +207,7 @@
   auto transport = make_unique<UnicastEthernetTransport>(*m_localEndpoint, remoteEndpoint,
                                                          params.persistency, m_idleFaceTimeout);
   auto face = make_shared<Face>(std::move(linkService), std::move(transport));
-  face->setChannel(shared_from_this()); // use weak_from_this() in C++17
+  face->setChannel(weak_from_this());
 
   m_channelFaces[remoteEndpoint] = face;
   connectFaceClosedSignal(*face, [this, remoteEndpoint] {
diff --git a/daemon/face/face-common.hpp b/daemon/face/face-common.hpp
index e2a0572..0e6f0bb 100644
--- a/daemon/face/face-common.hpp
+++ b/daemon/face/face-common.hpp
@@ -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,
@@ -78,9 +78,9 @@
 struct FaceParams
 {
   ndn::nfd::FacePersistency persistency = ndn::nfd::FACE_PERSISTENCY_PERSISTENT;
-  optional<time::nanoseconds> baseCongestionMarkingInterval;
-  optional<uint64_t> defaultCongestionThreshold;
-  optional<ssize_t> mtu;
+  std::optional<time::nanoseconds> baseCongestionMarkingInterval;
+  std::optional<uint64_t> defaultCongestionThreshold;
+  std::optional<ssize_t> mtu;
   bool wantLocalFields = false;
   bool wantLpReliability = false;
   boost::logic::tribool wantCongestionMarking = boost::logic::indeterminate;
@@ -128,9 +128,7 @@
 // implementation detail
 #define NFD_LOG_FACE(level, msg) NFD_LOG_##level( \
   ::nfd::face::FaceLogHelper< \
-    typename std::remove_cv< \
-      typename std::remove_reference<decltype(*this)>::type \
-    >::type \
+    std::remove_cv_t<std::remove_reference_t<decltype(*this)>> \
   >(*this) \
   << msg)
 /** \endcond */
diff --git a/daemon/face/face-counters.hpp b/daemon/face/face-counters.hpp
index aed0ba4..bfe08bd 100644
--- a/daemon/face/face-counters.hpp
+++ b/daemon/face/face-counters.hpp
@@ -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,
@@ -50,7 +50,7 @@
    *  \throw std::bad_cast counters type mismatch
    */
   template<typename T>
-  typename std::enable_if<std::is_base_of<LinkService::Counters, T>::value, const T&>::type
+  std::enable_if_t<std::is_base_of_v<LinkService::Counters, T>, const T&>
   get() const
   {
     return dynamic_cast<const T&>(m_linkServiceCounters);
@@ -61,7 +61,7 @@
    *  \throw std::bad_cast counters type mismatch
    */
   template<typename T>
-  typename std::enable_if<std::is_base_of<Transport::Counters, T>::value, const T&>::type
+  std::enable_if_t<std::is_base_of_v<Transport::Counters, T>, const T&>
   get() const
   {
     return dynamic_cast<const T&>(m_transportCounters);
diff --git a/daemon/face/face.hpp b/daemon/face/face.hpp
index c91e78a..e9731ee 100644
--- a/daemon/face/face.hpp
+++ b/daemon/face/face.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,
@@ -36,9 +36,10 @@
 
 class Channel;
 
-/** \brief indicates the state of a face
+/**
+ * \brief Indicates the state of a face.
  */
-typedef TransportState FaceState;
+using FaceState = TransportState;
 
 /** \brief generalization of a network interface
  *
diff --git a/daemon/face/link-service.hpp b/daemon/face/link-service.hpp
index c623622..e62c1a3 100644
--- a/daemon/face/link-service.hpp
+++ b/daemon/face/link-service.hpp
@@ -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,
@@ -75,9 +75,10 @@
 class LinkService : protected virtual LinkServiceCounters, noncopyable
 {
 public:
-  /** \brief counters provided by LinkService
+  /**
+   * \brief %Counters provided by LinkService.
    */
-  typedef LinkServiceCounters Counters;
+  using Counters = LinkServiceCounters;
 
 public:
   LinkService();
@@ -250,8 +251,8 @@
 operator<<(std::ostream& os, const FaceLogHelper<LinkService>& flh);
 
 template<typename T>
-typename std::enable_if<std::is_base_of<LinkService, T>::value &&
-                        !std::is_same<LinkService, T>::value, std::ostream&>::type
+std::enable_if_t<std::is_base_of_v<LinkService, T> && !std::is_same_v<LinkService, T>,
+                 std::ostream&>
 operator<<(std::ostream& os, const FaceLogHelper<T>& flh)
 {
   return os << FaceLogHelper<LinkService>(flh.obj);
diff --git a/daemon/face/protocol-factory.hpp b/daemon/face/protocol-factory.hpp
index ed87de3..50023cc 100644
--- a/daemon/face/protocol-factory.hpp
+++ b/daemon/face/protocol-factory.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,
@@ -133,7 +133,7 @@
   struct CreateFaceRequest
   {
     FaceUri remoteUri;
-    optional<FaceUri> localUri;
+    std::optional<FaceUri> localUri;
     FaceParams params;
   };
 
diff --git a/daemon/face/tcp-channel.cpp b/daemon/face/tcp-channel.cpp
index 3382a91..2dd454d 100644
--- a/daemon/face/tcp-channel.cpp
+++ b/daemon/face/tcp-channel.cpp
@@ -138,7 +138,7 @@
                                           socket.remote_endpoint().address());
     auto transport = make_unique<TcpTransport>(std::move(socket), params.persistency, faceScope);
     face = make_shared<Face>(std::move(linkService), std::move(transport));
-    face->setChannel(shared_from_this()); // use weak_from_this() in C++17
+    face->setChannel(weak_from_this());
 
     m_channelFaces[remoteEndpoint] = face;
     connectFaceClosedSignal(*face, [this, remoteEndpoint] { m_channelFaces.erase(remoteEndpoint); });
diff --git a/daemon/face/tcp-channel.hpp b/daemon/face/tcp-channel.hpp
index bc6fba4..19c714c 100644
--- a/daemon/face/tcp-channel.hpp
+++ b/daemon/face/tcp-channel.hpp
@@ -31,7 +31,7 @@
 namespace nfd {
 
 namespace tcp {
-typedef boost::asio::ip::tcp::endpoint Endpoint;
+using Endpoint = boost::asio::ip::tcp::endpoint;
 } // namespace tcp
 
 namespace face {
diff --git a/daemon/face/transport.hpp b/daemon/face/transport.hpp
index 9fb9c03..9b84c99 100644
--- a/daemon/face/transport.hpp
+++ b/daemon/face/transport.hpp
@@ -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,
@@ -469,8 +469,8 @@
 operator<<(std::ostream& os, const FaceLogHelper<Transport>& flh);
 
 template<typename T>
-typename std::enable_if<std::is_base_of<Transport, T>::value &&
-                        !std::is_same<Transport, T>::value, std::ostream&>::type
+std::enable_if_t<std::is_base_of_v<Transport, T> && !std::is_same_v<Transport, T>,
+                 std::ostream&>
 operator<<(std::ostream& os, const FaceLogHelper<T>& flh)
 {
   return os << FaceLogHelper<Transport>(flh.obj);
diff --git a/daemon/face/udp-channel.cpp b/daemon/face/udp-channel.cpp
index bb836d2..8804f06 100644
--- a/daemon/face/udp-channel.cpp
+++ b/daemon/face/udp-channel.cpp
@@ -189,7 +189,7 @@
   auto transport = make_unique<UnicastUdpTransport>(std::move(socket), params.persistency,
                                                     m_idleFaceTimeout);
   auto face = make_shared<Face>(std::move(linkService), std::move(transport));
-  face->setChannel(shared_from_this()); // use weak_from_this() in C++17
+  face->setChannel(weak_from_this());
 
   m_channelFaces[remoteEndpoint] = face;
   connectFaceClosedSignal(*face, [this, remoteEndpoint] { m_channelFaces.erase(remoteEndpoint); });
diff --git a/daemon/face/udp-factory.cpp b/daemon/face/udp-factory.cpp
index 8f7f77c..9f43ad1 100644
--- a/daemon/face/udp-factory.cpp
+++ b/daemon/face/udp-factory.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,
@@ -382,7 +382,7 @@
   return face;
 }
 
-static optional<ip::address>
+static std::optional<ip::address>
 pickAddress(const net::NetworkInterface& netif, net::AddressFamily af)
 {
   for (const auto& na : netif.getNetworkAddresses()) {
@@ -391,7 +391,7 @@
       return na.getIp();
     }
   }
-  return nullopt;
+  return std::nullopt;
 }
 
 std::vector<shared_ptr<Face>>
diff --git a/daemon/face/unix-stream-channel.cpp b/daemon/face/unix-stream-channel.cpp
index 760a264..7fb828b 100644
--- a/daemon/face/unix-stream-channel.cpp
+++ b/daemon/face/unix-stream-channel.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,
@@ -137,7 +137,7 @@
   auto linkService = make_unique<GenericLinkService>(options);
   auto transport = make_unique<UnixStreamTransport>(std::move(m_socket));
   auto face = make_shared<Face>(std::move(linkService), std::move(transport));
-  face->setChannel(shared_from_this()); // use weak_from_this() in C++17
+  face->setChannel(weak_from_this());
 
   ++m_size;
   connectFaceClosedSignal(*face, [this] { --m_size; });
diff --git a/daemon/face/unix-stream-channel.hpp b/daemon/face/unix-stream-channel.hpp
index 1faffa8..c65f784 100644
--- a/daemon/face/unix-stream-channel.hpp
+++ b/daemon/face/unix-stream-channel.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,
@@ -31,7 +31,7 @@
 namespace nfd {
 
 namespace unix_stream {
-typedef boost::asio::local::stream_protocol::endpoint Endpoint;
+using Endpoint = boost::asio::local::stream_protocol::endpoint;
 } // namespace unix_stream
 
 namespace face {
@@ -51,11 +51,7 @@
   class Error : public std::runtime_error
   {
   public:
-    explicit
-    Error(const std::string& what)
-      : std::runtime_error(what)
-    {
-    }
+    using std::runtime_error::runtime_error;
   };
 
   /**
diff --git a/daemon/face/unix-stream-transport.cpp b/daemon/face/unix-stream-transport.cpp
index 483a138..a051ca9 100644
--- a/daemon/face/unix-stream-transport.cpp
+++ b/daemon/face/unix-stream-transport.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,
@@ -34,7 +34,7 @@
   : StreamTransport(std::move(socket))
 {
   static_assert(
-    std::is_same<std::remove_cv<protocol::socket::native_handle_type>::type, int>::value,
+    std::is_same_v<std::remove_cv_t<protocol::socket::native_handle_type>, int>,
     "The native handle type for UnixStreamTransport sockets must be 'int'"
   );
 
diff --git a/daemon/face/websocket-channel.cpp b/daemon/face/websocket-channel.cpp
index 957c9ad..2ee41cd 100644
--- a/daemon/face/websocket-channel.cpp
+++ b/daemon/face/websocket-channel.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,
@@ -126,7 +126,7 @@
   auto linkService = make_unique<GenericLinkService>();
   auto transport = make_unique<WebSocketTransport>(hdl, m_server, m_pingInterval);
   auto face = make_shared<Face>(std::move(linkService), std::move(transport));
-  face->setChannel(shared_from_this()); // use weak_from_this() in C++17
+  face->setChannel(weak_from_this());
 
   BOOST_ASSERT(m_channelFaces.count(hdl) == 0);
   m_channelFaces[hdl] = face;
diff --git a/daemon/face/websocket-channel.hpp b/daemon/face/websocket-channel.hpp
index 1729841..52bf20f 100644
--- a/daemon/face/websocket-channel.hpp
+++ b/daemon/face/websocket-channel.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,
@@ -32,7 +32,7 @@
 namespace nfd {
 
 namespace websocket {
-typedef boost::asio::ip::tcp::endpoint Endpoint;
+using Endpoint = boost::asio::ip::tcp::endpoint;
 } // namespace websocket
 
 namespace face {