Value I (I ())

Code example:

typedef int I;
struct X{ X(int); };

int main()
{
    int(int());
    X(X());
    I(I());
}

A line int(int());is an expression using functional musical notation — it is temporary int, initialized with an initialized value int.

A string X(X());is a function declaration with a name with Xno arguments returning a struct X.

My question is: what's the point I(I())here? And what rules in the standard define the difference in meaning between these three cases?

+4
source share
1 answer

The rule says that if a construct is an ambiguous syntax for a declaration or statement, then it is considered to be a declaration.

[stmt.ambig] 1 , - : - (5.2.3), indis- , (. .

X(X()); , , , .

int(int()); , int, , . , , .

, I(I()); , , , I , I , , .

+3

Source: https://habr.com/ru/post/1682981/


All Articles