<div dir="ltr">2013/3/27 Timon Gehr <span dir="ltr"><<a href="mailto:timon.gehr@gmx.ch" target="_blank">timon.gehr@gmx.ch</a>></span><br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div class="im"><span style="color:rgb(34,34,34)">Because of a questionable patch (written by Kenji Hara, I think) some time ago, the following works:</span><br></div>
<br>
struct S{<br>
    template T(int x){<br>
        auto s = x; // implicitly static<br>
    }<br>
}<br>
<br>I consider this bad language design.</blockquote><div><br></div><div style>In above case, 's' cannot make a field in S.</div><div style>Because such a feature would make impossible to determine the size of S.</div>
<div style><br></div><div style>void main() {</div><div style>    S s;</div><div style>    assert(s.T!0.s == 0);  // If T!0.s is a field of s,</div><div style>    assert(s.T!1.s == 1);  // also T!1.s is a field...</div><div style>
    pragma(msg, S.sizeof == ??);  // ???</div><div style>}</div><div style><br></div><div style>So, variables in template declaration will always make "static' variables.<br></div><div style><br></div><div style>
Kenji Hara</div></div></div></div>