Refureku v2.2.0
C++17 runtime reflection library.
MemberFunction.h
1
8#pragma once
9
10#include <utility> //std::forward
11#include <cassert>
12
13#include "Refureku/TypeInfo/Functions/ICallable.h"
14
15namespace rfk
16{
17 template <typename CallerType, typename FunctionPrototype>
19
20 template <typename CallerType, typename ReturnType, typename... ArgTypes>
21 class MemberFunction<CallerType, ReturnType(ArgTypes...)> : public ICallable
22 {
23 private:
24 using FunctionPrototype = ReturnType (CallerType::*)(ArgTypes...);
25 using ConstFunctionPrototype = ReturnType (CallerType::*)(ArgTypes...) const;
26
27#if (defined(_WIN32) || defined(_WIN64))
28 std::size_t _originalFunctionSize = 0u;
29#endif
30
32 union
33 {
34 FunctionPrototype _function = nullptr;
35 ConstFunctionPrototype _constFunction;
36 };
37
39 bool _isConst;
40
41 public:
42 MemberFunction(FunctionPrototype function) noexcept;
43 MemberFunction(ConstFunctionPrototype function) noexcept;
44
45#if (defined(_WIN32) || defined(_WIN64))
46 std::size_t getOriginalFunctionSize() const noexcept;
47#endif
48
57 ReturnType operator()(CallerType& caller, ArgTypes&&... args) const;
58
67 ReturnType operator()(CallerType const& caller, ArgTypes&&... args) const;
68 };
69
70 #include "Refureku/TypeInfo/Functions/MemberFunction.inl"
71}
Definition: ICallable.h:13
ReturnType operator()(CallerType const &caller, ArgTypes &&... args) const
Call the underlying function with on the provided caller forwarding the provided arguments.
ReturnType operator()(CallerType &caller, ArgTypes &&... args) const
Call the underlying function with on the provided caller forwarding the provided arguments.
Definition: MemberFunction.h:18
Definition: Allocator.h:16