www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20687] New: Allow member function address as const initializer

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: nobody puremagic.com
          Reporter: boris2.9 gmail.com

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/gudyizszasrhstzhnhqj forum.dlang.org

--
Mar 19