mirror of
https://github.com/microsoft/GSL.git
synced 2024-11-03 17:56:43 -05:00
Merge pull request #815 from matt77hias/patch-1
Added std::exchange (C++14) to make the intent more explicit
This commit is contained in:
commit
cf9cc34da8
@ -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;
|
||||||
|
Loading…
Reference in New Issue
Block a user