From [dcl.fct], pretty explicitly:
Functions shall not have a return type of type array or function, although they may have a return type of
type pointer or reference to such things. There shall be no arrays of functions, although there can be arrays
of pointers to functions.
With C++11, you probably just want:
std::function<int()> f();
std::function<int(double)> f(char);
There is some confusion regarding the C++ grammar. The statement int f(char)(double);
can be parsed according to the grammar. Here is a parse tree:
Furthermore such a parse is even meaningful based on [dcl.fct]/1:
In a declaration
T D
whereD
has the form
D1
( parameter-declaration-clause ) cv-qualifier-seqopt
ref-qualifieropt exception-specificationopt attribute-specifier-seqoptand the type of the contained declarator-id in the declaration
T D1
is “derived-declarator-type-listT
”, the
type of the declarator-id inD
is “derived-declarator-type-list function of (parameter-declaration-clause ) cv-qualifier-seqopt
ref-qualifieropt returningT
”.
In this example T == int
, D == f(char)(double)
, D1 == f(char)
. The type of the declarator-id in T D1
(int f(char)
) is “function of (char) returning int”. So derived-declarator-type-list is “function of (char) returning”. Thus, the type of f
would be read as “function of (char) returning function of (double) returning int.”
It’s ultimately much ado about nothing, as this is an explicitly disallowed declarator form. But not by the grammar.