<div class="gmail_quote">On Sun, Apr 4, 2010 at 23:23, Justin Spahr-Summers <span dir="ltr"><<a href="mailto:Justin.SpahrSummers@gmail.com">Justin.SpahrSummers@gmail.com</a>></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><div></div>You can really only pass a single type tuple to a template, but you can<br></div>
work around it by passing a length and then comparing two parts of a<br>
combined tuple. For instance:<br>
<br>
import std.stdio;<br>
import std.typetuple;<br>
<br>
void compare(uint LEN, TL ...) () {<br>
writefln("%s", is(TL[0 .. LEN] == TL[LEN .. $]));<br>
}<br><br></blockquote><div><br>Since to be equal, they must have the same length, you can even get rid of the 'len' part and cut in the middle:<br><br>bool compare(TT...)() {<br> static if (TT.length % 2 == 0 && is(TT[0..$/2] == TT[$/2..$]))<br>
return true;<br> else<br> return false;<br>}<br><br>That's useful to compare two functions:<br><br>template sameArgs(alias fun1, alias fun2) {<br> static if (compare!(ParameterTypeTuple!fun1, ParameterTypeTuple!fun2))<br>
enum bool sameArgs = true;<br> else<br> enum bool sameArgs = false;<br>}<br><br>(I think we could use std.traits.Select to manage this kind of static ifs)<br><br> Philippe<br><br></div></div>