Re: need help to get member function const address

2020-03-20 Thread Calvin P via Digitalmars-d-learn
On Thursday, 19 March 2020 at 23:46:01 UTC, Boris Carvajal wrote: https://issues.dlang.org/show_bug.cgi?id=20687 https://github.com/dlang/dmd/pull/10946 Thanks very much for such a quick fix.

Re: need help to get member function const address

2020-03-19 Thread Boris Carvajal via Digitalmars-d-learn
On Thursday, 19 March 2020 at 14:43:53 UTC, Steven Schveighoffer wrote: I think this is an invalid limitation, you should file an issue at https://issues.dlang.org essentially, with your sample A struct: const f1 = // OK const f2 = // Error, not constant expression Both these should be

Re: need help to get member function const address

2020-03-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/19/20 9:40 AM, Calvin P wrote: On Monday, 16 March 2020 at 18:43:47 UTC, Steven Schveighoffer wrote: enum A0 = Note that you can't call it at all, but you can get the function pointer, and put it into a delegate later by assigning .funcptr. void main() {     A a;     void delegate()

Re: need help to get member function const address

2020-03-19 Thread Calvin P via Digitalmars-d-learn
On Thursday, 19 March 2020 at 13:23:41 UTC, Adam D. Ruppe wrote: Check the error message there... you already have a function pointer, no need to use the .funcptr metod. It is a bit weird though because it actually EXCLUDES the hidden argument for `this`. I prefer doing wrapper functions

Re: need help to get member function const address

2020-03-19 Thread Calvin P via Digitalmars-d-learn
On Monday, 16 March 2020 at 18:43:47 UTC, Steven Schveighoffer wrote: enum A0 = Note that you can't call it at all, but you can get the function pointer, and put it into a delegate later by assigning .funcptr. void main() { A a; void delegate() dg; dg.ptr = dg.funcptr =

Re: need help to get member function const address

2020-03-19 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 19 March 2020 at 04:30:32 UTC, Calvin P wrote: my question is, how to get it in compile time like static function address: = struct A { void d(){}; static void fn(){}; } enum FN = // static method address is ok enum A1 = (&__traits(getMember, A,"d")).funcptr;

Re: need help to get member function const address

2020-03-19 Thread Calvin P via Digitalmars-d-learn
On Thursday, 19 March 2020 at 06:34:40 UTC, Alex wrote: A non-static member method can use the context of the struct where it is defined in. E.g. it could alter a member variable. This context has to be constructed at run time (and there could be many instances of the context) and does not

Re: need help to get member function const address

2020-03-19 Thread Boris Carvajal via Digitalmars-d-learn
On Thursday, 19 March 2020 at 04:30:32 UTC, Calvin P wrote: I use this code to get member function address on runtime: = struct A { this(){}; } auto ctor = (&__traits(getMember, A.init,"__ctor")).funcptr; = my question is, how to get it in compile time like static

Re: need help to get member function const address

2020-03-19 Thread Alex via Digitalmars-d-learn
On Thursday, 19 March 2020 at 04:30:32 UTC, Calvin P wrote: I use this code to get member function address on runtime: = struct A { this(){}; } auto ctor = (&__traits(getMember, A.init,"__ctor")).funcptr; = my question is, how to get it in compile time like static

need help to get member function const address

2020-03-18 Thread Calvin P via Digitalmars-d-learn
I use this code to get member function address on runtime: = struct A { this(){}; } auto ctor = (&__traits(getMember, A.init,"__ctor")).funcptr; = my question is, how to get it in compile time like static function address: = struct A { void d(){};

Re: need help to get member function const address

2020-03-16 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/14/20 5:06 AM, Calvin P wrote: I use this code to get member function address on runtime: = struct A {    this(){}; } auto ctor = (&__traits(getMember, A.init,"__ctor")).funcptr; = my question is, how to get it in compile time like static function address: =

need help to get member function const address

2020-03-14 Thread Calvin P via Digitalmars-d-learn
I use this code to get member function address on runtime: = struct A { this(){}; } auto ctor = (&__traits(getMember, A.init,"__ctor")).funcptr; = my question is, how to get it in compile time like static function address: = struct A { void d(){};