<br><br><div class="gmail_quote">On Mon, Apr 19, 2010 at 07:31, BCS <span dir="ltr"><<a href="mailto:none@anon.com">none@anon.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;">
Or you can mangel that a bit:<br>
<br>
template check(alias func) {<br>
bool check(EL ...)() {<div class="im"><br>
GError* err;<br>
bool ok = func(EL, &err);<br>
if (!ok)<br>
throw new Exception((*err).message);<br>
return ok;<br>
}<br>
}<br>
<br></div>
that should allow you to call it like:<br>
<br>
check!(fooXXX)(arg1, ..., argN);<font color="#888888"></font></blockquote><div><br>(I guess you meant bool check(EL...)(EL el) in the second stage.)<br><br>Yes, this example is even more powerful. The version I posted already allows you to write <br>
<br>check!fun(params); // no need to give explictly the EL, the compiler wil deduce them for you<br><br> but yours allow you to 'store' the checking of fun and then to use it for any parameter typetuple. Maybe not useful for the OP, but mighty handy in some other cases.<br>
I discovered this trick a few weeks ago and, though a bitch to code sometimes, it's very nice to have.<br><br>Usage:<br><br>alias check!foo fooCheck; // checkFoo is a templated function, so it's _not_ a function. You cannot assign it to a variable.<br>
// use alias instead.<br><br>// some other code //<br>auto check1 = fooCheck(1,2,3);<br>//<br>auto check2 = fooCheck("a","b", 2.34);<br><br>It's particularly useful when foo is polymorphic. Again, not interesting for the OP, but very fun.<br>
<br>Philippe<br><br><br></div></div>