}
template <class T>
-Future<T>::Future(Future<T>&& other) noexcept : core_(nullptr) {
- *this = std::move(other);
+Future<T>::Future(Future<T>&& other) noexcept : core_(other.core_) {
+ other.core_ = nullptr;
}
template <class T>
-Future<T>& Future<T>::operator=(Future<T>&& other) {
+Future<T>& Future<T>::operator=(Future<T>&& other) noexcept {
std::swap(core_, other.core_);
return *this;
}
// movable
Future(Future&&) noexcept;
- Future& operator=(Future&&);
+ Future& operator=(Future&&) noexcept;
// makeFuture
template <class F = T>
{}
template <class T>
-Promise<T>::Promise(Promise<T>&& other) : core_(nullptr) {
- *this = std::move(other);
+Promise<T>::Promise(Promise<T>&& other) noexcept
+ : retrieved_(other.retrieved_), core_(other.core_) {
+ other.core_ = nullptr;
+ other.retrieved_ = false;
}
template <class T>
-Promise<T>& Promise<T>::operator=(Promise<T>&& other) {
+Promise<T>& Promise<T>::operator=(Promise<T>&& other) noexcept {
std::swap(core_, other.core_);
std::swap(retrieved_, other.retrieved_);
return *this;
Promise& operator=(Promise const&) = delete;
// movable
- Promise(Promise<T>&&);
- Promise& operator=(Promise<T>&&);
+ Promise(Promise<T>&&) noexcept;
+ Promise& operator=(Promise<T>&&) noexcept;
/** Return a Future tied to the shared core state. This can be called only
once, thereafter Future already retrieved exception will be raised. */