From 352f73df925f037b24d3f34446fd272b4305a330 Mon Sep 17 00:00:00 2001 From: Herb Sutter Date: Wed, 31 Aug 2022 16:24:05 -0700 Subject: [PATCH] Applying Casey's an Dmitry's changes... --- include/gsl/util | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/include/gsl/util b/include/gsl/util index 9bfcfc1..4d2f5cf 100644 --- a/include/gsl/util +++ b/include/gsl/util @@ -52,8 +52,8 @@ template class final_action { public: - template - explicit final_action(FF&& ff) noexcept : f{std::forward(ff)} { } + explicit final_action(const F& ff) noexcept : f{ff} { } + explicit final_action(F&& ff) noexcept : f{std::move(ff)} { } ~final_action() noexcept { if (invoke) f(); } @@ -61,9 +61,9 @@ public: : f(std::move(other.f)), invoke(std::exchange(other.invoke, false)) { } - final_action(const final_action& rhs) = delete; - void operator=(const final_action&) = delete; - void operator=(final_action&& other) = delete; + final_action(const final_action&) = delete; + void operator=(const final_action&) = delete; + void operator=(final_action&&) = delete; private: F f; @@ -72,9 +72,9 @@ private: // finally() - convenience function to generate a final_action template -[[nodiscard]] auto finally(F&& f) noexcept +GSL_NODISCARD auto finally(F&& f) noexcept { - return final_action{std::forward(f)}; + return final_action>{std::forward(f)}; } // narrow_cast(): a searchable way to do narrowing casts of values