Commit f34acf2c authored by Christopher Dykes's avatar Christopher Dykes Committed by Facebook Github Bot

Codemod folly::make_unique to std::make_unique

Summary: There are still some upstream references to `folly::make_unique` that need to be removed before it can be full killed, but this gets it most of the way there.

Reviewed By: yfeldblum

Differential Revision: D5024310

fbshipit-source-id: 6cfe8ea93662be18bb55588c8200dec72946e205
parent fea92be9
...@@ -54,7 +54,7 @@ class AtomicLinkedList { ...@@ -54,7 +54,7 @@ class AtomicLinkedList {
* after the call. * after the call.
*/ */
bool insertHead(T t) { bool insertHead(T t) {
auto wrapper = folly::make_unique<Wrapper>(std::move(t)); auto wrapper = std::make_unique<Wrapper>(std::move(t));
return list_.insertHead(wrapper.release()); return list_.insertHead(wrapper.release());
} }
......
...@@ -41,7 +41,7 @@ Try<T>::Try(typename std::enable_if<std::is_same<Unit, T2>::value, ...@@ -41,7 +41,7 @@ Try<T>::Try(typename std::enable_if<std::is_same<Unit, T2>::value,
} else if (t.hasException()) { } else if (t.hasException()) {
contains_ = Contains::EXCEPTION; contains_ = Contains::EXCEPTION;
new (&e_) std::unique_ptr<exception_wrapper>( new (&e_) std::unique_ptr<exception_wrapper>(
folly::make_unique<exception_wrapper>(t.exception())); std::make_unique<exception_wrapper>(t.exception()));
} }
} }
...@@ -71,7 +71,7 @@ Try<T>::Try(const Try<T>& t) { ...@@ -71,7 +71,7 @@ Try<T>::Try(const Try<T>& t) {
new (&value_)T(t.value_); new (&value_)T(t.value_);
} else if (contains_ == Contains::EXCEPTION) { } else if (contains_ == Contains::EXCEPTION) {
new (&e_)std::unique_ptr<exception_wrapper>(); new (&e_)std::unique_ptr<exception_wrapper>();
e_ = folly::make_unique<exception_wrapper>(*(t.e_)); e_ = std::make_unique<exception_wrapper>(*(t.e_));
} }
} }
...@@ -86,7 +86,7 @@ Try<T>& Try<T>::operator=(const Try<T>& t) { ...@@ -86,7 +86,7 @@ Try<T>& Try<T>::operator=(const Try<T>& t) {
new (&value_)T(t.value_); new (&value_)T(t.value_);
} else if (contains_ == Contains::EXCEPTION) { } else if (contains_ == Contains::EXCEPTION) {
new (&e_)std::unique_ptr<exception_wrapper>(); new (&e_)std::unique_ptr<exception_wrapper>();
e_ = folly::make_unique<exception_wrapper>(*(t.e_)); e_ = std::make_unique<exception_wrapper>(*(t.e_));
} }
return *this; return *this;
} }
......
...@@ -93,8 +93,8 @@ class Try { ...@@ -93,8 +93,8 @@ class Try {
* @param e The exception_wrapper * @param e The exception_wrapper
*/ */
explicit Try(exception_wrapper e) explicit Try(exception_wrapper e)
: contains_(Contains::EXCEPTION), : contains_(Contains::EXCEPTION),
e_(folly::make_unique<exception_wrapper>(std::move(e))) {} e_(std::make_unique<exception_wrapper>(std::move(e))) {}
/* /*
* DEPRECATED * DEPRECATED
...@@ -108,9 +108,9 @@ class Try { ...@@ -108,9 +108,9 @@ class Try {
try { try {
std::rethrow_exception(ep); std::rethrow_exception(ep);
} catch (const std::exception& e) { } catch (const std::exception& e) {
e_ = folly::make_unique<exception_wrapper>(std::current_exception(), e); e_ = std::make_unique<exception_wrapper>(std::current_exception(), e);
} catch (...) { } catch (...) {
e_ = folly::make_unique<exception_wrapper>(std::current_exception()); e_ = std::make_unique<exception_wrapper>(std::current_exception());
} }
} }
...@@ -266,8 +266,8 @@ class Try<void> { ...@@ -266,8 +266,8 @@ class Try<void> {
* @param e The exception_wrapper * @param e The exception_wrapper
*/ */
explicit Try(exception_wrapper e) explicit Try(exception_wrapper e)
: hasValue_(false), : hasValue_(false),
e_(folly::make_unique<exception_wrapper>(std::move(e))) {} e_(std::make_unique<exception_wrapper>(std::move(e))) {}
/* /*
* DEPRECATED * DEPRECATED
...@@ -280,9 +280,9 @@ class Try<void> { ...@@ -280,9 +280,9 @@ class Try<void> {
try { try {
std::rethrow_exception(ep); std::rethrow_exception(ep);
} catch (const std::exception& e) { } catch (const std::exception& e) {
e_ = folly::make_unique<exception_wrapper>(std::current_exception(), e); e_ = std::make_unique<exception_wrapper>(std::current_exception(), e);
} catch (...) { } catch (...) {
e_ = folly::make_unique<exception_wrapper>(std::current_exception()); e_ = std::make_unique<exception_wrapper>(std::current_exception());
} }
} }
...@@ -290,7 +290,7 @@ class Try<void> { ...@@ -290,7 +290,7 @@ class Try<void> {
Try& operator=(const Try<void>& t) { Try& operator=(const Try<void>& t) {
hasValue_ = t.hasValue_; hasValue_ = t.hasValue_;
if (t.e_) { if (t.e_) {
e_ = folly::make_unique<exception_wrapper>(*t.e_); e_ = std::make_unique<exception_wrapper>(*t.e_);
} }
return *this; return *this;
} }
......
...@@ -102,7 +102,7 @@ TemporaryDirectory::TemporaryDirectory( ...@@ -102,7 +102,7 @@ TemporaryDirectory::TemporaryDirectory(
fs::path dir, fs::path dir,
Scope scope) Scope scope)
: scope_(scope), : scope_(scope),
path_(folly::make_unique<fs::path>( path_(std::make_unique<fs::path>(
generateUniquePath(std::move(dir), namePrefix))) { generateUniquePath(std::move(dir), namePrefix))) {
fs::create_directory(path()); fs::create_directory(path());
} }
......
...@@ -23,7 +23,7 @@ struct FutureDAGTest : public testing::Test { ...@@ -23,7 +23,7 @@ struct FutureDAGTest : public testing::Test {
typedef FutureDAG::Handle Handle; typedef FutureDAG::Handle Handle;
Handle add() { Handle add() {
auto node = folly::make_unique<TestNode>(this); auto node = std::make_unique<TestNode>(this);
auto handle = node->handle; auto handle = node->handle;
nodes.emplace(handle, std::move(node)); nodes.emplace(handle, std::move(node));
return handle; return handle;
......
...@@ -29,7 +29,7 @@ template <template<typename> class MainPtr, ...@@ -29,7 +29,7 @@ template <template<typename> class MainPtr,
template<typename> class WeakPtr, template<typename> class WeakPtr,
size_t threadCount> size_t threadCount>
void benchmark(size_t n) { void benchmark(size_t n) {
MainPtr<int> mainPtr(folly::make_unique<int>(42)); MainPtr<int> mainPtr(std::make_unique<int>(42));
std::vector<std::thread> ts; std::vector<std::thread> ts;
......
...@@ -84,12 +84,12 @@ TEST_F(ReadMostlySharedPtrTest, BasicStores) { ...@@ -84,12 +84,12 @@ TEST_F(ReadMostlySharedPtrTest, BasicStores) {
// Store 1. // Store 1.
std::atomic<int> cnt1{0}; std::atomic<int> cnt1{0};
ptr.reset(folly::make_unique<TestObject>(1, cnt1)); ptr.reset(std::make_unique<TestObject>(1, cnt1));
EXPECT_EQ(1, cnt1.load()); EXPECT_EQ(1, cnt1.load());
// Store 2, check that 1 is destroyed. // Store 2, check that 1 is destroyed.
std::atomic<int> cnt2{0}; std::atomic<int> cnt2{0};
ptr.reset(folly::make_unique<TestObject>(2, cnt2)); ptr.reset(std::make_unique<TestObject>(2, cnt2));
EXPECT_EQ(1, cnt2.load()); EXPECT_EQ(1, cnt2.load());
EXPECT_EQ(0, cnt1.load()); EXPECT_EQ(0, cnt1.load());
...@@ -109,13 +109,13 @@ TEST_F(ReadMostlySharedPtrTest, BasicLoads) { ...@@ -109,13 +109,13 @@ TEST_F(ReadMostlySharedPtrTest, BasicLoads) {
EXPECT_EQ(ptr.get(), nullptr); EXPECT_EQ(ptr.get(), nullptr);
std::atomic<int> cnt1{0}; std::atomic<int> cnt1{0};
ptr.reset(folly::make_unique<TestObject>(1, cnt1)); ptr.reset(std::make_unique<TestObject>(1, cnt1));
EXPECT_EQ(1, cnt1.load()); EXPECT_EQ(1, cnt1.load());
x = ptr; x = ptr;
EXPECT_EQ(1, x->value); EXPECT_EQ(1, x->value);
ptr.reset(folly::make_unique<TestObject>(2, cnt2)); ptr.reset(std::make_unique<TestObject>(2, cnt2));
EXPECT_EQ(1, cnt2.load()); EXPECT_EQ(1, cnt2.load());
EXPECT_EQ(1, cnt1.load()); EXPECT_EQ(1, cnt1.load());
...@@ -174,18 +174,18 @@ TEST_F(ReadMostlySharedPtrTest, LoadsFromThreads) { ...@@ -174,18 +174,18 @@ TEST_F(ReadMostlySharedPtrTest, LoadsFromThreads) {
loads[0].requestAndWait(); loads[0].requestAndWait();
ptr.reset(folly::make_unique<TestObject>(1, cnt)); ptr.reset(std::make_unique<TestObject>(1, cnt));
loads[1].requestAndWait(); loads[1].requestAndWait();
ptr.reset(folly::make_unique<TestObject>(2, cnt)); ptr.reset(std::make_unique<TestObject>(2, cnt));
loads[2].requestAndWait(); loads[2].requestAndWait();
loads[3].requestAndWait(); loads[3].requestAndWait();
ptr.reset(folly::make_unique<TestObject>(3, cnt)); ptr.reset(std::make_unique<TestObject>(3, cnt));
ptr.reset(folly::make_unique<TestObject>(4, cnt)); ptr.reset(std::make_unique<TestObject>(4, cnt));
loads[4].requestAndWait(); loads[4].requestAndWait();
ptr.reset(folly::make_unique<TestObject>(5, cnt)); ptr.reset(std::make_unique<TestObject>(5, cnt));
loads[5].requestAndWait(); loads[5].requestAndWait();
loads[6].requestAndWait(); loads[6].requestAndWait();
...@@ -201,8 +201,7 @@ TEST_F(ReadMostlySharedPtrTest, LoadsFromThreads) { ...@@ -201,8 +201,7 @@ TEST_F(ReadMostlySharedPtrTest, LoadsFromThreads) {
TEST_F(ReadMostlySharedPtrTest, Ctor) { TEST_F(ReadMostlySharedPtrTest, Ctor) {
std::atomic<int> cnt1{0}; std::atomic<int> cnt1{0};
{ {
ReadMostlyMainPtr<TestObject> ptr( ReadMostlyMainPtr<TestObject> ptr(std::make_unique<TestObject>(1, cnt1));
folly::make_unique<TestObject>(1, cnt1));
EXPECT_EQ(1, ptr.getShared()->value); EXPECT_EQ(1, ptr.getShared()->value);
} }
...@@ -217,7 +216,7 @@ TEST_F(ReadMostlySharedPtrTest, ClearingCache) { ...@@ -217,7 +216,7 @@ TEST_F(ReadMostlySharedPtrTest, ClearingCache) {
ReadMostlyMainPtr<TestObject> ptr; ReadMostlyMainPtr<TestObject> ptr;
// Store 1. // Store 1.
ptr.reset(folly::make_unique<TestObject>(1, cnt1)); ptr.reset(std::make_unique<TestObject>(1, cnt1));
Coordinator c; Coordinator c;
...@@ -232,7 +231,7 @@ TEST_F(ReadMostlySharedPtrTest, ClearingCache) { ...@@ -232,7 +231,7 @@ TEST_F(ReadMostlySharedPtrTest, ClearingCache) {
EXPECT_EQ(1, cnt1.load()); EXPECT_EQ(1, cnt1.load());
// Store 2 and check that 1 is destroyed. // Store 2 and check that 1 is destroyed.
ptr.reset(folly::make_unique<TestObject>(2, cnt2)); ptr.reset(std::make_unique<TestObject>(2, cnt2));
EXPECT_EQ(0, cnt1.load()); EXPECT_EQ(0, cnt1.load());
// Unblock thread. // Unblock thread.
......
...@@ -118,7 +118,7 @@ TEST(TemporaryDirectory, SafelyMove) { ...@@ -118,7 +118,7 @@ TEST(TemporaryDirectory, SafelyMove) {
expectTempdirExists(d); expectTempdirExists(d);
expectTempdirExists(d2); expectTempdirExists(d2);
dir = folly::make_unique<TemporaryDirectory>(std::move(d)); dir = std::make_unique<TemporaryDirectory>(std::move(d));
dir2 = std::move(d2); dir2 = std::move(d2);
} }
......
...@@ -335,7 +335,7 @@ class ScopedAlternateSignalStack { ...@@ -335,7 +335,7 @@ class ScopedAlternateSignalStack {
return; return;
} }
stack_ = folly::make_unique<AltStackBuffer>(); stack_ = std::make_unique<AltStackBuffer>();
setAlternateStack(stack_->data(), stack_->size()); setAlternateStack(stack_->data(), stack_->size());
} }
......
...@@ -313,10 +313,10 @@ void FiberManager::addTaskRemote(F&& func) { ...@@ -313,10 +313,10 @@ void FiberManager::addTaskRemote(F&& func) {
auto currentFm = getFiberManagerUnsafe(); auto currentFm = getFiberManagerUnsafe();
if (currentFm && currentFm->currentFiber_ && if (currentFm && currentFm->currentFiber_ &&
currentFm->localType_ == localType_) { currentFm->localType_ == localType_) {
return folly::make_unique<RemoteTask>( return std::make_unique<RemoteTask>(
std::forward<F>(func), currentFm->currentFiber_->localData_); std::forward<F>(func), currentFm->currentFiber_->localData_);
} }
return folly::make_unique<RemoteTask>(std::forward<F>(func)); return std::make_unique<RemoteTask>(std::forward<F>(func));
}(); }();
auto insertHead = [&]() { auto insertHead = [&]() {
return remoteTaskQueue_.insertHead(task.release()); return remoteTaskQueue_.insertHead(task.release());
......
...@@ -337,7 +337,7 @@ class FiberManager : public ::folly::Executor { ...@@ -337,7 +337,7 @@ class FiberManager : public ::folly::Executor {
template <typename F> template <typename F>
RemoteTask(F&& f, const Fiber::LocalData& localData_) RemoteTask(F&& f, const Fiber::LocalData& localData_)
: func(std::forward<F>(f)), : func(std::forward<F>(f)),
localData(folly::make_unique<Fiber::LocalData>(localData_)), localData(std::make_unique<Fiber::LocalData>(localData_)),
rcontext(RequestContext::saveContext()) {} rcontext(RequestContext::saveContext()) {}
folly::Function<void()> func; folly::Function<void()> func;
std::unique_ptr<Fiber::LocalData> localData; std::unique_ptr<Fiber::LocalData> localData;
......
...@@ -245,7 +245,7 @@ class CacheManager { ...@@ -245,7 +245,7 @@ class CacheManager {
std::lock_guard<folly::SpinLock> lg(lock_); std::lock_guard<folly::SpinLock> lg(lock_);
if (inUse_ < kMaxInUse) { if (inUse_ < kMaxInUse) {
++inUse_; ++inUse_;
return folly::make_unique<StackCacheEntry>(stackSize); return std::make_unique<StackCacheEntry>(stackSize);
} }
return nullptr; return nullptr;
...@@ -277,7 +277,7 @@ class CacheManager { ...@@ -277,7 +277,7 @@ class CacheManager {
class StackCacheEntry { class StackCacheEntry {
public: public:
explicit StackCacheEntry(size_t stackSize) explicit StackCacheEntry(size_t stackSize)
: stackCache_(folly::make_unique<StackCache>(stackSize)) {} : stackCache_(std::make_unique<StackCache>(stackSize)) {}
StackCache& cache() const noexcept { StackCache& cache() const noexcept {
return *stackCache_; return *stackCache_;
......
...@@ -33,7 +33,7 @@ intptr_t TimeoutController::registerTimeout( ...@@ -33,7 +33,7 @@ intptr_t TimeoutController::registerTimeout(
} }
timeoutHandleBuckets_.emplace_back( timeoutHandleBuckets_.emplace_back(
duration, folly::make_unique<TimeoutHandleList>()); duration, std::make_unique<TimeoutHandleList>());
return *timeoutHandleBuckets_.back().second; return *timeoutHandleBuckets_.back().second;
}(); }();
......
...@@ -31,7 +31,7 @@ static size_t sNumAwaits; ...@@ -31,7 +31,7 @@ static size_t sNumAwaits;
void runBenchmark(size_t numAwaits, size_t toSend) { void runBenchmark(size_t numAwaits, size_t toSend) {
sNumAwaits = numAwaits; sNumAwaits = numAwaits;
FiberManager fiberManager(folly::make_unique<SimpleLoopController>()); FiberManager fiberManager(std::make_unique<SimpleLoopController>());
auto& loopController = auto& loopController =
dynamic_cast<SimpleLoopController&>(fiberManager.loopController()); dynamic_cast<SimpleLoopController&>(fiberManager.loopController());
...@@ -87,7 +87,7 @@ BENCHMARK(FiberManagerAllocateDeallocatePattern, iters) { ...@@ -87,7 +87,7 @@ BENCHMARK(FiberManagerAllocateDeallocatePattern, iters) {
FiberManager::Options opts; FiberManager::Options opts;
opts.maxFibersPoolSize = 0; opts.maxFibersPoolSize = 0;
FiberManager fiberManager(folly::make_unique<SimpleLoopController>(), opts); FiberManager fiberManager(std::make_unique<SimpleLoopController>(), opts);
for (size_t iter = 0; iter < iters; ++iter) { for (size_t iter = 0; iter < iters; ++iter) {
DCHECK_EQ(0, fiberManager.fibersPoolSize()); DCHECK_EQ(0, fiberManager.fibersPoolSize());
...@@ -110,7 +110,7 @@ BENCHMARK(FiberManagerAllocateLargeChunk, iters) { ...@@ -110,7 +110,7 @@ BENCHMARK(FiberManagerAllocateLargeChunk, iters) {
FiberManager::Options opts; FiberManager::Options opts;
opts.maxFibersPoolSize = 0; opts.maxFibersPoolSize = 0;
FiberManager fiberManager(folly::make_unique<SimpleLoopController>(), opts); FiberManager fiberManager(std::make_unique<SimpleLoopController>(), opts);
for (size_t iter = 0; iter < iters; ++iter) { for (size_t iter = 0; iter < iters; ++iter) {
DCHECK_EQ(0, fiberManager.fibersPoolSize()); DCHECK_EQ(0, fiberManager.fibersPoolSize());
......
This diff is collapsed.
...@@ -26,7 +26,7 @@ using namespace folly::fibers; ...@@ -26,7 +26,7 @@ using namespace folly::fibers;
struct Application { struct Application {
public: public:
Application() Application()
: fiberManager(folly::make_unique<SimpleLoopController>()), : fiberManager(std::make_unique<SimpleLoopController>()),
toSend(20), toSend(20),
maxOutstanding(5) {} maxOutstanding(5) {}
......
...@@ -1190,7 +1190,7 @@ Future<Unit> whileDo(P&& predicate, F&& thunk) { ...@@ -1190,7 +1190,7 @@ Future<Unit> whileDo(P&& predicate, F&& thunk) {
template <class F> template <class F>
Future<Unit> times(const int n, F&& thunk) { Future<Unit> times(const int n, F&& thunk) {
return folly::whileDo( return folly::whileDo(
[ n, count = folly::make_unique<std::atomic<int>>(0) ]() mutable { [ n, count = std::make_unique<std::atomic<int>>(0) ]() mutable {
return count->fetch_add(1) < n; return count->fetch_add(1) < n;
}, },
std::forward<F>(thunk)); std::forward<F>(thunk));
......
...@@ -240,7 +240,7 @@ class Core final { ...@@ -240,7 +240,7 @@ class Core final {
interruptLock_.lock(); interruptLock_.lock();
} }
if (!interrupt_ && !hasResult()) { if (!interrupt_ && !hasResult()) {
interrupt_ = folly::make_unique<exception_wrapper>(std::move(e)); interrupt_ = std::make_unique<exception_wrapper>(std::move(e));
if (interruptHandler_) { if (interruptHandler_) {
interruptHandler_(*interrupt_); interruptHandler_(*interrupt_);
} }
......
...@@ -29,8 +29,9 @@ TEST(Filter, alwaysFalse) { ...@@ -29,8 +29,9 @@ TEST(Filter, alwaysFalse) {
} }
TEST(Filter, moveOnlyValue) { TEST(Filter, moveOnlyValue) {
EXPECT_EQ(42, EXPECT_EQ(
*makeFuture(folly::make_unique<int>(42)) 42,
.filter([](std::unique_ptr<int> const&) { return true; }) *makeFuture(std::make_unique<int>(42))
.get()); .filter([](std::unique_ptr<int> const&) { return true; })
.get());
} }
...@@ -722,8 +722,8 @@ TEST(Future, detachRace) { ...@@ -722,8 +722,8 @@ TEST(Future, detachRace) {
// slow test so I won't do that but if it ever fails, take it seriously, and // slow test so I won't do that but if it ever fails, take it seriously, and
// run the test binary with "--gtest_repeat=10000 --gtest_filter=*detachRace" // run the test binary with "--gtest_repeat=10000 --gtest_filter=*detachRace"
// (Don't forget to enable ASAN) // (Don't forget to enable ASAN)
auto p = folly::make_unique<Promise<bool>>(); auto p = std::make_unique<Promise<bool>>();
auto f = folly::make_unique<Future<bool>>(p->getFuture()); auto f = std::make_unique<Future<bool>>(p->getFuture());
folly::Baton<> baton; folly::Baton<> baton;
std::thread t1([&]{ std::thread t1([&]{
baton.post(); baton.post();
...@@ -818,7 +818,7 @@ TEST(Future, RequestContext) { ...@@ -818,7 +818,7 @@ TEST(Future, RequestContext) {
{ {
folly::RequestContextScopeGuard rctx; folly::RequestContextScopeGuard rctx;
RequestContext::get()->setContextData( RequestContext::get()->setContextData(
"key", folly::make_unique<MyRequestData>(true)); "key", std::make_unique<MyRequestData>(true));
auto checker = [](int lineno) { auto checker = [](int lineno) {
return [lineno](Try<int>&& /* t */) { return [lineno](Try<int>&& /* t */) {
auto d = static_cast<MyRequestData*>( auto d = static_cast<MyRequestData*>(
......
...@@ -38,7 +38,7 @@ TEST(NonCopyableLambda, basic) { ...@@ -38,7 +38,7 @@ TEST(NonCopyableLambda, basic) {
TEST(NonCopyableLambda, unique_ptr) { TEST(NonCopyableLambda, unique_ptr) {
Promise<Unit> promise; Promise<Unit> promise;
auto int_ptr = folly::make_unique<int>(1); auto int_ptr = std::make_unique<int>(1);
EXPECT_EQ(*int_ptr, 1); EXPECT_EQ(*int_ptr, 1);
......
...@@ -134,7 +134,7 @@ TEST(Promise, isFulfilledWithFuture) { ...@@ -134,7 +134,7 @@ TEST(Promise, isFulfilledWithFuture) {
} }
TEST(Promise, brokenOnDelete) { TEST(Promise, brokenOnDelete) {
auto p = folly::make_unique<Promise<int>>(); auto p = std::make_unique<Promise<int>>();
auto f = p->getFuture(); auto f = p->getFuture();
EXPECT_FALSE(f.isReady()); EXPECT_FALSE(f.isReady());
...@@ -149,10 +149,10 @@ TEST(Promise, brokenOnDelete) { ...@@ -149,10 +149,10 @@ TEST(Promise, brokenOnDelete) {
} }
TEST(Promise, brokenPromiseHasTypeInfo) { TEST(Promise, brokenPromiseHasTypeInfo) {
auto pInt = folly::make_unique<Promise<int>>(); auto pInt = std::make_unique<Promise<int>>();
auto fInt = pInt->getFuture(); auto fInt = pInt->getFuture();
auto pFloat = folly::make_unique<Promise<float>>(); auto pFloat = std::make_unique<Promise<float>>();
auto fFloat = pFloat->getFuture(); auto fFloat = pFloat->getFuture();
pInt.reset(); pInt.reset();
......
...@@ -335,9 +335,8 @@ class ThreadExecutor : public Executor { ...@@ -335,9 +335,8 @@ class ThreadExecutor : public Executor {
TEST(Via, viaThenGetWasRacy) { TEST(Via, viaThenGetWasRacy) {
ThreadExecutor x; ThreadExecutor x;
std::unique_ptr<int> val = folly::via(&x) std::unique_ptr<int> val =
.then([] { return folly::make_unique<int>(42); }) folly::via(&x).then([] { return std::make_unique<int>(42); }).get();
.get();
ASSERT_TRUE(!!val); ASSERT_TRUE(!!val);
EXPECT_EQ(42, *val); EXPECT_EQ(42, *val);
} }
...@@ -603,7 +602,7 @@ TEST(ViaFunc, isSticky) { ...@@ -603,7 +602,7 @@ TEST(ViaFunc, isSticky) {
TEST(ViaFunc, moveOnly) { TEST(ViaFunc, moveOnly) {
ManualExecutor x; ManualExecutor x;
auto intp = folly::make_unique<int>(42); auto intp = std::make_unique<int>(42);
EXPECT_EQ(42, via(&x, [intp = std::move(intp)] { return *intp; }).getVia(&x)); EXPECT_EQ(42, via(&x, [intp = std::move(intp)] { return *intp; }).getVia(&x));
} }
...@@ -1274,14 +1274,14 @@ TEST(Gen, Unwrap) { ...@@ -1274,14 +1274,14 @@ TEST(Gen, Unwrap) {
EXPECT_EQ(4, o | unwrap); EXPECT_EQ(4, o | unwrap);
EXPECT_THROW(e | unwrap, OptionalEmptyException); EXPECT_THROW(e | unwrap, OptionalEmptyException);
auto oup = folly::make_optional(folly::make_unique<int>(5)); auto oup = folly::make_optional(std::make_unique<int>(5));
// optional has a value, and that value is non-null // optional has a value, and that value is non-null
EXPECT_TRUE(bool(oup | unwrap)); EXPECT_TRUE(bool(oup | unwrap));
EXPECT_EQ(5, *(oup | unwrap)); EXPECT_EQ(5, *(oup | unwrap));
EXPECT_TRUE(oup.hasValue()); // still has a pointer (null or not) EXPECT_TRUE(oup.hasValue()); // still has a pointer (null or not)
EXPECT_TRUE(bool(oup.value())); // that value isn't null EXPECT_TRUE(bool(oup.value())); // that value isn't null
auto moved1 = std::move(oup) | unwrapOr(folly::make_unique<int>(6)); auto moved1 = std::move(oup) | unwrapOr(std::make_unique<int>(6));
// oup still has a value, but now it's now nullptr since the pointer was moved // oup still has a value, but now it's now nullptr since the pointer was moved
// into moved1 // into moved1
EXPECT_TRUE(oup.hasValue()); EXPECT_TRUE(oup.hasValue());
...@@ -1289,12 +1289,12 @@ TEST(Gen, Unwrap) { ...@@ -1289,12 +1289,12 @@ TEST(Gen, Unwrap) {
EXPECT_TRUE(bool(moved1)); EXPECT_TRUE(bool(moved1));
EXPECT_EQ(5, *moved1); EXPECT_EQ(5, *moved1);
auto moved2 = std::move(oup) | unwrapOr(folly::make_unique<int>(7)); auto moved2 = std::move(oup) | unwrapOr(std::make_unique<int>(7));
// oup's still-valid nullptr value wins here, the pointer to 7 doesn't apply // oup's still-valid nullptr value wins here, the pointer to 7 doesn't apply
EXPECT_FALSE(moved2); EXPECT_FALSE(moved2);
oup.clear(); oup.clear();
auto moved3 = std::move(oup) | unwrapOr(folly::make_unique<int>(8)); auto moved3 = std::move(oup) | unwrapOr(std::make_unique<int>(8));
// oup is empty now, so the unwrapOr comes into play. // oup is empty now, so the unwrapOr comes into play.
EXPECT_TRUE(bool(moved3)); EXPECT_TRUE(bool(moved3));
EXPECT_EQ(8, *moved3); EXPECT_EQ(8, *moved3);
...@@ -1332,7 +1332,7 @@ TEST(Gen, Unwrap) { ...@@ -1332,7 +1332,7 @@ TEST(Gen, Unwrap) {
{ {
auto opt = folly::make_optional(std::make_shared<int>(8)); auto opt = folly::make_optional(std::make_shared<int>(8));
auto fallback = unwrapOr(folly::make_unique<int>(9)); auto fallback = unwrapOr(std::make_unique<int>(9));
// fallback must be std::move'd to be used // fallback must be std::move'd to be used
EXPECT_EQ(8, *(opt | std::move(fallback))); EXPECT_EQ(8, *(opt | std::move(fallback)));
EXPECT_TRUE(bool(opt.value())); // shared_ptr copied out, not moved EXPECT_TRUE(bool(opt.value())); // shared_ptr copied out, not moved
......
...@@ -1338,7 +1338,7 @@ AsyncSSLSocket::performRead(void** buf, size_t* buflen, size_t* offset) { ...@@ -1338,7 +1338,7 @@ AsyncSSLSocket::performRead(void** buf, size_t* buflen, size_t* offset) {
<< "): client intitiated SSL renegotiation not permitted"; << "): client intitiated SSL renegotiation not permitted";
return ReadResult( return ReadResult(
READ_ERROR, READ_ERROR,
folly::make_unique<SSLException>(SSLError::CLIENT_RENEGOTIATION)); std::make_unique<SSLException>(SSLError::CLIENT_RENEGOTIATION));
} }
if (bytes <= 0) { if (bytes <= 0) {
int error = SSL_get_error(ssl_, bytes); int error = SSL_get_error(ssl_, bytes);
...@@ -1358,7 +1358,7 @@ AsyncSSLSocket::performRead(void** buf, size_t* buflen, size_t* offset) { ...@@ -1358,7 +1358,7 @@ AsyncSSLSocket::performRead(void** buf, size_t* buflen, size_t* offset) {
<< "): unsupported SSL renegotiation during read"; << "): unsupported SSL renegotiation during read";
return ReadResult( return ReadResult(
READ_ERROR, READ_ERROR,
folly::make_unique<SSLException>(SSLError::INVALID_RENEGOTIATION)); std::make_unique<SSLException>(SSLError::INVALID_RENEGOTIATION));
} else { } else {
if (zero_return(error, bytes)) { if (zero_return(error, bytes)) {
return ReadResult(bytes); return ReadResult(bytes);
...@@ -1375,7 +1375,7 @@ AsyncSSLSocket::performRead(void** buf, size_t* buflen, size_t* offset) { ...@@ -1375,7 +1375,7 @@ AsyncSSLSocket::performRead(void** buf, size_t* buflen, size_t* offset) {
<< "reason: " << ERR_reason_error_string(errError); << "reason: " << ERR_reason_error_string(errError);
return ReadResult( return ReadResult(
READ_ERROR, READ_ERROR,
folly::make_unique<SSLException>(error, errError, bytes, errno)); std::make_unique<SSLException>(error, errError, bytes, errno));
} }
} else { } else {
appBytesReceived_ += bytes; appBytesReceived_ += bytes;
...@@ -1418,7 +1418,7 @@ AsyncSocket::WriteResult AsyncSSLSocket::interpretSSLError(int rc, int error) { ...@@ -1418,7 +1418,7 @@ AsyncSocket::WriteResult AsyncSSLSocket::interpretSSLError(int rc, int error) {
<< "unsupported SSL renegotiation during write"; << "unsupported SSL renegotiation during write";
return WriteResult( return WriteResult(
WRITE_ERROR, WRITE_ERROR,
folly::make_unique<SSLException>(SSLError::INVALID_RENEGOTIATION)); std::make_unique<SSLException>(SSLError::INVALID_RENEGOTIATION));
} else { } else {
if (zero_return(error, rc)) { if (zero_return(error, rc)) {
return WriteResult(0); return WriteResult(0);
...@@ -1431,7 +1431,7 @@ AsyncSocket::WriteResult AsyncSSLSocket::interpretSSLError(int rc, int error) { ...@@ -1431,7 +1431,7 @@ AsyncSocket::WriteResult AsyncSSLSocket::interpretSSLError(int rc, int error) {
<< ", reason: " << ERR_reason_error_string(errError); << ", reason: " << ERR_reason_error_string(errError);
return WriteResult( return WriteResult(
WRITE_ERROR, WRITE_ERROR,
folly::make_unique<SSLException>(error, errError, rc, errno)); std::make_unique<SSLException>(error, errError, rc, errno));
} }
} }
...@@ -1452,7 +1452,7 @@ AsyncSocket::WriteResult AsyncSSLSocket::performWrite( ...@@ -1452,7 +1452,7 @@ AsyncSocket::WriteResult AsyncSSLSocket::performWrite(
<< "TODO: AsyncSSLSocket currently does not support calling " << "TODO: AsyncSSLSocket currently does not support calling "
<< "write() before the handshake has fully completed"; << "write() before the handshake has fully completed";
return WriteResult( return WriteResult(
WRITE_ERROR, folly::make_unique<SSLException>(SSLError::EARLY_WRITE)); WRITE_ERROR, std::make_unique<SSLException>(SSLError::EARLY_WRITE));
} }
// Declare a buffer used to hold small write requests. It could point to a // Declare a buffer used to hold small write requests. It could point to a
......
...@@ -2011,7 +2011,7 @@ AsyncSocket::sendSocketMessage(int fd, struct msghdr* msg, int msg_flags) { ...@@ -2011,7 +2011,7 @@ AsyncSocket::sendSocketMessage(int fd, struct msghdr* msg, int msg_flags) {
registerForConnectEvents(); registerForConnectEvents();
} catch (const AsyncSocketException& ex) { } catch (const AsyncSocketException& ex) {
return WriteResult( return WriteResult(
WRITE_ERROR, folly::make_unique<AsyncSocketException>(ex)); WRITE_ERROR, std::make_unique<AsyncSocketException>(ex));
} }
// Let's fake it that no bytes were written and return an errno. // Let's fake it that no bytes were written and return an errno.
errno = EAGAIN; errno = EAGAIN;
...@@ -2034,7 +2034,7 @@ AsyncSocket::sendSocketMessage(int fd, struct msghdr* msg, int msg_flags) { ...@@ -2034,7 +2034,7 @@ AsyncSocket::sendSocketMessage(int fd, struct msghdr* msg, int msg_flags) {
totalWritten = -1; totalWritten = -1;
} catch (const AsyncSocketException& ex) { } catch (const AsyncSocketException& ex) {
return WriteResult( return WriteResult(
WRITE_ERROR, folly::make_unique<AsyncSocketException>(ex)); WRITE_ERROR, std::make_unique<AsyncSocketException>(ex));
} }
} else if (errno == EAGAIN) { } else if (errno == EAGAIN) {
// Normally sendmsg would indicate that the write would block. // Normally sendmsg would indicate that the write would block.
...@@ -2043,7 +2043,7 @@ AsyncSocket::sendSocketMessage(int fd, struct msghdr* msg, int msg_flags) { ...@@ -2043,7 +2043,7 @@ AsyncSocket::sendSocketMessage(int fd, struct msghdr* msg, int msg_flags) {
// instead, and is an error condition indicating no fds available. // instead, and is an error condition indicating no fds available.
return WriteResult( return WriteResult(
WRITE_ERROR, WRITE_ERROR,
folly::make_unique<AsyncSocketException>( std::make_unique<AsyncSocketException>(
AsyncSocketException::UNKNOWN, "No more free local ports")); AsyncSocketException::UNKNOWN, "No more free local ports"));
} }
} else { } else {
......
...@@ -740,7 +740,7 @@ const char* EventBase::getLibeventMethod() { return event_get_method(); } ...@@ -740,7 +740,7 @@ const char* EventBase::getLibeventMethod() { return event_get_method(); }
VirtualEventBase& EventBase::getVirtualEventBase() { VirtualEventBase& EventBase::getVirtualEventBase() {
folly::call_once(virtualEventBaseInitFlag_, [&] { folly::call_once(virtualEventBaseInitFlag_, [&] {
virtualEventBase_ = folly::make_unique<VirtualEventBase>(*this); virtualEventBase_ = std::make_unique<VirtualEventBase>(*this);
}); });
return *virtualEventBase_; return *virtualEventBase_;
......
...@@ -251,7 +251,7 @@ size_t HHWheelTimer::cancelAll() { ...@@ -251,7 +251,7 @@ size_t HHWheelTimer::cancelAll() {
if (count_ != 0) { if (count_ != 0) {
const uint64_t numElements = WHEEL_BUCKETS * WHEEL_SIZE; const uint64_t numElements = WHEEL_BUCKETS * WHEEL_SIZE;
auto maxBuckets = std::min(numElements, count_); auto maxBuckets = std::min(numElements, count_);
auto buckets = folly::make_unique<CallbackList[]>(maxBuckets); auto buckets = std::make_unique<CallbackList[]>(maxBuckets);
size_t countBuckets = 0; size_t countBuckets = 0;
for (auto& tick : buckets_) { for (auto& tick : buckets_) {
for (auto& bucket : tick) { for (auto& bucket : tick) {
......
...@@ -72,7 +72,7 @@ struct TimeoutManager::CobTimeouts { ...@@ -72,7 +72,7 @@ struct TimeoutManager::CobTimeouts {
}; };
TimeoutManager::TimeoutManager() TimeoutManager::TimeoutManager()
: cobTimeouts_(folly::make_unique<CobTimeouts>()) {} : cobTimeouts_(std::make_unique<CobTimeouts>()) {}
void TimeoutManager::runAfterDelay( void TimeoutManager::runAfterDelay(
Func cob, Func cob,
...@@ -92,8 +92,8 @@ bool TimeoutManager::tryRunAfterDelay( ...@@ -92,8 +92,8 @@ bool TimeoutManager::tryRunAfterDelay(
return false; return false;
} }
auto timeout = folly::make_unique<CobTimeouts::CobTimeout>( auto timeout =
this, std::move(cob), internal); std::make_unique<CobTimeouts::CobTimeout>(this, std::move(cob), internal);
if (!timeout->scheduleTimeout(milliseconds)) { if (!timeout->scheduleTimeout(milliseconds)) {
return false; return false;
} }
......
...@@ -181,7 +181,7 @@ TEST(AsyncSSLSocketTest, ReadAfterClose) { ...@@ -181,7 +181,7 @@ TEST(AsyncSSLSocketTest, ReadAfterClose) {
ReadEOFCallback readCallback(&writeCallback); ReadEOFCallback readCallback(&writeCallback);
HandshakeCallback handshakeCallback(&readCallback); HandshakeCallback handshakeCallback(&readCallback);
SSLServerAcceptCallback acceptCallback(&handshakeCallback); SSLServerAcceptCallback acceptCallback(&handshakeCallback);
auto server = folly::make_unique<TestSSLServer>(&acceptCallback); auto server = std::make_unique<TestSSLServer>(&acceptCallback);
// Set up SSL context. // Set up SSL context.
auto sslContext = std::make_shared<SSLContext>(); auto sslContext = std::make_shared<SSLContext>();
...@@ -402,8 +402,8 @@ class NextProtocolTest : public testing::TestWithParam<NextProtocolTypePair> { ...@@ -402,8 +402,8 @@ class NextProtocolTest : public testing::TestWithParam<NextProtocolTypePair> {
new AsyncSSLSocket(clientCtx, &eventBase, fds[0], false)); new AsyncSSLSocket(clientCtx, &eventBase, fds[0], false));
AsyncSSLSocket::UniquePtr serverSock( AsyncSSLSocket::UniquePtr serverSock(
new AsyncSSLSocket(serverCtx, &eventBase, fds[1], true)); new AsyncSSLSocket(serverCtx, &eventBase, fds[1], true));
client = folly::make_unique<NpnClient>(std::move(clientSock)); client = std::make_unique<NpnClient>(std::move(clientSock));
server = folly::make_unique<NpnServer>(std::move(serverSock)); server = std::make_unique<NpnServer>(std::move(serverSock));
eventBase.loop(); eventBase.loop();
} }
......
...@@ -2806,7 +2806,7 @@ class MockEvbChangeCallback : public AsyncSocket::EvbChangeCallback { ...@@ -2806,7 +2806,7 @@ class MockEvbChangeCallback : public AsyncSocket::EvbChangeCallback {
}; };
TEST(AsyncSocketTest, EvbCallbacks) { TEST(AsyncSocketTest, EvbCallbacks) {
auto cb = folly::make_unique<MockEvbChangeCallback>(); auto cb = std::make_unique<MockEvbChangeCallback>();
EventBase evb; EventBase evb;
std::shared_ptr<AsyncSocket> socket = AsyncSocket::newSocket(&evb); std::shared_ptr<AsyncSocket> socket = AsyncSocket::newSocket(&evb);
......
...@@ -85,9 +85,7 @@ class UDPServer { ...@@ -85,9 +85,7 @@ class UDPServer {
void start() { void start() {
CHECK(evb_->isInEventBaseThread()); CHECK(evb_->isInEventBaseThread());
socket_ = folly::make_unique<AsyncUDPServerSocket>( socket_ = std::make_unique<AsyncUDPServerSocket>(evb_, 1500);
evb_,
1500);
try { try {
socket_->bind(addr_); socket_->bind(addr_);
...@@ -159,7 +157,7 @@ class UDPClient ...@@ -159,7 +157,7 @@ class UDPClient
CHECK(evb_->isInEventBaseThread()); CHECK(evb_->isInEventBaseThread());
server_ = server; server_ = server;
socket_ = folly::make_unique<AsyncUDPSocket>(evb_); socket_ = std::make_unique<AsyncUDPSocket>(evb_);
try { try {
socket_->bind(folly::SocketAddress("127.0.0.1", 0)); socket_->bind(folly::SocketAddress("127.0.0.1", 0));
......
...@@ -1789,7 +1789,7 @@ TEST(EventBaseTest, LoopKeepAliveInLoop) { ...@@ -1789,7 +1789,7 @@ TEST(EventBaseTest, LoopKeepAliveInLoop) {
} }
TEST(EventBaseTest, LoopKeepAliveWithLoopForever) { TEST(EventBaseTest, LoopKeepAliveWithLoopForever) {
std::unique_ptr<EventBase> evb = folly::make_unique<EventBase>(); std::unique_ptr<EventBase> evb = std::make_unique<EventBase>();
bool done = false; bool done = false;
...@@ -1817,7 +1817,7 @@ TEST(EventBaseTest, LoopKeepAliveWithLoopForever) { ...@@ -1817,7 +1817,7 @@ TEST(EventBaseTest, LoopKeepAliveWithLoopForever) {
} }
TEST(EventBaseTest, LoopKeepAliveShutdown) { TEST(EventBaseTest, LoopKeepAliveShutdown) {
auto evb = folly::make_unique<EventBase>(); auto evb = std::make_unique<EventBase>();
bool done = false; bool done = false;
...@@ -1840,7 +1840,7 @@ TEST(EventBaseTest, LoopKeepAliveShutdown) { ...@@ -1840,7 +1840,7 @@ TEST(EventBaseTest, LoopKeepAliveShutdown) {
} }
TEST(EventBaseTest, LoopKeepAliveAtomic) { TEST(EventBaseTest, LoopKeepAliveAtomic) {
auto evb = folly::make_unique<EventBase>(); auto evb = std::make_unique<EventBase>();
static constexpr size_t kNumThreads = 100; static constexpr size_t kNumThreads = 100;
static constexpr size_t kNumTasks = 100; static constexpr size_t kNumTasks = 100;
...@@ -1850,7 +1850,7 @@ TEST(EventBaseTest, LoopKeepAliveAtomic) { ...@@ -1850,7 +1850,7 @@ TEST(EventBaseTest, LoopKeepAliveAtomic) {
size_t done{0}; size_t done{0};
for (size_t i = 0; i < kNumThreads; ++i) { for (size_t i = 0; i < kNumThreads; ++i) {
batons.emplace_back(folly::make_unique<Baton<>>()); batons.emplace_back(std::make_unique<Baton<>>());
} }
for (size_t i = 0; i < kNumThreads; ++i) { for (size_t i = 0; i < kNumThreads; ++i) {
......
...@@ -56,8 +56,7 @@ TEST(RequestContext, SimpleTest) { ...@@ -56,8 +56,7 @@ TEST(RequestContext, SimpleTest) {
EXPECT_EQ(nullptr, RequestContext::get()->getContextData("test")); EXPECT_EQ(nullptr, RequestContext::get()->getContextData("test"));
RequestContext::get()->setContextData( RequestContext::get()->setContextData("test", std::make_unique<TestData>(10));
"test", folly::make_unique<TestData>(10));
base.runInEventBaseThread([&](){ base.runInEventBaseThread([&](){
EXPECT_TRUE(RequestContext::get() != nullptr); EXPECT_TRUE(RequestContext::get() != nullptr);
auto data = dynamic_cast<TestData*>( auto data = dynamic_cast<TestData*>(
...@@ -83,16 +82,15 @@ TEST(RequestContext, SimpleTest) { ...@@ -83,16 +82,15 @@ TEST(RequestContext, SimpleTest) {
TEST(RequestContext, setIfAbsentTest) { TEST(RequestContext, setIfAbsentTest) {
EXPECT_TRUE(RequestContext::get() != nullptr); EXPECT_TRUE(RequestContext::get() != nullptr);
RequestContext::get()->setContextData( RequestContext::get()->setContextData("test", std::make_unique<TestData>(10));
"test", folly::make_unique<TestData>(10));
EXPECT_FALSE(RequestContext::get()->setContextDataIfAbsent( EXPECT_FALSE(RequestContext::get()->setContextDataIfAbsent(
"test", folly::make_unique<TestData>(20))); "test", std::make_unique<TestData>(20)));
EXPECT_EQ(10, EXPECT_EQ(10,
dynamic_cast<TestData*>( dynamic_cast<TestData*>(
RequestContext::get()->getContextData("test"))->data_); RequestContext::get()->getContextData("test"))->data_);
EXPECT_TRUE(RequestContext::get()->setContextDataIfAbsent( EXPECT_TRUE(RequestContext::get()->setContextDataIfAbsent(
"test2", folly::make_unique<TestData>(20))); "test2", std::make_unique<TestData>(20)));
EXPECT_EQ(20, EXPECT_EQ(20,
dynamic_cast<TestData*>( dynamic_cast<TestData*>(
RequestContext::get()->getContextData("test2"))->data_); RequestContext::get()->getContextData("test2"))->data_);
...@@ -104,13 +102,13 @@ TEST(RequestContext, setIfAbsentTest) { ...@@ -104,13 +102,13 @@ TEST(RequestContext, setIfAbsentTest) {
TEST(RequestContext, testSetUnset) { TEST(RequestContext, testSetUnset) {
RequestContext::create(); RequestContext::create();
auto ctx1 = RequestContext::saveContext(); auto ctx1 = RequestContext::saveContext();
ctx1->setContextData("test", folly::make_unique<TestData>(10)); ctx1->setContextData("test", std::make_unique<TestData>(10));
auto testData1 = dynamic_cast<TestData*>(ctx1->getContextData("test")); auto testData1 = dynamic_cast<TestData*>(ctx1->getContextData("test"));
// Override RequestContext // Override RequestContext
RequestContext::create(); RequestContext::create();
auto ctx2 = RequestContext::saveContext(); auto ctx2 = RequestContext::saveContext();
ctx2->setContextData("test", folly::make_unique<TestData>(20)); ctx2->setContextData("test", std::make_unique<TestData>(20));
auto testData2 = dynamic_cast<TestData*>(ctx2->getContextData("test")); auto testData2 = dynamic_cast<TestData*>(ctx2->getContextData("test"));
// Check ctx1->onUnset was called // Check ctx1->onUnset was called
...@@ -137,7 +135,7 @@ TEST(RequestContext, deadlockTest) { ...@@ -137,7 +135,7 @@ TEST(RequestContext, deadlockTest) {
virtual ~DeadlockTestData() { virtual ~DeadlockTestData() {
RequestContext::get()->setContextData( RequestContext::get()->setContextData(
val_, folly::make_unique<TestData>(1)); val_, std::make_unique<TestData>(1));
} }
void onSet() override {} void onSet() override {}
...@@ -148,6 +146,6 @@ TEST(RequestContext, deadlockTest) { ...@@ -148,6 +146,6 @@ TEST(RequestContext, deadlockTest) {
}; };
RequestContext::get()->setContextData( RequestContext::get()->setContextData(
"test", folly::make_unique<DeadlockTestData>("test2")); "test", std::make_unique<DeadlockTestData>("test2"));
RequestContext::get()->clearContextData("test"); RequestContext::get()->clearContextData("test");
} }
...@@ -138,7 +138,7 @@ TEST_F(SSLSessionTest, SerializeDeserializeTest) { ...@@ -138,7 +138,7 @@ TEST_F(SSLSessionTest, SerializeDeserializeTest) {
ASSERT_TRUE(client.handshakeSuccess_); ASSERT_TRUE(client.handshakeSuccess_);
std::unique_ptr<SSLSession> sess = std::unique_ptr<SSLSession> sess =
folly::make_unique<SSLSession>(clientPtr->getSSLSession()); std::make_unique<SSLSession>(clientPtr->getSSLSession());
sessiondata = sess->serialize(); sessiondata = sess->serialize();
ASSERT_TRUE(!sessiondata.empty()); ASSERT_TRUE(!sessiondata.empty());
} }
...@@ -150,7 +150,7 @@ TEST_F(SSLSessionTest, SerializeDeserializeTest) { ...@@ -150,7 +150,7 @@ TEST_F(SSLSessionTest, SerializeDeserializeTest) {
new AsyncSSLSocket(clientCtx, &eventBase, fds[0], serverName)); new AsyncSSLSocket(clientCtx, &eventBase, fds[0], serverName));
auto clientPtr = clientSock.get(); auto clientPtr = clientSock.get();
std::unique_ptr<SSLSession> sess = std::unique_ptr<SSLSession> sess =
folly::make_unique<SSLSession>(sessiondata); std::make_unique<SSLSession>(sessiondata);
ASSERT_NE(sess.get(), nullptr); ASSERT_NE(sess.get(), nullptr);
clientSock->setSSLSession(sess->getRawSSLSessionDangerous(), true); clientSock->setSSLSession(sess->getRawSSLSessionDangerous(), true);
AsyncSSLSocket::UniquePtr serverSock( AsyncSSLSocket::UniquePtr serverSock(
...@@ -181,7 +181,7 @@ TEST_F(SSLSessionTest, GetSessionID) { ...@@ -181,7 +181,7 @@ TEST_F(SSLSessionTest, GetSessionID) {
ASSERT_TRUE(client.handshakeSuccess_); ASSERT_TRUE(client.handshakeSuccess_);
std::unique_ptr<SSLSession> sess = std::unique_ptr<SSLSession> sess =
folly::make_unique<SSLSession>(clientPtr->getSSLSession()); std::make_unique<SSLSession>(clientPtr->getSSLSession());
ASSERT_NE(sess, nullptr); ASSERT_NE(sess, nullptr);
auto sessID = sess->getSessionID(); auto sessID = sess->getSessionID();
ASSERT_GE(sessID.length(), 0); ASSERT_GE(sessID.length(), 0);
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
namespace folly { namespace folly {
ScopedBoundPort::ScopedBoundPort(IPAddress host) { ScopedBoundPort::ScopedBoundPort(IPAddress host) {
ebth_ = folly::make_unique<ScopedEventBaseThread>(); ebth_ = std::make_unique<ScopedEventBaseThread>();
ebth_->getEventBase()->runInEventBaseThreadAndWait([&] { ebth_->getEventBase()->runInEventBaseThreadAndWait([&] {
sock_ = AsyncServerSocket::newSocket(ebth_->getEventBase()); sock_ = AsyncServerSocket::newSocket(ebth_->getEventBase());
sock_->bind(SocketAddress(host, 0)); sock_->bind(SocketAddress(host, 0));
......
...@@ -27,13 +27,12 @@ class SSLSession { ...@@ -27,13 +27,12 @@ class SSLSession {
public: public:
// Holds and takes ownership of an SSL_SESSION object by incrementing refcount // Holds and takes ownership of an SSL_SESSION object by incrementing refcount
explicit SSLSession(SSL_SESSION* session, bool takeOwnership = true) explicit SSLSession(SSL_SESSION* session, bool takeOwnership = true)
: impl_(folly::make_unique<detail::SSLSessionImpl>( : impl_(
session, std::make_unique<detail::SSLSessionImpl>(session, takeOwnership)) {}
takeOwnership)) {}
// Deserialize from a string // Deserialize from a string
explicit SSLSession(const std::string& serializedSession) explicit SSLSession(const std::string& serializedSession)
: impl_(folly::make_unique<detail::SSLSessionImpl>(serializedSession)) {} : impl_(std::make_unique<detail::SSLSessionImpl>(serializedSession)) {}
// Serialize to a string that is suitable to store in a persistent cache // Serialize to a string that is suitable to store in a persistent cache
std::string serialize() const { std::string serialize() const {
......
...@@ -33,7 +33,7 @@ struct MyObject { ...@@ -33,7 +33,7 @@ struct MyObject {
typedef folly::AtomicHashMap<int,std::shared_ptr<MyObject>> MyMap; typedef folly::AtomicHashMap<int,std::shared_ptr<MyObject>> MyMap;
typedef std::lock_guard<std::mutex> Guard; typedef std::lock_guard<std::mutex> Guard;
std::unique_ptr<MyMap> newMap() { return folly::make_unique<MyMap>(100); } std::unique_ptr<MyMap> newMap() { return std::make_unique<MyMap>(100); }
struct MyObjectDirectory { struct MyObjectDirectory {
MyObjectDirectory() MyObjectDirectory()
......
...@@ -313,7 +313,7 @@ TEST(Function, Bind) { ...@@ -313,7 +313,7 @@ TEST(Function, Bind) {
// NonCopyableLambda // NonCopyableLambda
TEST(Function, NonCopyableLambda) { TEST(Function, NonCopyableLambda) {
auto unique_ptr_int = folly::make_unique<int>(900); auto unique_ptr_int = std::make_unique<int>(900);
EXPECT_EQ(900, *unique_ptr_int); EXPECT_EQ(900, *unique_ptr_int);
struct { struct {
......
...@@ -149,7 +149,7 @@ TEST(MPMCQueue, lots_of_element_types) { ...@@ -149,7 +149,7 @@ TEST(MPMCQueue, lots_of_element_types) {
runElementTypeTest(std::make_pair(10, string("def"))); runElementTypeTest(std::make_pair(10, string("def")));
runElementTypeTest(vector<string>{{"abc"}}); runElementTypeTest(vector<string>{{"abc"}});
runElementTypeTest(std::make_shared<char>('a')); runElementTypeTest(std::make_shared<char>('a'));
runElementTypeTest(folly::make_unique<char>('a')); runElementTypeTest(std::make_unique<char>('a'));
runElementTypeTest(boost::intrusive_ptr<RefCounted>(new RefCounted)); runElementTypeTest(boost::intrusive_ptr<RefCounted>(new RefCounted));
EXPECT_EQ(RefCounted::active_instances, 0); EXPECT_EQ(RefCounted::active_instances, 0);
} }
...@@ -160,7 +160,7 @@ TEST(MPMCQueue, lots_of_element_types_dynamic) { ...@@ -160,7 +160,7 @@ TEST(MPMCQueue, lots_of_element_types_dynamic) {
runElementTypeTest<true>(std::make_pair(10, string("def"))); runElementTypeTest<true>(std::make_pair(10, string("def")));
runElementTypeTest<true>(vector<string>{{"abc"}}); runElementTypeTest<true>(vector<string>{{"abc"}});
runElementTypeTest<true>(std::make_shared<char>('a')); runElementTypeTest<true>(std::make_shared<char>('a'));
runElementTypeTest<true>(folly::make_unique<char>('a')); runElementTypeTest<true>(std::make_unique<char>('a'));
runElementTypeTest<true>(boost::intrusive_ptr<RefCounted>(new RefCounted)); runElementTypeTest<true>(boost::intrusive_ptr<RefCounted>(new RefCounted));
EXPECT_EQ(RefCounted::active_instances, 0); EXPECT_EQ(RefCounted::active_instances, 0);
} }
......
...@@ -103,7 +103,7 @@ TEST(ThreadLocalPtr, DefaultDeleterOwnershipTransfer) { ...@@ -103,7 +103,7 @@ TEST(ThreadLocalPtr, DefaultDeleterOwnershipTransfer) {
Widget::totalVal_ = 0; Widget::totalVal_ = 0;
{ {
ThreadLocalPtr<Widget> w; ThreadLocalPtr<Widget> w;
auto source = folly::make_unique<Widget>(); auto source = std::make_unique<Widget>();
std::thread([&w, &source]() { std::thread([&w, &source]() {
w.reset(std::move(source)); w.reset(std::move(source));
w.get()->val_ += 10; w.get()->val_ += 10;
......
...@@ -55,7 +55,7 @@ TEST(Try, moveOnly) { ...@@ -55,7 +55,7 @@ TEST(Try, moveOnly) {
TEST(Try, makeTryWith) { TEST(Try, makeTryWith) {
auto func = []() { auto func = []() {
return folly::make_unique<int>(1); return std::make_unique<int>(1);
}; };
auto result = makeTryWith(func); auto result = makeTryWith(func);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment