diff --git a/patch_common/include/patch_common/CodeInjection.h b/patch_common/include/patch_common/CodeInjection.h index 9388043f1..d7dad1474 100644 --- a/patch_common/include/patch_common/CodeInjection.h +++ b/patch_common/include/patch_common/CodeInjection.h @@ -234,7 +234,7 @@ class CodeInjection2()(std::declval(&wrapper), needs_trampoline), - m_functor(handler) + m_functor(std::move(handler)) {} private: @@ -253,8 +253,8 @@ class BaseCodeInjectionWithoutRegsAccess : public BaseCodeInjection WrapperPtr m_wrapper_ptr; - BaseCodeInjectionWithoutRegsAccess(uintptr_t addr, WrapperPtr wrapper_ptr, bool needs_trampoline) : - BaseCodeInjection(addr, needs_trampoline), m_wrapper_ptr(wrapper_ptr) + BaseCodeInjectionWithoutRegsAccess(uintptr_t addr, WrapperPtr wrapper_ptr) : + BaseCodeInjection(addr, true), m_wrapper_ptr(wrapper_ptr) {} void emit_code(AsmWriter& asm_writter, void* trampoline) override; @@ -266,9 +266,9 @@ class CodeInjection2()())> : public BaseCodeInjectio T m_functor; public: - CodeInjection2(uintptr_t addr, T handler, bool needs_trampoline) : - BaseCodeInjectionWithoutRegsAccess(addr, reinterpret_cast(&wrapper), needs_trampoline), - m_functor(handler) + CodeInjection2(uintptr_t addr, T handler) : + BaseCodeInjectionWithoutRegsAccess(addr, reinterpret_cast(&wrapper)), + m_functor(std::move(handler)) {} private: @@ -278,11 +278,20 @@ class CodeInjection2()())> : public BaseCodeInjectio } }; -template -class CodeInjection : public CodeInjection2 -{ +template +class CodeInjection : public CodeInjection2 { public: - CodeInjection(uintptr_t addr, T handler, bool needs_trampoline = true) : - CodeInjection2(addr, handler, needs_trampoline) - {} + CodeInjection(const uintptr_t addr, T handler) + requires std::invocable + : CodeInjection2(addr, std::move(handler)) { + } + + CodeInjection( + const uintptr_t addr, + T handler, + const bool needs_trampoline = true + ) + requires std::invocable + : CodeInjection2(addr, std::move(handler), needs_trampoline) { + } };