uvco 0.1
Loading...
Searching...
No Matches
util.h
Go to the documentation of this file.
1// uvco (c) 2025 Lewin Bormann. See LICENSE for specific terms.
2
3#pragma once
4
5#include <functional>
6
7namespace uvco {
8
12
13class OnExit {
14public:
15 explicit OnExit(std::function<void()> &&func) : func_{std::move(func)} {}
16
18 if (func_) {
19 func_();
20 }
21 }
22
23 // Pin in place
24 OnExit(const OnExit &) = delete;
25 OnExit(OnExit &&) = delete;
26 OnExit &operator=(const OnExit &) = delete;
27 OnExit &operator=(OnExit &&) = delete;
28
29private:
30 std::function<void()> func_;
31};
32
34
35} // namespace uvco
OnExit(std::function< void()> &&func)
Definition util.h:15
OnExit(OnExit &&)=delete
OnExit & operator=(const OnExit &)=delete
OnExit(const OnExit &)=delete
std::function< void()> func_
Definition util.h:30
OnExit & operator=(OnExit &&)=delete
~OnExit()
Definition util.h:17
Definition async_work.cc:18