Use make_unique where appropriate
Change-Id: I30c9f0fb2033a810df73a1c9147fcf09d610f763
Refs: #3093
diff --git a/common.hpp b/common.hpp
index 73116b1..25cc4a6 100644
--- a/common.hpp
+++ b/common.hpp
@@ -67,6 +67,7 @@
#include <ndn-cxx/data.hpp>
#include <ndn-cxx/name.hpp>
#include <ndn-cxx/encoding/block.hpp>
+#include <ndn-cxx/util/backports.hpp>
#include <ndn-cxx/util/face-uri.hpp>
#include <ndn-cxx/util/signal.hpp>
@@ -88,6 +89,7 @@
using std::unique_ptr;
using std::weak_ptr;
using std::make_shared;
+using ndn::make_unique;
using std::enable_shared_from_this;
using std::static_pointer_cast;
diff --git a/daemon/table/cs.cpp b/daemon/table/cs.cpp
index 9ea3d8b..674d333 100644
--- a/daemon/table/cs.cpp
+++ b/daemon/table/cs.cpp
@@ -47,7 +47,7 @@
unique_ptr<Policy>
makeDefaultPolicy()
{
- return unique_ptr<Policy>(new PriorityFifoPolicy());
+ return make_unique<PriorityFifoPolicy>();
}
Cs::Cs(size_t nMaxPackets, unique_ptr<Policy> policy)
diff --git a/tests/daemon/fw/topology-tester.hpp b/tests/daemon/fw/topology-tester.hpp
index 16a1173..406c6b1 100644
--- a/tests/daemon/fw/topology-tester.hpp
+++ b/tests/daemon/fw/topology-tester.hpp
@@ -247,7 +247,7 @@
addForwarder()
{
size_t i = m_forwarders.size();
- m_forwarders.push_back(std::move(unique_ptr<Forwarder>(new Forwarder())));
+ m_forwarders.push_back(make_unique<Forwarder>());
return i;
}
diff --git a/tests/daemon/table/cs-policy-lru.t.cpp b/tests/daemon/table/cs-policy-lru.t.cpp
index a690f33..02ce3c0 100644
--- a/tests/daemon/table/cs-policy-lru.t.cpp
+++ b/tests/daemon/table/cs-policy-lru.t.cpp
@@ -41,7 +41,7 @@
BOOST_FIXTURE_TEST_CASE(EvictOneLRU, UnitTestTimeFixture)
{
Cs cs(3);
- cs.setPolicy(unique_ptr<Policy>(new LruPolicy()));
+ cs.setPolicy(make_unique<LruPolicy>());
cs.insert(*makeData("ndn:/A"));
cs.insert(*makeData("ndn:/B"));
diff --git a/tests/daemon/table/cs-policy-priority-fifo.t.cpp b/tests/daemon/table/cs-policy-priority-fifo.t.cpp
index e88f8d5..8fd1746 100644
--- a/tests/daemon/table/cs-policy-priority-fifo.t.cpp
+++ b/tests/daemon/table/cs-policy-priority-fifo.t.cpp
@@ -41,7 +41,7 @@
BOOST_FIXTURE_TEST_CASE(EvictOne, UnitTestTimeFixture)
{
Cs cs(3);
- cs.setPolicy(unique_ptr<Policy>(new PriorityFifoPolicy()));
+ cs.setPolicy(make_unique<PriorityFifoPolicy>());
shared_ptr<Data> dataA = makeData("ndn:/A");
dataA->setFreshnessPeriod(time::milliseconds(99999));
@@ -94,7 +94,7 @@
BOOST_FIXTURE_TEST_CASE(Refresh, UnitTestTimeFixture)
{
Cs cs(3);
- cs.setPolicy(unique_ptr<Policy>(new PriorityFifoPolicy()));
+ cs.setPolicy(make_unique<PriorityFifoPolicy>());
shared_ptr<Data> dataA = makeData("ndn:/A");
dataA->setFreshnessPeriod(time::milliseconds(99999));