Improve and simplify code with modern C++ features
Change-Id: I83bf5513c2a1f90ba5a59e93c473306864b27d94
diff --git a/core/common.hpp b/core/common.hpp
index b0fc450..2678a17 100644
--- a/core/common.hpp
+++ b/core/common.hpp
@@ -91,8 +91,8 @@
using std::const_pointer_cast;
using std::bind;
-using std::cref;
-using std::ref;
+
+using namespace std::string_literals;
using ndn::optional;
using ndn::nullopt;
diff --git a/core/manager-base.hpp b/core/manager-base.hpp
index cddb7c1..a19ccb2 100644
--- a/core/manager-base.hpp
+++ b/core/manager-base.hpp
@@ -161,7 +161,7 @@
m_dispatcher.addControlCommand<ControlParameters>(
makeRelPrefix(verb),
makeAuthorization(verb),
- bind(&ManagerBase::validateParameters, cref(*command), _1),
+ bind(&ManagerBase::validateParameters, std::cref(*command), _1),
bind(&ManagerBase::handleCommand, command, handler, _1, _2, _3, _4));
}
diff --git a/core/network-predicate.cpp b/core/network-predicate.cpp
index 5755f32..d10a5e3 100644
--- a/core/network-predicate.cpp
+++ b/core/network-predicate.cpp
@@ -193,8 +193,8 @@
bool
NetworkInterfacePredicate::operator()(const ndn::net::NetworkInterface& netif) const
{
- return std::any_of(m_whitelist.begin(), m_whitelist.end(), bind(&doesNetifMatchRule, cref(netif), _1)) &&
- std::none_of(m_blacklist.begin(), m_blacklist.end(), bind(&doesNetifMatchRule, cref(netif), _1));
+ return std::any_of(m_whitelist.begin(), m_whitelist.end(), bind(&doesNetifMatchRule, std::cref(netif), _1)) &&
+ std::none_of(m_blacklist.begin(), m_blacklist.end(), bind(&doesNetifMatchRule, std::cref(netif), _1));
}
static bool
@@ -214,8 +214,8 @@
bool
IpAddressPredicate::operator()(const boost::asio::ip::address& address) const
{
- return std::any_of(m_whitelist.begin(), m_whitelist.end(), bind(&doesAddressMatchRule, cref(address), _1)) &&
- std::none_of(m_blacklist.begin(), m_blacklist.end(), bind(&doesAddressMatchRule, cref(address), _1));
+ return std::any_of(m_whitelist.begin(), m_whitelist.end(), bind(&doesAddressMatchRule, std::cref(address), _1)) &&
+ std::none_of(m_blacklist.begin(), m_blacklist.end(), bind(&doesAddressMatchRule, std::cref(address), _1));
}
} // namespace nfd
diff --git a/core/rtt-estimator.hpp b/core/rtt-estimator.hpp
index 2b93880..e8a5eb9 100644
--- a/core/rtt-estimator.hpp
+++ b/core/rtt-estimator.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-2018, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -33,7 +33,7 @@
/**
* \brief implements the Mean-Deviation RTT estimator
*
- * reference: ns3::RttMeanDeviation
+ * \sa ns3::RttMeanDeviation
*
* This RttEstimator algorithm is designed for TCP, which is a continuous stream.
* NDN Interest-Data traffic is not always a continuous stream,
@@ -43,18 +43,18 @@
class RttEstimator
{
public:
- typedef time::microseconds Duration;
-
- static Duration
- getInitialRtt(void)
- {
- return time::seconds(1);
- }
+ using Duration = time::microseconds;
RttEstimator(uint16_t maxMultiplier = 16,
- Duration minRto = time::milliseconds(1),
+ Duration minRto = 1_ms,
double gain = 0.1);
+ static Duration
+ getInitialRtt()
+ {
+ return 1_s;
+ }
+
void
addMeasurement(Duration measure);