help understanding 'T (&)[N])'

i came across this snippet, couldn't understand some part of it

1
2
3
4
template <typename T, size_t N>
constexpr size_t size_of(T (&)[N]) {
    return N;
}


so you can later utilize it with something like this

1
2
int x[10];
int y[size_of(x)];


what i dont quite get is the part 'T (&)[N]' in the parameter of the template function, what kind of syntax is that and what does it do exactly? thanks!
It is a reference to an array. Normally there would be the name of the parameter between the ampersand and the closing parenthesis. The parenthesis are needed for the same reason they are needed with function pointers and function references - C syntax holdover.
Topic archived. No new replies allowed.