Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/156.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 从函数中获取参数类型列表_C++_C++11_Visual C++ - Fatal编程技术网

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()... };