src: Remove unnecessary uses of boost::cref in make_shared and replace boost::cref/boost::ref with just cref/ref
In some cases, due to argument-dependent lookup, it is necessary to use
ndn::ref, instead of just ref.
Change-Id: I682180a007609535855f77511b49622154ad4f11
Refs: #1591
diff --git a/daemon/face/ethernet-factory.cpp b/daemon/face/ethernet-factory.cpp
index 6809e6c..0408f03 100644
--- a/daemon/face/ethernet-factory.cpp
+++ b/daemon/face/ethernet-factory.cpp
@@ -47,11 +47,9 @@
return face;
shared_ptr<boost::asio::posix::stream_descriptor> socket =
- make_shared<boost::asio::posix::stream_descriptor>(boost::ref(getGlobalIoService()));
+ make_shared<boost::asio::posix::stream_descriptor>(ref(getGlobalIoService()));
- face = make_shared<EthernetFace>(boost::cref(socket),
- boost::cref(interface),
- boost::cref(address));
+ face = make_shared<EthernetFace>(socket, interface, address);
face->onFail += bind(&EthernetFactory::afterFaceFailed,
this, name, address);
m_multicastFaces[std::make_pair(name, address)] = face;
diff --git a/daemon/face/face.cpp b/daemon/face/face.cpp
index 46dbcf6..75600b4 100644
--- a/daemon/face/face.cpp
+++ b/daemon/face/face.cpp
@@ -40,10 +40,10 @@
, m_localUri(localUri)
, m_isOnDemand(false)
{
- onReceiveInterest += bind(&increaseCounter, boost::ref(m_counters.getNInInterests()));
- onReceiveData += bind(&increaseCounter, boost::ref(m_counters.getNInDatas()));
- onSendInterest += bind(&increaseCounter, boost::ref(m_counters.getNOutInterests()));
- onSendData += bind(&increaseCounter, boost::ref(m_counters.getNOutDatas()));
+ onReceiveInterest += bind(&increaseCounter, ref(m_counters.getNInInterests()));
+ onReceiveData += bind(&increaseCounter, ref(m_counters.getNInDatas()));
+ onSendInterest += bind(&increaseCounter, ref(m_counters.getNOutInterests()));
+ onSendData += bind(&increaseCounter, ref(m_counters.getNOutDatas()));
}
Face::~Face()
diff --git a/daemon/face/tcp-channel.cpp b/daemon/face/tcp-channel.cpp
index 708f36b..cd2fb4f 100644
--- a/daemon/face/tcp-channel.cpp
+++ b/daemon/face/tcp-channel.cpp
@@ -48,7 +48,7 @@
const ConnectFailedCallback& onAcceptFailed,
int backlog/* = tcp::acceptor::max_connections*/)
{
- m_acceptor = make_shared<ip::tcp::acceptor>(boost::ref(getGlobalIoService()));
+ m_acceptor = make_shared<ip::tcp::acceptor>(ref(getGlobalIoService()));
m_acceptor->open(m_localEndpoint.protocol());
m_acceptor->set_option(ip::tcp::acceptor::reuse_address(true));
if (m_localEndpoint.address().is_v6())
@@ -59,7 +59,7 @@
m_acceptor->listen(backlog);
shared_ptr<ip::tcp::socket> clientSocket =
- make_shared<ip::tcp::socket>(boost::ref(getGlobalIoService()));
+ make_shared<ip::tcp::socket>(ref(getGlobalIoService()));
m_acceptor->async_accept(*clientSocket,
bind(&TcpChannel::handleSuccessfulAccept, this, _1,
clientSocket,
@@ -81,10 +81,10 @@
}
shared_ptr<ip::tcp::socket> clientSocket =
- make_shared<ip::tcp::socket>(boost::ref(getGlobalIoService()));
+ make_shared<ip::tcp::socket>(ref(getGlobalIoService()));
shared_ptr<ndn::monotonic_deadline_timer> connectTimeoutTimer =
- make_shared<ndn::monotonic_deadline_timer>(boost::ref(getGlobalIoService()));
+ make_shared<ndn::monotonic_deadline_timer>(ref(getGlobalIoService()));
clientSocket->async_connect(remoteEndpoint,
bind(&TcpChannel::handleSuccessfulConnect, this, _1,
@@ -104,14 +104,14 @@
const time::seconds& timeout/* = time::seconds(4)*/)
{
shared_ptr<ip::tcp::socket> clientSocket =
- make_shared<ip::tcp::socket>(boost::ref(getGlobalIoService()));
+ make_shared<ip::tcp::socket>(ref(getGlobalIoService()));
shared_ptr<ndn::monotonic_deadline_timer> connectTimeoutTimer =
- make_shared<ndn::monotonic_deadline_timer>(boost::ref(getGlobalIoService()));
+ make_shared<ndn::monotonic_deadline_timer>(ref(getGlobalIoService()));
ip::tcp::resolver::query query(remoteHost, remotePort);
shared_ptr<ip::tcp::resolver> resolver =
- make_shared<ip::tcp::resolver>(boost::ref(getGlobalIoService()));
+ make_shared<ip::tcp::resolver>(ref(getGlobalIoService()));
resolver->async_resolve(query,
bind(&TcpChannel::handleEndpointResolution, this, _1, _2,
@@ -140,9 +140,9 @@
shared_ptr<Face> face;
if (socket->local_endpoint().address().is_loopback())
- face = make_shared<TcpLocalFace>(boost::cref(socket), isOnDemand);
+ face = make_shared<TcpLocalFace>(socket, isOnDemand);
else
- face = make_shared<TcpFace>(boost::cref(socket), isOnDemand);
+ face = make_shared<TcpFace>(socket, isOnDemand);
face->onFail += bind(&TcpChannel::afterFaceFailed, this, remoteEndpoint);
@@ -178,7 +178,7 @@
// prepare accepting the next connection
shared_ptr<ip::tcp::socket> clientSocket =
- make_shared<ip::tcp::socket>(boost::ref(getGlobalIoService()));
+ make_shared<ip::tcp::socket>(ref(getGlobalIoService()));
m_acceptor->async_accept(*clientSocket,
bind(&TcpChannel::handleSuccessfulAccept, this, _1,
clientSocket,
diff --git a/daemon/face/tcp-factory.cpp b/daemon/face/tcp-factory.cpp
index 07d7a86..bb08313 100644
--- a/daemon/face/tcp-factory.cpp
+++ b/daemon/face/tcp-factory.cpp
@@ -115,7 +115,7 @@
if(static_cast<bool>(channel))
return channel;
- channel = make_shared<TcpChannel>(boost::cref(endpoint));
+ channel = make_shared<TcpChannel>(endpoint);
m_channels[endpoint] = channel;
prohibitEndpoint(endpoint);
diff --git a/daemon/face/udp-channel.cpp b/daemon/face/udp-channel.cpp
index ca052a2..99d01e3 100644
--- a/daemon/face/udp-channel.cpp
+++ b/daemon/face/udp-channel.cpp
@@ -42,7 +42,7 @@
/// We need to check this
/// (SO_REUSEADDR doesn't behave uniformly in different OS)
- m_socket = make_shared<ip::udp::socket>(boost::ref(getGlobalIoService()));
+ m_socket = make_shared<ip::udp::socket>(ref(getGlobalIoService()));
m_socket->open(m_localEndpoint.protocol());
m_socket->set_option(boost::asio::ip::udp::socket::reuse_address(true));
if (m_localEndpoint.address().is_v6())
@@ -106,7 +106,7 @@
//creating a new socket for the face that will be created soon
shared_ptr<ip::udp::socket> clientSocket =
- make_shared<ip::udp::socket>(boost::ref(getGlobalIoService()));
+ make_shared<ip::udp::socket>(ref(getGlobalIoService()));
clientSocket->open(m_localEndpoint.protocol());
clientSocket->set_option(ip::udp::socket::reuse_address(true));
@@ -134,7 +134,7 @@
{
ip::udp::resolver::query query(remoteHost, remotePort);
shared_ptr<ip::udp::resolver> resolver =
- make_shared<ip::udp::resolver>(boost::ref(getGlobalIoService()));
+ make_shared<ip::udp::resolver>(ref(getGlobalIoService()));
resolver->async_resolve(query,
bind(&UdpChannel::handleEndpointResolution, this, _1, _2,
@@ -180,7 +180,7 @@
{
udp::Endpoint remoteEndpoint = socket->remote_endpoint();
- shared_ptr<UdpFace> face = make_shared<UdpFace>(boost::cref(socket), isOnDemand);
+ shared_ptr<UdpFace> face = make_shared<UdpFace>(socket, isOnDemand);
face->onFail += bind(&UdpChannel::afterFaceFailed, this, remoteEndpoint);
onFaceCreated(face);
@@ -215,7 +215,7 @@
}
else {
shared_ptr<ip::udp::socket> clientSocket =
- make_shared<ip::udp::socket>(boost::ref(getGlobalIoService()));
+ make_shared<ip::udp::socket>(ref(getGlobalIoService()));
clientSocket->open(m_localEndpoint.protocol());
clientSocket->set_option(ip::udp::socket::reuse_address(true));
clientSocket->bind(m_localEndpoint);
diff --git a/daemon/face/udp-channel.hpp b/daemon/face/udp-channel.hpp
index f97c3a3..73403aa 100644
--- a/daemon/face/udp-channel.hpp
+++ b/daemon/face/udp-channel.hpp
@@ -124,8 +124,7 @@
* associated with any UdpFace
*/
void
- newPeer(const boost::system::error_code& error,
- std::size_t nBytesReceived);
+ newPeer(const boost::system::error_code& error, std::size_t nBytesReceived);
void
handleEndpointResolution(const boost::system::error_code& error,
diff --git a/daemon/face/udp-factory.cpp b/daemon/face/udp-factory.cpp
index e97e9bb..470fd5e 100644
--- a/daemon/face/udp-factory.cpp
+++ b/daemon/face/udp-factory.cpp
@@ -148,8 +148,7 @@
"create a multicast face");
}
- channel = make_shared<UdpChannel>(boost::cref(endpoint),
- timeout);
+ channel = make_shared<UdpChannel>(endpoint, timeout);
m_channels[endpoint] = channel;
prohibitEndpoint(endpoint);
@@ -208,7 +207,7 @@
}
shared_ptr<ip::udp::socket> clientSocket =
- make_shared<ip::udp::socket>(boost::ref(getGlobalIoService()));
+ make_shared<ip::udp::socket>(ref(getGlobalIoService()));
clientSocket->open(multicastEndpoint.protocol());
@@ -249,7 +248,7 @@
clientSocket->set_option(ip::multicast::enable_loopback(false));
- multicastFace = make_shared<MulticastUdpFace>(boost::cref(clientSocket), localEndpoint);
+ multicastFace = make_shared<MulticastUdpFace>(clientSocket, localEndpoint);
multicastFace->onFail += bind(&UdpFactory::afterFaceFailed, this, localEndpoint);
m_multicastFaces[localEndpoint] = multicastFace;
@@ -326,8 +325,8 @@
return;
}
}
- onConnectFailed("No channels available to connect to "
- + boost::lexical_cast<std::string>(endpoint));
+ onConnectFailed("No channels available to connect to " +
+ boost::lexical_cast<std::string>(endpoint));
}
shared_ptr<UdpChannel>
diff --git a/daemon/face/unix-stream-channel.cpp b/daemon/face/unix-stream-channel.cpp
index efdf700..d64f333 100644
--- a/daemon/face/unix-stream-channel.cpp
+++ b/daemon/face/unix-stream-channel.cpp
@@ -96,7 +96,7 @@
throw Error(m_endpoint.path() + " already exists and is not a socket file");
}
- m_acceptor = make_shared<stream_protocol::acceptor>(boost::ref(getGlobalIoService()));
+ m_acceptor = make_shared<stream_protocol::acceptor>(ref(getGlobalIoService()));
m_acceptor->open();
m_acceptor->bind(m_endpoint);
m_acceptor->listen(backlog);
@@ -108,7 +108,7 @@
}
shared_ptr<stream_protocol::socket> clientSocket =
- make_shared<stream_protocol::socket>(boost::ref(getGlobalIoService()));
+ make_shared<stream_protocol::socket>(ref(getGlobalIoService()));
m_acceptor->async_accept(*clientSocket,
bind(&UnixStreamChannel::handleSuccessfulAccept, this,
@@ -134,7 +134,7 @@
NFD_LOG_DEBUG("[" << m_endpoint << "] << Incoming connection");
shared_ptr<stream_protocol::socket> clientSocket =
- make_shared<stream_protocol::socket>(boost::ref(getGlobalIoService()));
+ make_shared<stream_protocol::socket>(ref(getGlobalIoService()));
// prepare accepting the next connection
m_acceptor->async_accept(*clientSocket,
@@ -142,7 +142,7 @@
boost::asio::placeholders::error, clientSocket,
onFaceCreated, onAcceptFailed));
- shared_ptr<UnixStreamFace> face = make_shared<UnixStreamFace>(boost::cref(socket));
+ shared_ptr<UnixStreamFace> face = make_shared<UnixStreamFace>(socket);
onFaceCreated(face);
}
diff --git a/daemon/face/unix-stream-factory.cpp b/daemon/face/unix-stream-factory.cpp
index 96a158a..45668c9 100644
--- a/daemon/face/unix-stream-factory.cpp
+++ b/daemon/face/unix-stream-factory.cpp
@@ -39,7 +39,7 @@
if (channel)
return channel;
- channel = make_shared<UnixStreamChannel>(boost::cref(endpoint));
+ channel = make_shared<UnixStreamChannel>(endpoint);
m_channels[endpoint] = channel;
return channel;
}
diff --git a/daemon/face/websocket-channel.cpp b/daemon/face/websocket-channel.cpp
index db7fdc0..f409dc9 100644
--- a/daemon/face/websocket-channel.cpp
+++ b/daemon/face/websocket-channel.cpp
@@ -78,7 +78,7 @@
m_server.close(hdl, websocketpp::close::status::normal, "closed by channel", ecode);
}
shared_ptr<WebSocketFace> face = make_shared<WebSocketFace>(FaceUri(remote), this->getUri(),
- hdl, boost::ref(m_server));
+ hdl, ref(m_server));
m_onFaceCreatedCallback(face);
m_channelFaces[hdl] = face;
}
diff --git a/daemon/face/websocket-factory.cpp b/daemon/face/websocket-factory.cpp
index 224a75b..8a6e6c3 100644
--- a/daemon/face/websocket-factory.cpp
+++ b/daemon/face/websocket-factory.cpp
@@ -43,7 +43,7 @@
if (static_cast<bool>(channel))
return channel;
- channel = make_shared<WebSocketChannel>(boost::cref(endpoint));
+ channel = make_shared<WebSocketChannel>(endpoint);
m_channels[endpoint] = channel;
return channel;
diff --git a/daemon/fw/available-strategies.cpp b/daemon/fw/available-strategies.cpp
index fce0fc5..c6f7d42 100644
--- a/daemon/fw/available-strategies.cpp
+++ b/daemon/fw/available-strategies.cpp
@@ -33,7 +33,7 @@
shared_ptr<Strategy>
makeDefaultStrategy(Forwarder& forwarder)
{
- return make_shared<BestRouteStrategy>(boost::ref(forwarder));
+ return make_shared<BestRouteStrategy>(ref(forwarder));
}
template<typename S>
@@ -42,7 +42,7 @@
{
StrategyChoice& strategyChoice = forwarder.getStrategyChoice();
if (!strategyChoice.hasStrategy(S::STRATEGY_NAME)) {
- strategyChoice.install(make_shared<S>(boost::ref(forwarder)));
+ strategyChoice.install(make_shared<S>(ref(forwarder)));
}
}
diff --git a/daemon/fw/face-table.cpp b/daemon/fw/face-table.cpp
index ce66a89..ec9deb6 100644
--- a/daemon/fw/face-table.cpp
+++ b/daemon/fw/face-table.cpp
@@ -58,9 +58,9 @@
" local=" << face->getLocalUri());
face->onReceiveInterest += bind(&Forwarder::onInterest,
- &m_forwarder, boost::ref(*face), _1);
+ &m_forwarder, ref(*face), _1);
face->onReceiveData += bind(&Forwarder::onData,
- &m_forwarder, boost::ref(*face), _1);
+ &m_forwarder, ref(*face), _1);
face->onFail += bind(&FaceTable::remove,
this, face);
diff --git a/daemon/fw/forwarder.cpp b/daemon/fw/forwarder.cpp
index 6b06d10..4c8aa36 100644
--- a/daemon/fw/forwarder.cpp
+++ b/daemon/fw/forwarder.cpp
@@ -105,7 +105,7 @@
// dispatch to strategy
this->dispatchToStrategy(pitEntry, bind(&Strategy::afterReceiveInterest, _1,
- boost::cref(inFace), boost::cref(interest), fibEntry, pitEntry));
+ cref(inFace), cref(interest), fibEntry, pitEntry));
}
void
@@ -191,7 +191,7 @@
// invoke PIT unsatisfied callback
this->dispatchToStrategy(pitEntry, bind(&Strategy::beforeExpirePendingInterest, _1,
- pitEntry));
+ pitEntry));
// PIT delete
m_pit.erase(pitEntry);
@@ -254,7 +254,7 @@
// invoke PIT satisfy callback
this->dispatchToStrategy(pitEntry, bind(&Strategy::beforeSatisfyPendingInterest, _1,
- pitEntry, boost::cref(inFace), boost::cref(data)));
+ pitEntry, cref(inFace), cref(data)));
}
// foreach pending downstream
diff --git a/daemon/main.cpp b/daemon/main.cpp
index fdf14b5..697b65b 100644
--- a/daemon/main.cpp
+++ b/daemon/main.cpp
@@ -107,19 +107,19 @@
{
m_internalFace = make_shared<InternalFace>();
- m_fibManager = make_shared<FibManager>(boost::ref(m_forwarder->getFib()),
+ m_fibManager = make_shared<FibManager>(ref(m_forwarder->getFib()),
bind(&Forwarder::getFace, m_forwarder.get(), _1),
m_internalFace);
- m_faceManager = make_shared<FaceManager>(boost::ref(m_forwarder->getFaceTable()),
+ m_faceManager = make_shared<FaceManager>(ref(m_forwarder->getFaceTable()),
m_internalFace);
m_strategyChoiceManager =
- make_shared<StrategyChoiceManager>(boost::ref(m_forwarder->getStrategyChoice()),
+ make_shared<StrategyChoiceManager>(ref(m_forwarder->getStrategyChoice()),
m_internalFace);
m_statusServer = make_shared<StatusServer>(m_internalFace,
- boost::ref(*m_forwarder));
+ ref(*m_forwarder));
ConfigFile config((IgnoreRibAndLogSections()));
@@ -232,8 +232,7 @@
else
{
/// \todo May be try to reload config file (at least security section)
- signalSet.async_wait(bind(&Nfd::terminate, this, _1, _2,
- boost::ref(signalSet)));
+ signalSet.async_wait(bind(&Nfd::terminate, this, _1, _2, ref(signalSet)));
}
}
@@ -312,8 +311,7 @@
signalSet.add(SIGHUP);
signalSet.add(SIGUSR1);
signalSet.add(SIGUSR2);
- signalSet.async_wait(bind(&Nfd::terminate, &nfdInstance, _1, _2,
- boost::ref(signalSet)));
+ signalSet.async_wait(bind(&Nfd::terminate, &nfdInstance, _1, _2, ref(signalSet)));
try {
getGlobalIoService().run();
diff --git a/daemon/mgmt/face-manager.cpp b/daemon/mgmt/face-manager.cpp
index e2c2848..f91a8f8 100644
--- a/daemon/mgmt/face-manager.cpp
+++ b/daemon/mgmt/face-manager.cpp
@@ -314,7 +314,7 @@
if (!isDryRun)
{
- shared_ptr<TcpFactory> factory = make_shared<TcpFactory>(boost::cref(port));
+ shared_ptr<TcpFactory> factory = ndn::make_shared<TcpFactory>(port);
m_factories.insert(std::make_pair("tcp", factory));
if (enableV4)
@@ -485,7 +485,7 @@
if (!isDryRun)
{
- shared_ptr<UdpFactory> factory = make_shared<UdpFactory>(boost::cref(port));
+ shared_ptr<UdpFactory> factory = ndn::make_shared<UdpFactory>(port);
m_factories.insert(std::make_pair("udp", factory));
if (enableV4)
@@ -704,7 +704,7 @@
if (!isDryRun)
{
- shared_ptr<WebSocketFactory> factory = make_shared<WebSocketFactory>(boost::cref(port));
+ shared_ptr<WebSocketFactory> factory = ndn::make_shared<WebSocketFactory>(port);
m_factories.insert(std::make_pair("websocket", factory));
uint16_t portNo = boost::lexical_cast<uint16_t>(port);
@@ -747,7 +747,7 @@
if (unsignedVerbProcessor != m_unsignedVerbDispatch.end())
{
NFD_LOG_DEBUG("command result: processing verb: " << verb);
- (unsignedVerbProcessor->second)(this, boost::cref(request));
+ (unsignedVerbProcessor->second)(this, request);
}
else if (COMMAND_UNSIGNED_NCOMPS <= commandNComps &&
commandNComps < COMMAND_SIGNED_NCOMPS)
diff --git a/daemon/mgmt/fib-manager.cpp b/daemon/mgmt/fib-manager.cpp
index 0936f5c..98c4578 100644
--- a/daemon/mgmt/fib-manager.cpp
+++ b/daemon/mgmt/fib-manager.cpp
@@ -108,7 +108,7 @@
if (unsignedVerbProcessor != m_unsignedVerbDispatch.end())
{
NFD_LOG_DEBUG("command result: processing verb: " << verb);
- (unsignedVerbProcessor->second)(this, boost::cref(request));
+ (unsignedVerbProcessor->second)(this, request);
}
else if (COMMAND_UNSIGNED_NCOMPS <= commandNComps &&
commandNComps < COMMAND_SIGNED_NCOMPS)
diff --git a/daemon/table/pit.cpp b/daemon/table/pit.cpp
index 9c2554a..6f0e446 100644
--- a/daemon/table/pit.cpp
+++ b/daemon/table/pit.cpp
@@ -82,7 +82,7 @@
// then check if this Interest is already in the PIT entries
std::vector<shared_ptr<pit::Entry> >::const_iterator it =
std::find_if(pitEntries.begin(), pitEntries.end(),
- bind(&predicate_PitEntry_similar_Interest, _1, boost::cref(interest)));
+ bind(&predicate_PitEntry_similar_Interest, _1, cref(interest)));
if (it != pitEntries.end())
{
diff --git a/daemon/table/strategy-choice.cpp b/daemon/table/strategy-choice.cpp
index fff84c1..2383118 100644
--- a/daemon/table/strategy-choice.cpp
+++ b/daemon/table/strategy-choice.cpp
@@ -265,7 +265,7 @@
std::for_each(m_nameTree.partialEnumerate(entry->getPrefix(),
bind(&predicate_nameTreeEntry_needResetStrategyChoice,
- _1, boost::cref(*m_nameTree.get(*entry)))),
+ _1, cref(*m_nameTree.get(*entry)))),
m_nameTree.end(),
&clearStrategyInfo);
}
diff --git a/daemon/table/strategy-info-host.hpp b/daemon/table/strategy-info-host.hpp
index dfe9341..361eaaf 100644
--- a/daemon/table/strategy-info-host.hpp
+++ b/daemon/table/strategy-info-host.hpp
@@ -91,7 +91,7 @@
{
shared_ptr<T> info = this->getStrategyInfo<T>();
if (!static_cast<bool>(info)) {
- info = make_shared<T>(boost::ref(a1));
+ info = make_shared<T>(ref(a1));
this->setStrategyInfo(info);
}
return info;