Commit 5e32096c authored by Hannes Roth's avatar Hannes Roth Committed by Alecs King

Revert: (Wangle) Clean up move constructors

Summary:
This reverts commit 1e407b48d379a41f32e7a980285dbdf4dadb2e33.

Test Plan: revert-hammer

Reviewed By: yitingli@fb.com

Subscribers: folly-diffs@, jsedgwick, yfeldblum

FB internal diff: D1858994

Signature: t1:1858994:1424386588:5c4608ecbe1f9ab1108ac12e506b157b54d0078b
parent 0fd618d4
...@@ -32,14 +32,13 @@ namespace detail { ...@@ -32,14 +32,13 @@ namespace detail {
} }
template <class T> template <class T>
Future<T>::Future(Future<T>&& other) noexcept : core_(other.core_) { Future<T>::Future(Future<T>&& other) noexcept : core_(nullptr) {
other.core_ = nullptr; *this = std::move(other);
} }
template <class T> template <class T>
Future<T>& Future<T>::operator=(Future<T>&& other) noexcept { Future<T>& Future<T>::operator=(Future<T>&& other) {
core_ = other.core_; std::swap(core_, other.core_);
other.core_ = nullptr;
return *this; return *this;
} }
......
...@@ -192,7 +192,7 @@ class Future { ...@@ -192,7 +192,7 @@ class Future {
// movable // movable
Future(Future&&) noexcept; Future(Future&&) noexcept;
Future& operator=(Future&&) noexcept; Future& operator=(Future&&);
// makeFuture // makeFuture
template <class F = T> template <class F = T>
......
...@@ -29,16 +29,14 @@ Promise<T>::Promise() : retrieved_(false), core_(new detail::Core<T>()) ...@@ -29,16 +29,14 @@ Promise<T>::Promise() : retrieved_(false), core_(new detail::Core<T>())
{} {}
template <class T> template <class T>
Promise<T>::Promise(Promise<T>&& other) noexcept Promise<T>::Promise(Promise<T>&& other) : core_(nullptr) {
: retrieved_(other.retrieved_), core_(other.core_) { *this = std::move(other);
other.core_ = nullptr;
} }
template <class T> template <class T>
Promise<T>& Promise<T>::operator=(Promise<T>&& other) noexcept { Promise<T>& Promise<T>::operator=(Promise<T>&& other) {
retrieved_ = other.retrieved_; std::swap(core_, other.core_);
core_ = other.core_; std::swap(retrieved_, other.retrieved_);
other.core_ = nullptr;
return *this; return *this;
} }
......
...@@ -36,8 +36,8 @@ public: ...@@ -36,8 +36,8 @@ public:
Promise& operator=(Promise const&) = delete; Promise& operator=(Promise const&) = delete;
// movable // movable
Promise(Promise<T>&&) noexcept; Promise(Promise<T>&&);
Promise& operator=(Promise<T>&&) noexcept; Promise& operator=(Promise<T>&&);
/** Return a Future tied to the shared core state. This can be called only /** Return a Future tied to the shared core state. This can be called only
once, thereafter Future already retrieved exception will be raised. */ once, thereafter Future already retrieved exception will be raised. */
......
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