/* This file is part of the dynarmic project. * Copyright (c) 2016 MerryMage * This software may be used and distributed according to the terms of the GNU * General Public License version 2 or any later version. */ #pragma once #include #include namespace Dynarmic { namespace mp { /// Used to provide information about an arbitrary function. template struct FunctionInfo; /** * Partial specialization for function types. * * This is used as the supporting base for all other specializations. */ template struct FunctionInfo { using return_type = R; static constexpr size_t args_count = sizeof...(Args); template struct Parameter { static_assert(args_count != 0 && ParameterIndex < args_count - 1, "Non-existent function parameter index"); using type = std::tuple_element_t>; }; }; /// Partial specialization for function pointers template struct FunctionInfo : public FunctionInfo { }; /// Partial specialization for member function pointers. template struct FunctionInfo : public FunctionInfo { using class_type = C; }; /** * Helper template for retrieving the type of a function parameter. * * @tparam Function An arbitrary function type. * @tparam ParameterIndex Zero-based index indicating which parameter to get the type of. */ template using parameter_type_t = typename FunctionInfo::template Parameter::type; /** * Helper template for retrieving the return type of a function. * * @tparam Function The function type to get the return type of. */ template using return_type_t = typename FunctionInfo::return_type; } // namespace mp } // namespace Dynarmic