从C 11标准第5.2.2 / 1段中提取的句子中粗体字符是什么意思?
There are two kinds of function call: ordinary function call and member function (9.3) call. A function call is a postfix expression followed by parentheses containing a possibly empty,comma-separated list of expressions which constitute the arguments to the function. For an ordinary function call,the postfix expression shall be either an lvalue that refers to a function (in which case the function-to-pointer standard conversion (4.3) is suppressed on the postfix expression),or it shall have pointer to function type.
编辑
基本上我要问的是:当标准说“(在这种情况下,函数到指针标准转换在后缀表达式上被抑制)”这是否意味着这种抑制是好的或者它将在以后被撤销(例如,在函数重载之后)?
EDIT1
在我看来,上面的“抑制”一词具有误导性,因为它给人的印象是,从函数名到函数指针的转换可能永远不会被编译器完成.我相信情况并非如此.在函数重载过程完成后,此转换将始终发生,因为只有在此时,编译器才能确切地知道要调用的函数.程序初始化函数指针时不是这种情况.在这种情况下,编译器知道要调用的函数,因此不会出现重载,如下例所示.
#include
int foo(int i) { std::cout << "int" << '\n'; return i * i; }
double foo(double d) { std::cout << "double" << '\n'; return d * d; }
int main()
{
int(*pf)(int) = foo; // no overloading here!
std::cout << pf(10.) << '\n'; // calls foo(int)
std::cout << foo(10.) << '\n'; // call foo(double) after function overloading. Therefore,only after function
// overloading is finished,the function name foo() is converted into a function-pointer.
}
代码打印:
int
100
double
100