25template <
typename Callback>
 
   26class FastScopeGuard final {
 
   28  static_assert(std::is_nothrow_move_constructible_v<Callback>);
 
   31      std::is_nothrow_invocable_v<Callback&&>,
 
   32      "If the functions called in the body of the lambda are all 'noexcept', " 
   33      "please mark the lambda itself as 'noexcept'. If however, the contents " 
   34      "are not 'noexcept', use 'ScopeGuard' instead of 'FastScopeGuard'.");
 
   36  static_assert(std::is_void_v<std::invoke_result_t<Callback&&>>,
 
   37                "Return type of Callback function should be void");
 
   39  static_assert(std::is_nothrow_destructible_v<Callback>,
 
   40                "Callback function destructor should be noexcept");
 
   42  constexpr explicit FastScopeGuard(Callback callback) 
noexcept 
   43      : callback_(std::move(callback)) {}
 
   45  constexpr FastScopeGuard(FastScopeGuard&& other) 
noexcept 
   46      : callback_(std::move(other.callback_)),
 
   47        is_active_(std::exchange(other.is_active_, 
false)) {}
 
   49  constexpr FastScopeGuard& operator=(FastScopeGuard&& other) 
noexcept {
 
   51      callback_ = std::move(other.callback_);
 
   52      is_active_ = std::exchange(other.is_active_, 
false);
 
   58    if (is_active_) std::move(callback_)();
 
   61  constexpr void Release() 
noexcept { is_active_ = 
false; }
 
   67  bool is_active_{
true};