(*fun)(m,n) same as fun(m,n) because of the rules in C and C ++ that convert functions to function pointers.
In C 2011, a rule is clause 6.3.2.1 4: "A function designator is an expression that has a function type. Unless it is an operand of the sizeof operator, the _Llignof operator, or a unary operator & , the designation of a function with the type of the returned function of type is converted to an expression , which is of type βpointer to the return type of the function.β In C ++, the rule is clause 4.3.
Note that a function designation is not just an identifier that calls a function. It can be an identifier, or it can be another expression. For example, if foo is the name of a function, it is automatically converted to a pointer to the function above. Then, since foo is a pointer to a function, *foo is a function. This means that you can write:
(*fun)(m,n)
As a result, fun automatically converted to a pointer, then * evaluates the function, then *fun converted back to a pointer, then the function is called. You can continue this and write:
(**************fun)(m,n)
This is the same as fun(m,n) . Each * executes the function again, but the compiler automatically converts it back to a pointer. You can continue this battle forever, but the compiler will always win.
In fact, they all have the same effect:
(&fun)(m,n) ( fun)(m,n) (*fun)(m,n)
Eric Postpischil
source share