Static class member
<p>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.</p>

<pre><code>#include &lt;iostream&gt;

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

Z f2();

int main()
{
    std::cout &lt;&lt; f2()::mysize &lt;&lt; std::endl;
}
</code></pre>

<p>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.</p>

<pre><code>template&lt;int N&gt; struct S
{
    enum { mysize = N };
};

template&lt;class T, int N&gt; S&lt;N&gt; f(T (&amp;)[N]);

int main()
{
    char buf[10];
    std::cout &lt;&lt; f(buf)::mysize &lt;&lt; std::endl;
}
</code></pre>
