mirror of
https://github.com/microsoft/GSL.git
synced 2024-11-03 17:56:43 -05:00
Fixing move constructor of Final_act to take non-const r-value reference and move properly from other Final_act object so that correctness is not dependent on copy elison.
This commit is contained in:
parent
065f4880c3
commit
422e7164d5
@ -50,16 +50,17 @@ template <class F>
|
||||
class Final_act
|
||||
{
|
||||
public:
|
||||
explicit Final_act(F f) : f_(std::move(f)) {}
|
||||
explicit Final_act(F f) : f_(std::move(f)), invoke_(true) {}
|
||||
|
||||
Final_act(const Final_act&& other) : f_(other.f_) {}
|
||||
Final_act(Final_act&& other) : f_(std::move(other.f_)), invoke_(true) { other._invoke = false; }
|
||||
Final_act(const Final_act&) = delete;
|
||||
Final_act& operator=(const Final_act&) = delete;
|
||||
|
||||
~Final_act() { f_(); }
|
||||
~Final_act() { if (invoke_) f_(); }
|
||||
|
||||
private:
|
||||
F f_;
|
||||
bool invoke_;
|
||||
};
|
||||
|
||||
// finally() - convenience function to generate a Final_act
|
||||
|
Loading…
Reference in New Issue
Block a user