aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJordan Maples [MSFT] <49793787+JordanMaples@users.noreply.github.com>2019-10-09 15:05:26 -0700
committerGitHub <noreply@github.com>2019-10-09 15:05:26 -0700
commitcf9cc34da84c92d0a60ab5813722a5c554052a1a (patch)
tree531c373c8829e4e850e4cc5780ad450efe3d7d04
parent02d1051fddbb9a1d43b61c2970ec383a65ca58f4 (diff)
parent0a78d8ea3c7dbb29a39f6cb2ae98710058f5b3a2 (diff)
downloadplatform_external_Microsoft-GSL-cf9cc34da84c92d0a60ab5813722a5c554052a1a.tar.gz
platform_external_Microsoft-GSL-cf9cc34da84c92d0a60ab5813722a5c554052a1a.tar.bz2
platform_external_Microsoft-GSL-cf9cc34da84c92d0a60ab5813722a5c554052a1a.zip
Merge pull request #815 from matt77hias/patch-1
Added std::exchange (C++14) to make the intent more explicit
-rw-r--r--include/gsl/gsl_util7
1 files changed, 2 insertions, 5 deletions
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 <exception> // for exception
#include <initializer_list> // for initializer_list
#include <type_traits> // for is_signed, integral_constant
-#include <utility> // for forward
+#include <utility> // 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;