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

          Issue ID: 20687
           Summary: Allow member function address as const initializer
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: [email protected]
          Reporter: [email protected]

Code:

struct S
{
    void foo(){}
}

void main()
{
    S i;
    enum fp = &S.foo;
    auto dg = &i.foo;
    assert(fp == dg.funcptr);

    // Allow this
    static immutable dgfp = &S.foo;
    assert(dgfp == dg.funcptr);
}

You can already use an enum.

https://forum.dlang.org/thread/[email protected]

--

Reply via email to