C++ 从函数中获取参数类型列表
为了从函数指针中获取参数类型列表,我在下午和晚上绞尽脑汁。我可以通过解决方案获得单独的参数类型,比如这里提出的解决方案:,但这会中断,因为我不知道使用了多少个参数(如果有的话) 我有以下(减少)功能:C++ 从函数中获取参数类型列表,c++,c++11,visual-c++,C++,C++11,Visual C++,为了从函数指针中获取参数类型列表,我在下午和晚上绞尽脑汁。我可以通过解决方案获得单独的参数类型,比如这里提出的解决方案:,但这会中断,因为我不知道使用了多少个参数(如果有的话) 我有以下(减少)功能: void LuaWrapper::Register(const char* aFunctionName, Ret(*aFunctionType(Args...)) { //I can get the return value via typeid(Ret).name() //I
void LuaWrapper::Register(const char* aFunctionName, Ret(*aFunctionType(Args...))
{
//I can get the return value via typeid(Ret).name()
//I would like to be able to do something like typeid(Args...).name() to get a list of all parameter types
}
我所要求的是不可能的,还是我太密集了?对于所有
Args
,您无法获得一个typeid
,因为Args
包含多个类型
只需针对每种类型分别获取:
const char *args[] = { typeid(Args).name()... };