Merge pull request #815 from matt77hias/patch-1

Added std::exchange (C++14) to make the intent more explicit
This commit is contained in:
Jordan Maples [MSFT] 2019-10-09 15:05:26 -07:00 committed by GitHub
commit cf9cc34da8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -24,7 +24,7 @@
#include <exception> // for exception #include <exception> // for exception
#include <initializer_list> // for initializer_list #include <initializer_list> // for initializer_list
#include <type_traits> // for is_signed, integral_constant #include <type_traits> // for is_signed, integral_constant
#include <utility> // for forward #include <utility> // for exchange, forward
#if defined(_MSC_VER) && !defined(__clang__) #if defined(_MSC_VER) && !defined(__clang__)
@ -59,10 +59,7 @@ class final_action
public: public:
explicit final_action(F f) noexcept : f_(std::move(f)) {} explicit final_action(F f) noexcept : f_(std::move(f)) {}
final_action(final_action&& other) noexcept : f_(std::move(other.f_)), invoke_(other.invoke_) final_action(final_action&& other) noexcept : f_(std::move(other.f_)), invoke_(std::exchange(other.invoke_, false)) {}
{
other.invoke_ = false;
}
final_action(const final_action&) = delete; final_action(const final_action&) = delete;
final_action& operator=(const final_action&) = delete; final_action& operator=(const final_action&) = delete;