<div dir="ltr">2013/8/13 monarch_dodra <span dir="ltr"><<a href="mailto:monarchdodra@gmail.com" target="_blank">monarchdodra@gmail.com</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">
Related: I have encountered this problem, and I can't seem to work around it; *other* than non-parameterized templates. Basically, I have this pred function, we'll call it "foo". This pred function can itself be parameterized to take its own (optional) pred. This basically allows:<br>
foo(a, b)<br>
or<br>
foo!pred(a, b)<br>
<br>
This is "traditionally" solved by doing:<br>
void foo(A, B)(A a, B b);<br>
void foo(alias pred, A, B)(A a, B b);<br>
<br>
Here is the kicker though: "foo" is itself a pred. This means that I *need* to be able to pass "foo!pred" as a predicate. This does not work, as "foo!pred" is nothing: The compiler doesn't know what you are talking about, as the parameters A and B are missing. This is usually solved by a template:<br>
<br>
template foo(alias pred)<br>
{<br>
void foo(A, B)(A a, B b);<br>
}<br>
<br>
This works.... *however* the presence of the "void foo(A, B)(A a, B b);" confuses the crap out of the compiler:<br>
foo(a, b); //OK<br>
alias PRED = foo!"hello";<br>
PRED(a, b); //OK<br>
<br>
BUT:<br>
foo!"hello"(a, b); //Error:<br>
Error: template hello.foo does not match any function template declaration. Candidates are:<br>
hello.foo(R1, R2)(R1 r1, R2 r2)<br>
hello.foo(alias pred)<br>
Error: template hello.foo(R1, R2)(R1 r1, R2 r2) cannot deduce template function from argument types !("hello")(int, int)<br>
Error: template instance foo!"hello" errors instantiating template<br>
<br>
So... how to make this work? AFAIK, non-parameterized templates should solve it. Or is it just a compiler issue?<br>
<br>
FYI: This is a problem present in Phobos. You can use:<br>
"equal!equal(RoR1, RoR2)"<br>
To compare two ranges of ranges. equal!equal gets instanciated, because the args are present to "finish" the missing R1/R2 args after pred.<br>
<br>
However, this neat trick stop there:<br>
"equal!(equal!equal)(RoRoR1, RoRoR2)"<br>
This time, this does not work, as the compiler can't resolve the predicate.<br>
<br>
I'd like to solve this. IMO "equal!equal" is one of the neatest "1-word" in D, and I want to make sure it works as one would expect it to.<br>
<br>
--------<br>
<br>
So: Any workaround recommendations? Alternatives? Thoughts on parameter-less templates (regardless of my issue)?<br>
</blockquote></div><br></div><div class="gmail_extra">Maybe: <a href="http://d.puremagic.com/issues/show_bug.cgi?id=10811">http://d.puremagic.com/issues/show_bug.cgi?id=10811</a></div><div class="gmail_extra"><br></div><div class="gmail_extra">
Kenji Hara</div></div>