diff --git a/include/gsl/gsl_util b/include/gsl/gsl_util index 0fce689..e4b2daa 100644 --- a/include/gsl/gsl_util +++ b/include/gsl/gsl_util @@ -24,7 +24,7 @@ #include // for exception #include // for initializer_list #include // for is_signed, integral_constant -#include // for forward +#include // for exchange, forward #if defined(_MSC_VER) && !defined(__clang__) @@ -59,10 +59,7 @@ class final_action public: explicit final_action(F f) noexcept : f_(std::move(f)) {} - final_action(final_action&& other) noexcept : f_(std::move(other.f_)), invoke_(other.invoke_) - { - other.invoke_ = false; - } + final_action(final_action&& other) noexcept : f_(std::move(other.f_)), invoke_(std::exchange(other.invoke_, false)) {} final_action(const final_action&) = delete; final_action& operator=(const final_action&) = delete;