X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=folly%2FTry-inl.h;h=e6e4c415187b1012bc02fc7bf6d6e9eeb9c84a0a;hb=a4a7fad40c50b9a63b0fe2e67ea62207ebe76f88;hp=522e77b984450604b40a77fb0d4602b4cdd4c20a;hpb=ed8c80a0e0988e4ce687f51ca832a00e4a6b7930;p=folly.git diff --git a/folly/Try-inl.h b/folly/Try-inl.h index 522e77b9..e6e4c415 100644 --- a/folly/Try-inl.h +++ b/folly/Try-inl.h @@ -26,7 +26,7 @@ Try::Try(Try&& t) noexcept : contains_(t.contains_) { if (contains_ == Contains::VALUE) { new (&value_)T(std::move(t.value_)); } else if (contains_ == Contains::EXCEPTION) { - new (&e_)std::unique_ptr(std::move(t.e_)); + new (&e_) exception_wrapper(std::move(t.e_)); } } @@ -40,8 +40,7 @@ Try::Try(typename std::enable_if::value, new (&value_) T(); } else if (t.hasException()) { contains_ = Contains::EXCEPTION; - new (&e_) std::unique_ptr( - folly::make_unique(t.exception())); + new (&e_) exception_wrapper(t.exception()); } } @@ -56,7 +55,7 @@ Try& Try::operator=(Try&& t) noexcept { if (contains_ == Contains::VALUE) { new (&value_)T(std::move(t.value_)); } else if (contains_ == Contains::EXCEPTION) { - new (&e_)std::unique_ptr(std::move(t.e_)); + new (&e_) exception_wrapper(std::move(t.e_)); } return *this; } @@ -70,8 +69,7 @@ Try::Try(const Try& t) { if (contains_ == Contains::VALUE) { new (&value_)T(t.value_); } else if (contains_ == Contains::EXCEPTION) { - new (&e_)std::unique_ptr(); - e_ = folly::make_unique(*(t.e_)); + new (&e_) exception_wrapper(t.e_); } } @@ -85,8 +83,7 @@ Try& Try::operator=(const Try& t) { if (contains_ == Contains::VALUE) { new (&value_)T(t.value_); } else if (contains_ == Contains::EXCEPTION) { - new (&e_)std::unique_ptr(); - e_ = folly::make_unique(*(t.e_)); + new (&e_) exception_wrapper(t.e_); } return *this; } @@ -96,7 +93,7 @@ Try::~Try() { if (LIKELY(contains_ == Contains::VALUE)) { value_.~T(); } else if (UNLIKELY(contains_ == Contains::EXCEPTION)) { - e_.~unique_ptr(); + e_.~exception_wrapper(); } } @@ -122,7 +119,7 @@ template void Try::throwIfFailed() const { if (contains_ != Contains::VALUE) { if (contains_ == Contains::EXCEPTION) { - e_->throwException(); + e_.throw_exception(); } else { throw UsingUninitializedTry(); } @@ -131,7 +128,7 @@ void Try::throwIfFailed() const { void Try::throwIfFailed() const { if (!hasValue_) { - e_->throwException(); + e_.throw_exception(); } }