Re: composition of declarators
ssailor wrote:
I saw an exaple in the c++ standard(clause 6.8),
-------------------------------------------------------
struct T1 {
T1 operator ()( int x ) { return T1(x ); }
int operator =( int x ) { return x; }
T1(int ) { }
};
struct T2 { T2(int ){ } };
int a , (*(* b)( T2 ))( int ), c , d;
void ff ()
{
T1(a) = 3 ,
(*(* b)( T2(c )))( int(d )); // AA
}
--------------------------------------------
I am confused that the declaration at the line AA is valid.
It is.
Then, what's the meaning of this declaration? Thank in advance.
The second part of the declaration declares 'b' to be a pointer
to a function that takes one argument of type 'int' and returns
a pointer to a function that takes one argument of type T2 and
returns T1. 'c' and 'd' are names of the formal arguments and
do not add meaning to the declaration. The fact that they are
in parentheses does not matter.
In the example in the subclause 6.8 of the Standard the
declaration of 'b' is preceded by another declaration of 'T2'
which masks the type name, thus making parsing of the 'b'
declaration improper, and the code ill-formed. That's at least
AIUI. No diagnostic is required, though. Online trial of
Comeau compiles either code without a problem.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask