blob: 63bc31dc3170644b0100e27bbeff171bbd2bde83 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#ifndef _INC_FUNCTION_HPP__
#define _INC_FUNCTION_HPP__
#include <NewKit/Defines.hpp>
namespace NewOS {
template <typename T, typename... Args>
class Function final {
public:
Function() = default;
public:
explicit Function(T (*Fn)(Args... args)) : m_Fn(Fn) {}
~Function() = default;
Function &operator=(const Function &) = default;
Function(const Function &) = default;
template <typename... XArgs>
T operator()(Args... args) {
return m_Fn(args...);
}
template <typename... XArgs>
T Call(Args... args) {
return m_Fn(args...);
}
operator bool() { return m_Fn; }
bool operator!() { return !m_Fn; }
private:
T (*m_Fn)(Args... args);
};
} // namespace NewOS
#endif // !_INC_FUNCTION_HPP__
|