build: switch to C++17
Change-Id: Ie68020a04b7e20b74778b6d0370544ded55c5e26
diff --git a/daemon/common/config-file.hpp b/daemon/common/config-file.hpp
index c58de29..39cc2ed 100644
--- a/daemon/common/config-file.hpp
+++ b/daemon/common/config-file.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,
@@ -105,9 +105,9 @@
static T
parseNumber(const ConfigSection& node, const std::string& key, const std::string& sectionName)
{
- static_assert(std::is_arithmetic<T>::value, "T must be an arithmetic type");
+ static_assert(std::is_arithmetic_v<T>);
- boost::optional<T> value = node.get_value_optional<T>();
+ auto value = node.get_value_optional<T>();
// Unsigned logic is workaround for https://redmine.named-data.net/issues/4489
if (value &&
(std::is_signed<T>() || node.get_value<std::string>().find("-") == std::string::npos)) {
@@ -132,7 +132,7 @@
static void
checkRange(T value, T min, T max, const std::string& key, const std::string& sectionName)
{
- static_assert(std::is_integral<T>::value, "T must be an integral type");
+ static_assert(std::is_integral_v<T>);
if (value < min || value > max) {
NDN_THROW(Error("Invalid value '" + to_string(value) + "' for option '" + key +
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 {
diff --git a/daemon/fw/access-strategy.hpp b/daemon/fw/access-strategy.hpp
index edcf63b..1aaa5ed 100644
--- a/daemon/fw/access-strategy.hpp
+++ b/daemon/fw/access-strategy.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,6 +31,8 @@
#include <ndn-cxx/util/rtt-estimator.hpp>
+#include <unordered_map>
+
namespace nfd {
namespace fw {
diff --git a/daemon/fw/asf-measurements.hpp b/daemon/fw/asf-measurements.hpp
index aede00b..a3eafc9 100644
--- a/daemon/fw/asf-measurements.hpp
+++ b/daemon/fw/asf-measurements.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,6 +31,8 @@
#include <ndn-cxx/util/rtt-estimator.hpp>
+#include <unordered_map>
+
namespace nfd {
namespace fw {
namespace asf {
diff --git a/daemon/fw/self-learning-strategy.cpp b/daemon/fw/self-learning-strategy.cpp
index 80630dc..89ca397 100644
--- a/daemon/fw/self-learning-strategy.cpp
+++ b/daemon/fw/self-learning-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,
@@ -193,7 +193,7 @@
runOnRibIoService([pitEntryWeak = weak_ptr<pit::Entry>{pitEntry}, inFaceId = inFace.getId(), data, this] {
rib::Service::get().getRibManager().slFindAnn(data.getName(),
- [pitEntryWeak, inFaceId, data, this] (optional<ndn::PrefixAnnouncement> paOpt) {
+ [pitEntryWeak, inFaceId, data, this] (std::optional<ndn::PrefixAnnouncement> paOpt) {
if (paOpt) {
runOnMainIoService([pitEntryWeak, inFaceId, data, pa = std::move(*paOpt), this] {
auto pitEntry = pitEntryWeak.lock();
diff --git a/daemon/fw/strategy.cpp b/daemon/fw/strategy.cpp
index fa948ee..1f7babc 100644
--- a/daemon/fw/strategy.cpp
+++ b/daemon/fw/strategy.cpp
@@ -31,6 +31,7 @@
#include <boost/range/adaptor/map.hpp>
#include <boost/range/algorithm/copy.hpp>
+#include <unordered_set>
namespace nfd {
namespace fw {
@@ -127,7 +128,7 @@
return {input.getPrefix(i + 1), input[i].toVersion(), input.getSubName(i + 1)};
}
}
- return {input, nullopt, PartialName()};
+ return {input, std::nullopt, PartialName()};
}
Name
diff --git a/daemon/fw/strategy.hpp b/daemon/fw/strategy.hpp
index 50c79dc..4e162bd 100644
--- a/daemon/fw/strategy.hpp
+++ b/daemon/fw/strategy.hpp
@@ -377,7 +377,7 @@
struct ParsedInstanceName
{
Name strategyName; ///< Strategy name without parameters
- optional<uint64_t> version; ///< The strategy version number, if present
+ std::optional<uint64_t> version; ///< The strategy version number, if present
PartialName parameters; ///< Parameter components, may be empty
};
@@ -445,7 +445,7 @@
// Note: only arithmetic types are supported by getOrDefault() for now
template<typename T>
- std::enable_if_t<std::is_signed<T>::value, T>
+ std::enable_if_t<std::is_signed_v<T>, T>
getOrDefault(const key_type& key, const T& defaultVal) const
{
auto it = find(key);
@@ -461,7 +461,7 @@
}
template<typename T>
- std::enable_if_t<std::is_unsigned<T>::value, T>
+ std::enable_if_t<std::is_unsigned_v<T>, T>
getOrDefault(const key_type& key, const T& defaultVal) const
{
auto it = find(key);
diff --git a/daemon/mgmt/command-authenticator.cpp b/daemon/mgmt/command-authenticator.cpp
index 7c3cb23..ebf7991 100644
--- a/daemon/mgmt/command-authenticator.cpp
+++ b/daemon/mgmt/command-authenticator.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,
@@ -51,12 +51,12 @@
/** \brief obtain signer from SignerTag attached to Interest, if available
*/
-static optional<std::string>
+static std::optional<std::string>
getSignerFromTag(const Interest& interest)
{
- shared_ptr<SignerTag> signerTag = interest.getTag<SignerTag>();
+ auto signerTag = interest.getTag<SignerTag>();
if (signerTag == nullptr) {
- return nullopt;
+ return std::nullopt;
}
else {
return signerTag->get().toUri();
diff --git a/daemon/mgmt/command-authenticator.hpp b/daemon/mgmt/command-authenticator.hpp
index 8d5158e..12c6c70 100644
--- a/daemon/mgmt/command-authenticator.hpp
+++ b/daemon/mgmt/command-authenticator.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,
@@ -31,6 +31,8 @@
#include <ndn-cxx/mgmt/dispatcher.hpp>
#include <ndn-cxx/security/validator.hpp>
+#include <unordered_map>
+
namespace nfd {
/** \brief Provides ControlCommand authorization according to NFD configuration file.
diff --git a/daemon/mgmt/face-manager.cpp b/daemon/mgmt/face-manager.cpp
index 1d38f43..839a6fb 100644
--- a/daemon/mgmt/face-manager.cpp
+++ b/daemon/mgmt/face-manager.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,
@@ -87,7 +87,7 @@
return;
}
- optional<FaceUri> localUri;
+ std::optional<FaceUri> localUri;
if (parameters.hasLocalUri()) {
localUri = FaceUri{};
diff --git a/daemon/mgmt/rib-manager.cpp b/daemon/mgmt/rib-manager.cpp
index 4e444bf..d66baea 100644
--- a/daemon/mgmt/rib-manager.cpp
+++ b/daemon/mgmt/rib-manager.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,
@@ -125,7 +125,7 @@
}
void
-RibManager::beginAddRoute(const Name& name, Route route, optional<time::nanoseconds> expires,
+RibManager::beginAddRoute(const Name& name, Route route, std::optional<time::nanoseconds> expires,
const std::function<void(RibUpdateResult)>& done)
{
if (expires) {
@@ -238,7 +238,7 @@
route.cost = parameters.getCost();
route.flags = parameters.getFlags();
- optional<time::nanoseconds> expires;
+ std::optional<time::nanoseconds> expires;
if (parameters.hasExpirationPeriod() &&
parameters.getExpirationPeriod() != time::milliseconds::max()) {
expires = time::duration_cast<time::nanoseconds>(parameters.getExpirationPeriod());
@@ -261,12 +261,11 @@
route.faceId = parameters.getFaceId();
route.origin = parameters.getOrigin();
- beginRemoveRoute(parameters.getName(), route, [] (RibUpdateResult) {});
+ beginRemoveRoute(parameters.getName(), route, [] (auto&&...) {});
}
void
-RibManager::listEntries(const Name&, const Interest& interest,
- ndn::mgmt::StatusDatasetContext& context)
+RibManager::listEntries(const Name&, const Interest&, ndn::mgmt::StatusDatasetContext& context)
{
auto now = time::steady_clock::now();
for (const auto& kv : m_rib) {
@@ -363,7 +362,7 @@
[=] (const Data&) {
Route route(pa, faceId);
route.expires = std::min(route.annExpires, time::steady_clock::now() + maxLifetime);
- beginAddRoute(pa.getAnnouncedName(), route, nullopt,
+ beginAddRoute(pa.getAnnouncedName(), route, std::nullopt,
[=] (RibUpdateResult ribRes) {
auto res = getSlAnnounceResultFromRibUpdateResult(ribRes);
NFD_LOG_INFO("slAnnounce " << pa.getAnnouncedName() << " " << faceId << ": " << res);
@@ -395,7 +394,7 @@
Route route = *oldRoute;
route.expires = std::min(route.annExpires, time::steady_clock::now() + maxLifetime);
- beginAddRoute(routeName, route, nullopt,
+ beginAddRoute(routeName, route, std::nullopt,
[=] (RibUpdateResult ribRes) {
auto res = getSlAnnounceResultFromRibUpdateResult(ribRes);
NFD_LOG_INFO("slRenew " << name << " " << faceId << ": " << res << " " << routeName);
@@ -415,7 +414,7 @@
entry = m_rib.findParent(name);
}
if (entry == nullptr) {
- return cb(nullopt);
+ return cb(std::nullopt);
}
auto pa = entry->getPrefixAnnouncement();
diff --git a/daemon/mgmt/rib-manager.hpp b/daemon/mgmt/rib-manager.hpp
index 98739f0..ac2a324 100644
--- a/daemon/mgmt/rib-manager.hpp
+++ b/daemon/mgmt/rib-manager.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,
@@ -99,7 +99,7 @@
};
using SlAnnounceCallback = std::function<void(SlAnnounceResult res)>;
- using SlFindAnnCallback = std::function<void(optional<ndn::PrefixAnnouncement>)>;
+ using SlFindAnnCallback = std::function<void(std::optional<ndn::PrefixAnnouncement>)>;
/** \brief Insert a route by prefix announcement from self-learning strategy.
* \param pa A prefix announcement. It must contain the Data.
@@ -176,7 +176,7 @@
* \param done completion callback
*/
void
- beginAddRoute(const Name& name, rib::Route route, optional<time::nanoseconds> expires,
+ beginAddRoute(const Name& name, rib::Route route, std::optional<time::nanoseconds> expires,
const std::function<void(RibUpdateResult)>& done);
/** \brief Start removing a route from RIB and FIB.
diff --git a/daemon/rib/readvertise/client-to-nlsr-readvertise-policy.cpp b/daemon/rib/readvertise/client-to-nlsr-readvertise-policy.cpp
index ca54132..7aff618 100644
--- a/daemon/rib/readvertise/client-to-nlsr-readvertise-policy.cpp
+++ b/daemon/rib/readvertise/client-to-nlsr-readvertise-policy.cpp
@@ -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,
@@ -28,14 +28,14 @@
namespace nfd {
namespace rib {
-optional<ReadvertiseAction>
+std::optional<ReadvertiseAction>
ClientToNlsrReadvertisePolicy::handleNewRoute(const RibRouteRef& ribRoute) const
{
if (ribRoute.route->origin == ndn::nfd::ROUTE_ORIGIN_CLIENT) {
return ReadvertiseAction{ribRoute.entry->getName(), ndn::security::SigningInfo()};
}
else {
- return nullopt;
+ return std::nullopt;
}
}
diff --git a/daemon/rib/readvertise/client-to-nlsr-readvertise-policy.hpp b/daemon/rib/readvertise/client-to-nlsr-readvertise-policy.hpp
index b1c5e29..c0d5837 100644
--- a/daemon/rib/readvertise/client-to-nlsr-readvertise-policy.hpp
+++ b/daemon/rib/readvertise/client-to-nlsr-readvertise-policy.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,
@@ -41,7 +41,7 @@
* If the route origin is "client" (typically from auto prefix propagation), readvertise it
* using the default signing identity.
*/
- optional<ReadvertiseAction>
+ std::optional<ReadvertiseAction>
handleNewRoute(const RibRouteRef& ribRoute) const override;
time::milliseconds
diff --git a/daemon/rib/readvertise/host-to-gateway-readvertise-policy.cpp b/daemon/rib/readvertise/host-to-gateway-readvertise-policy.cpp
index 9ee7985..89f11fd 100644
--- a/daemon/rib/readvertise/host-to-gateway-readvertise-policy.cpp
+++ b/daemon/rib/readvertise/host-to-gateway-readvertise-policy.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,13 +44,13 @@
m_refreshInterval = interval ? time::seconds(*interval) : DEFAULT_REFRESH_INTERVAL;
}
-optional<ReadvertiseAction>
+std::optional<ReadvertiseAction>
HostToGatewayReadvertisePolicy::handleNewRoute(const RibRouteRef& ribRoute) const
{
auto ribEntryName = ribRoute.entry->getName();
if (scope_prefix::LOCALHOST.isPrefixOf(ribEntryName) ||
ribEntryName == RibManager::LOCALHOP_TOP_PREFIX) {
- return nullopt;
+ return std::nullopt;
}
// find out the shortest identity whose name is a prefix of the RIB entry name
@@ -73,12 +73,10 @@
}
}
- if (isFound) {
- return ReadvertiseAction{prefixToAdvertise, ndn::security::signingByIdentity(signingIdentity)};
+ if (!isFound) {
+ return std::nullopt;
}
- else {
- return nullopt;
- }
+ return ReadvertiseAction{prefixToAdvertise, ndn::security::signingByIdentity(signingIdentity)};
}
time::milliseconds
diff --git a/daemon/rib/readvertise/host-to-gateway-readvertise-policy.hpp b/daemon/rib/readvertise/host-to-gateway-readvertise-policy.hpp
index 325fc80..ac2491d 100644
--- a/daemon/rib/readvertise/host-to-gateway-readvertise-policy.hpp
+++ b/daemon/rib/readvertise/host-to-gateway-readvertise-policy.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,
@@ -43,7 +43,7 @@
const ConfigSection& section);
public:
- optional<ReadvertiseAction>
+ std::optional<ReadvertiseAction>
handleNewRoute(const RibRouteRef& ribRoute) const override;
time::milliseconds
diff --git a/daemon/rib/readvertise/readvertise-policy.hpp b/daemon/rib/readvertise/readvertise-policy.hpp
index 99deccb..da22139 100644
--- a/daemon/rib/readvertise/readvertise-policy.hpp
+++ b/daemon/rib/readvertise/readvertise-policy.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,
@@ -51,7 +51,7 @@
/** \brief decide whether to readvertise a route, and what prefix to readvertise
*/
- virtual optional<ReadvertiseAction>
+ virtual std::optional<ReadvertiseAction>
handleNewRoute(const RibRouteRef& ribRoute) const = 0;
/** \return how often readvertisements made by this policy should be refreshed.
diff --git a/daemon/rib/readvertise/readvertise.cpp b/daemon/rib/readvertise/readvertise.cpp
index 2f16795..addad72 100644
--- a/daemon/rib/readvertise/readvertise.cpp
+++ b/daemon/rib/readvertise/readvertise.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,
@@ -67,7 +67,7 @@
void
Readvertise::afterAddRoute(const RibRouteRef& ribRoute)
{
- optional<ReadvertiseAction> action = m_policy->handleNewRoute(ribRoute);
+ std::optional<ReadvertiseAction> action = m_policy->handleNewRoute(ribRoute);
if (!action) {
NFD_LOG_DEBUG("add-route " << ribRoute.entry->getName() << '(' << ribRoute.route->faceId <<
',' << ribRoute.route->origin << ") not-readvertising");
diff --git a/daemon/rib/route.hpp b/daemon/rib/route.hpp
index 18df250..9b0bead 100644
--- a/daemon/rib/route.hpp
+++ b/daemon/rib/route.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,
@@ -82,13 +82,13 @@
ndn::nfd::RouteOrigin origin = ndn::nfd::ROUTE_ORIGIN_APP;
uint64_t cost = 0;
std::underlying_type_t<ndn::nfd::RouteFlags> flags = ndn::nfd::ROUTE_FLAGS_NONE;
- optional<time::steady_clock::time_point> expires;
+ std::optional<time::steady_clock::time_point> expires;
/** \brief The prefix announcement that caused the creation of this route.
*
* This is nullopt if this route is not created by a prefix announcement.
*/
- optional<ndn::PrefixAnnouncement> announcement;
+ std::optional<ndn::PrefixAnnouncement> announcement;
/** \brief Expiration time of the prefix announcement.
*
diff --git a/daemon/table/fib.hpp b/daemon/table/fib.hpp
index f5984aa..a4b688f 100644
--- a/daemon/table/fib.hpp
+++ b/daemon/table/fib.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,
@@ -122,8 +122,8 @@
removeNextHop(Entry& entry, const Face& face);
public: // enumeration
- typedef boost::transformed_range<name_tree::GetTableEntry<Entry>, const name_tree::Range> Range;
- typedef boost::range_iterator<Range>::type const_iterator;
+ using Range = boost::transformed_range<name_tree::GetTableEntry<Entry>, const name_tree::Range>;
+ using const_iterator = boost::range_iterator<Range>::type;
/** \return an iterator to the beginning
* \note The iteration order is implementation-defined.
diff --git a/daemon/table/name-tree-hashtable.cpp b/daemon/table/name-tree-hashtable.cpp
index 30e4ca3..fc17523 100644
--- a/daemon/table/name-tree-hashtable.cpp
+++ b/daemon/table/name-tree-hashtable.cpp
@@ -52,9 +52,10 @@
}
};
-/** \brief a type with compute static method to compute hash value from a raw buffer
+/**
+ * \brief A type with a `compute()` static method to compute the hash value from a raw buffer
*/
-using HashFunc = std::conditional<(sizeof(HashValue) > 4), Hash64, Hash32>::type;
+using HashFunc = std::conditional_t<(sizeof(HashValue) > 4), Hash64, Hash32>;
HashValue
computeHash(const Name& name, size_t prefixLen)
diff --git a/daemon/table/name-tree-hashtable.hpp b/daemon/table/name-tree-hashtable.hpp
index ec5caa0..2880984 100644
--- a/daemon/table/name-tree-hashtable.hpp
+++ b/daemon/table/name-tree-hashtable.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2017, 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,
@@ -124,19 +124,19 @@
/** \brief if hashtable has more than nBuckets*expandLoadFactor nodes, it will be expanded
*/
- float expandLoadFactor = 0.5;
+ float expandLoadFactor = 0.5f;
/** \brief when hashtable is expanded, its new size is nBuckets*expandFactor
*/
- float expandFactor = 2.0;
+ float expandFactor = 2.0f;
/** \brief if hashtable has less than nBuckets*shrinkLoadFactor nodes, it will be shrunk
*/
- float shrinkLoadFactor = 0.1;
+ float shrinkLoadFactor = 0.1f;
/** \brief when hashtable is shrunk, its new size is max(nBuckets*shrinkFactor, minSize)
*/
- float shrinkFactor = 0.5;
+ float shrinkFactor = 0.5f;
};
/** \brief a hashtable for fast exact name lookup
@@ -149,7 +149,7 @@
class Hashtable
{
public:
- typedef HashtableOptions Options;
+ using Options = HashtableOptions;
explicit
Hashtable(const Options& options);
diff --git a/daemon/table/strategy-choice.hpp b/daemon/table/strategy-choice.hpp
index 4b1548e..8c810a4 100644
--- a/daemon/table/strategy-choice.hpp
+++ b/daemon/table/strategy-choice.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,
@@ -106,7 +106,7 @@
Status m_status;
std::string m_exceptionMessage;
- friend class StrategyChoice;
+ friend StrategyChoice;
friend std::ostream& operator<<(std::ostream&, const InsertResult&);
};
@@ -152,8 +152,8 @@
findEffectiveStrategy(const measurements::Entry& measurementsEntry) const;
public: // enumeration
- typedef boost::transformed_range<name_tree::GetTableEntry<Entry>, const name_tree::Range> Range;
- typedef boost::range_iterator<Range>::type const_iterator;
+ using Range = boost::transformed_range<name_tree::GetTableEntry<Entry>, const name_tree::Range>;
+ using const_iterator = boost::range_iterator<Range>::type;
/** \return an iterator to the beginning
* \note Iteration order is implementation-defined.
diff --git a/daemon/table/strategy-info-host.hpp b/daemon/table/strategy-info-host.hpp
index 03f42f4..9204575 100644
--- a/daemon/table/strategy-info-host.hpp
+++ b/daemon/table/strategy-info-host.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,
@@ -28,6 +28,8 @@
#include "fw/strategy-info.hpp"
+#include <unordered_map>
+
namespace nfd {
/** \brief Base class for an entity onto which StrategyInfo items may be placed
@@ -43,8 +45,7 @@
T*
getStrategyInfo() const
{
- static_assert(std::is_base_of<fw::StrategyInfo, T>::value,
- "T must inherit from StrategyInfo");
+ static_assert(std::is_base_of_v<fw::StrategyInfo, T>);
auto it = m_items.find(T::getTypeId());
if (it == m_items.end()) {
@@ -62,8 +63,7 @@
std::pair<T*, bool>
insertStrategyInfo(A&&... args)
{
- static_assert(std::is_base_of<fw::StrategyInfo, T>::value,
- "T must inherit from StrategyInfo");
+ static_assert(std::is_base_of_v<fw::StrategyInfo, T>);
auto& item = m_items[T::getTypeId()];
bool isNew = item == nullptr;
@@ -81,8 +81,7 @@
size_t
eraseStrategyInfo()
{
- static_assert(std::is_base_of<fw::StrategyInfo, T>::value,
- "T must inherit from StrategyInfo");
+ static_assert(std::is_base_of_v<fw::StrategyInfo, T>);
return m_items.erase(T::getTypeId());
}