[Issue 11685] template opDispatch rejects-valid.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Dec 4 14:09:13 PST 2013


https://d.puremagic.com/issues/show_bug.cgi?id=11685



--- Comment #1 from John Colvin <john.loughran.colvin at gmail.com> 2013-12-04 22:09:12 GMT ---
Also, note that it manages to print something halfway-correct for the unittest
pragma(msg, ...) even though it claims a much earlier error.


A clean version of the code without all the pragmas:

template PartialApply(alias F, uint argLoc, Arg ...)
    if(Arg.length == 1)
{
    template PartialApply(L ...)
    {
        alias PartialApply = F!(L[0 .. argLoc], Arg, L[argLoc .. $]);
    }
}

struct Pack(T...)
{
    template opDispatch(string s)
    {
        mixin("alias opDispatch = PartialApply!(." ~ s ~ ", 0,
typeof(this));");
    }
}


struct asArg(T, uint argIndex)
{
    template opDispatch(string s)
    {
        mixin("alias opDispatch = PartialApply!(." ~ s ~ ", " ~
argIndex.stringof ~ ", T);");
    }
}

unittest
{
    alias A = Pack!(1,2,3).asArg!(1).Pack!(0);
}

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list