diff --git a/loader/include/Geode/utils/function.hpp b/loader/include/Geode/utils/function.hpp new file mode 100644 index 00000000..855f1951 --- /dev/null +++ b/loader/include/Geode/utils/function.hpp @@ -0,0 +1,59 @@ +#pragma once + +#include + +namespace geode::utils::function { + namespace detail { + template + struct ImplExtract; + + template + struct ImplExtract { + using Type = R(A...); + using Return = R; + using Args = std::tuple; + static constexpr std::size_t ARG_COUNT = std::tuple_size_v; + }; + template + struct ImplExtract { + using Type = R(A...); + using Return = R; + using Args = std::tuple; + static constexpr std::size_t ARG_COUNT = std::tuple_size_v; + }; + template + struct ImplExtract { + using Type = R(A...); + using Class = C; + using Return = R; + using Args = std::tuple; + static constexpr std::size_t ARG_COUNT = std::tuple_size_v; + }; + template + struct ImplExtract { + using Type = R(A...); + using Class = C; + using Return = R; + using Args = std::tuple; + static constexpr std::size_t ARG_COUNT = std::tuple_size_v; + }; + template + requires requires { &F::operator(); } + struct ImplExtract : public ImplExtract {}; + + template + using Extract = ImplExtract>; + } + + template + using FunctionInfo = detail::Extract; + + template + using Return = typename detail::Extract::Return; + + template + using Args = typename detail::Extract::Args; + + template + using Arg = std::tuple_element_t::Args>; +}