mardi 25 août 2015

C++ syntax, array and lambda function ambiguity

My question is purely syntactical. In C++ we can declare unnamed function parameters. Let's take

void f( int () )

It is valid. Just like these ones:

void f( int f2() )

void f( int (f2()) )first parentheses are just for grouping, albeit with no effect

void f( int (()) )first parentheses are just for grouping, albeit with no effect

Now, let's consider

void f( int [] )

It is valid. Just like these ones:

void f( int a[] )

void f( int (a[]) )first parentheses are just for grouping, albeit with no effect

However, this one

void f( int ([]) )

is illegal in visual studio. It interprets it as functional cast to lambda. I want to know, whether compiler should support this syntactic construction or it potentially can spawn syntactic ambiguity with lambda or something else. It should be smart enough to see that it is function declaration and not a function call that accepts lambda.

Aucun commentaire:

Enregistrer un commentaire