GitWatcherBot 1.0.0
A Telegram Bot that notifies you when a new change is made in your repositories (issues, pull requests, stars, forks, and watches)
Loading...
Searching...
No Matches
FinalAction.hpp
Go to the documentation of this file.
1#pragma once
2#include <utility>
3
6template <class F>
8{
9public:
10 explicit FinalAction(const F& ff) noexcept : f{ff} { }
11 explicit FinalAction(F&& ff) noexcept : f{std::move(ff)} { }
12
13 ~FinalAction() noexcept { if (invoke) f(); }
14
15 FinalAction(FinalAction&& other) noexcept
16 : f(std::move(other.f)), invoke(std::exchange(other.invoke, false))
17 { }
18
19 FinalAction(const FinalAction&) = delete;
20 void operator=(const FinalAction&) = delete;
21 void operator=(FinalAction&&) = delete;
22
23private:
24 F f;
25 bool invoke = true;
26};
Executes a function at the end of the scope (deferred) using RAII gsl libs.
void operator=(const FinalAction &)=delete
FinalAction(const F &ff) noexcept
FinalAction(F &&ff) noexcept
FinalAction(const FinalAction &)=delete
~FinalAction() noexcept
void operator=(FinalAction &&)=delete
FinalAction(FinalAction &&other) noexcept