Actually that was a pretty useless example. const needs to be evaluable at compile-time, so why did I bother creating a template function? lol..<br><br><div class="gmail_quote">On Wed, Aug 11, 2010 at 7:03 PM, Andrej Mitrovic <span dir="ltr">&lt;<a href="mailto:andrej.mitrovich@gmail.com">andrej.mitrovich@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">I think a more appropriate word for that would be &quot;hide&quot;, or maybe &quot;freeze&quot;.<br>
<br>Here&#39;s another alternative, if you can call it that :p :<br><br>import std.stdio;<br><br>auto freeze(alias dg)()<br>
{<br>    return cast(const) dg();<br>}<br><br>void main() {<br>    auto aa = freeze!(<div class="im"><br>    {<br>        int[int] aa_;<br>        foreach (i; 0 .. 10)<br>            aa_[i] = i * i;<br><br></div>        return aa_;<br>
    });<br>
    <br>    writeln(aa, &quot; &quot;, typeid(aa));<br>}<br><br>But that returns const(const(int)[int]).<br><br>I&#39;m not sure if there&#39;s a way to hide a symbol, appart from introducing another scope with { }. That wouldn&#39;t work in this case, since you want a const type back. Perhaps using the &quot;variant&quot; type from Phobos could do the trick.. I haven&#39;t played with that yet.<div>
<div></div><div class="h5"><br>
<br><div class="gmail_quote">On Wed, Aug 11, 2010 at 6:01 PM, bearophile <span dir="ltr">&lt;<a href="mailto:bearophileHUGS@lycos.com" target="_blank">bearophileHUGS@lycos.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

<div>&gt; Here delete doesn&#39;t clean the aa_, it just removes the aa_ name from the local namespace.<br>
<br>
</div>It&#39;s similar to the #undef directive of C.<br>
<br>
Bye,<br>
<font color="#888888">bearophile<br>
</font></blockquote></div><br>
</div></div></blockquote></div><br>