Joshua:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
oh wow didnt know u could do that. much nicer.<br></blockquote><div><br></div><div>It's an is() expression (you cited my tutorial, there is an appendix on it). It recently became even more powerful, so the tutorial is not accurate any more.</div>
<div><br></div><div>A few months ago, you couldn't do </div><div><br></div><div>is(Type _ == Template!Args, Args...)</div><div><br></div><div>with Args being whatever number of args are needed. Only fixed numbers were possible:</div>
<div><br></div><div><div>is(Type _ == Template!(T), T)</div></div><div>is(Type _ == Template!(T,U), T,U)</div><div>and so on...</div><div><br></div><div>Now, testing for a Tuple is easy:</div><div><br></div><div>is(Type _ == Tuple!Args, Args...)</div>
<div><br></div><div><br></div><div><br></div><div>What's even nicer with an is() expr is that the introspection info is accessible when used inside a static if. So with Artur's code, CT can be seen inside the true branch of the static if.</div>
<div><br></div><div>template ComplexType(T) </div><div>if (isComplex!T) // Using the previously defined isComplex</div><div>{</div><div>    // we know it's a Complex!CT, for some CT</div><div>    static if (is(T _ == Complex!CT, CT)</div>
<div>        alias CT ComplexType;</div><div>    else</div><div>        static assert(false, "This should not happen!");</div><div>}</div><div><br></div><div>void main()</div><div>{</div><div>    Complex!double c;</div>
<div>    writeln(ComplexType!(typeof(c)).stringof);</div><div>}</div><div><br></div></div>