I came across a function with this signature.
void foo(char (&x)[5])
{
}
This is the syntax for passing a fixed size char array by reference.
The fact that it requires parentheses around &x strikes me as unusual.
It is probably part of the C++03 standard.
What is this form called and can anyone point out a reference to the standard?
c++decl is not a friend yet:
$ c++decl
Type `help' or `?' for help
c++decl> explain void foo(char (&x)[5])
syntax error
There is nothing unusual or new about the syntax. You see it all the time in C with pointers.
[]has higher precedence than&, so you need to put it in parentheses if you want to declare a reference to an array. The same thing happens with*(which has the same precedence as&): For example, to declare a pointer to an array of 5 chars in C, you would dochar (*x)[5];. Similarly, a pointer to a function that takes and returns an int would beint (*x)(int);(()has same precedence as[]). The story is the same with references, except that references are only on C++ and there are some restrictions to what types can be formed from references.