From 80be9bfbc16f529c3a988c6da923f740b1eb6b59 Mon Sep 17 00:00:00 2001 From: Basit Ayantunde Date: Sun, 24 Dec 2023 09:40:09 +0000 Subject: [PATCH] update --- include/stx/fn.h | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/include/stx/fn.h b/include/stx/fn.h index 9deb42c..2c62f36 100644 --- a/include/stx/fn.h +++ b/include/stx/fn.h @@ -44,19 +44,15 @@ struct Fn; template struct Fn { - using func_type = ReturnType (*)(memory_handle, Args...); - - explicit constexpr Fn(func_type idispatcher, memory_handle idata_addr) : - dispatcher{idispatcher}, data_addr{idata_addr} - {} + using func_type = ReturnType (*)(void *, Args...); constexpr ReturnType operator()(Args... args) const { - return dispatcher(data_addr, std::forward(args)...); + return dispatcher(data, static_cast(args)...); } - func_type dispatcher = nullptr; - memory_handle data_addr = nullptr; + func_type dispatcher = nullptr; + void *data = nullptr; }; template @@ -122,13 +118,13 @@ struct RawFnTraits template struct RawFunctionDispatcher { - static constexpr ReturnType dispatch(memory_handle data_addr, Args... args) + static constexpr ReturnType dispatch(void *data, Args... args) { using ptr = ReturnType (*)(Args...); - ptr function_ptr = reinterpret_cast(data_addr); + ptr function_ptr = reinterpret_cast(data); - return function_ptr(std::forward(args)...); + return function_ptr(static_cast(args)...); } }; @@ -150,9 +146,9 @@ struct RawFnTraits template struct FunctorDispatcher { - static constexpr ReturnType dispatch(memory_handle data_addr, Args... args) + static constexpr ReturnType dispatch(void *data, Args... args) { - return (*(reinterpret_cast(data_addr)))(std::forward(args)...); + return (*(reinterpret_cast(data)))(static_cast(args)...); } };