[Issue 11012] [TDPL] is(typeof(f) == function) fails with some functions

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri Jun 23 11:40:23 PDT 2017


https://issues.dlang.org/show_bug.cgi?id=11012

--- Comment #9 from Alexander <ismailsiege at gmail.com> ---
I'm not sure about it being a bug, though I was before. I think spec should be
a little more explicit on the difference between function and function pointer
types.

For now, this templates solve all my problems:

template isFunctionPointerType(T: FT*, FT)
{
    enum isFunctionPointerType = is(FT == function);
}

template ReturnType(FuncType: FT*, FT)
{
    static if (is(FT RT == return))
        alias ReturnType = RT;
    else
        static assert(0, "FuncType must be function pointer type");
}

template ParamTypes(FuncType: FT*, FT)
{
    static if (is(FT Params == function))
        alias ParamTypes = Params;
    else
        static assert(0, "FuncType must be function pointer type");
}

--


More information about the Digitalmars-d-bugs mailing list