[Issue 1816] Parameter names not visible in return type in function declarations

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Feb 5 08:09:29 PST 2008


http://d.puremagic.com/issues/show_bug.cgi?id=1816


andrei at metalanguage.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED




------- Comment #2 from andrei at metalanguage.com  2008-02-05 10:09 -------
Thanks, downs, worked great. You forgot a pair of parens, so for others'
reference here's the current implementation of binaryPred in std.functional:

template binaryPred(string comp) {
    // @@@BUG@@@: typeof(mixin(comp)) should work
    typeof({ ElementType a, b; return mixin(comp);}())
    binaryPred(ElementType)(ElementType a, ElementType b)
    {
        return mixin(comp);
    }
}

unittest
{
    alias binaryPred!(q{a < b}) less;
    assert(less(1, 2) && !less(2, 1));
    assert(less("1", "2") && !less("2", "1"));
}


-- 



More information about the Digitalmars-d-bugs mailing list