我们知道看起来像的参数void()将被重写为void(*)().这类似于阵列到指针衰变,其中int[]变int*.在许多情况下,使用数组会将其衰减为指针.是否存在功能"衰减"的参数以外的情况?
C++标准规定:
§8.3.5/ 5
...在确定每个参数的类型之后,将"T的数组"或"返回的函数T"的任何参数分别调整为"指向T的指针"或"指向函数返回T的指针",...
由于下面的评论者似乎不相信我......我的编译器显示的是什么.
void handler(void func())
{
func(42);
}
main.cpp: In function 'void handler(void (*)())':
main.cpp:5:12: error: too many arguments to function
func(42);
^
Run Code Online (Sandbox Code Playgroud) c++ ×1