What's wrong with the code below? Latest version of g++ and clang both give error. I am sure I am missing something basic here.

```
#include <iostream>

struct Z
{
  static const int mysize = 10; 
};

Z f2();

int main()
{
    std::cout << f2()::mysize << std::endl;
}

```

The motivation here is to be able to find out the size of an array using templates using code such as below. I know there are many ways, but just stumbled upon this idea.

```
template<int N> struct S
{
    enum { mysize = N };
};

template<class T, int N> S<N> f(T (&)[N]);

int main()
{
    char buf[10];
    std::cout << f(buf)::mysize << std::endl;
}

```