Botcraft 1.21.4
Loading...
Searching...
No Matches
MiscUtilities.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <functional>
4
6{
7 /// @brief A class to execute a callback when destroyed
9 {
10 public:
11 OnEndScope(const std::function<void()>& f = []() {}) : callback(f) {}
13
14 // No copy
15 OnEndScope(const OnEndScope& other) = delete;
16 OnEndScope(OnEndScope&& other) = delete;
17 OnEndScope& operator=(const OnEndScope& other) = delete;
18
19 private:
20 std::function<void()> callback;
21 };
22}
A class to execute a callback when destroyed.
OnEndScope(const std::function< void()> &f=[]() {})
OnEndScope(OnEndScope &&other)=delete
std::function< void()> callback
OnEndScope(const OnEndScope &other)=delete
OnEndScope & operator=(const OnEndScope &other)=delete