Re: Calling template member function?

2022-04-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/19/22 8:44 PM, Andrey Zherikov wrote: On Tuesday, 19 April 2022 at 20:29:01 UTC, Steven Schveighoffer wrote: You can work around the dual context, if you are OK with passing the second context explicitly. The easiest way is to move the member function to a UFCS function. an example:

Re: Calling template member function?

2022-04-19 Thread Andrey Zherikov via Digitalmars-d-learn
On Tuesday, 19 April 2022 at 20:29:01 UTC, Steven Schveighoffer wrote: You can work around the dual context, if you are OK with passing the second context explicitly. The easiest way is to move the member function to a UFCS function. an example: ```d struct X { int x; void

Re: Calling template member function?

2022-04-19 Thread Andrey Zherikov via Digitalmars-d-learn
On Tuesday, 19 April 2022 at 19:07:37 UTC, Ali Çehreli wrote: On 4/19/22 11:18, Andrey Zherikov wrote: > Is there a way/workaround to achieve the desired behavior? Can you describe the goal a little more. For example, I assume you really need a more useful lambda although the example you

Re: Calling template member function?

2022-04-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/19/22 2:18 PM, Andrey Zherikov wrote: On Tuesday, 19 April 2022 at 16:38:42 UTC, Steven Schveighoffer wrote: On 4/19/22 11:46 AM, Paul Backus wrote: If you remove `static` from `f_new`, you get an error message talking about this explicitly: Interesting that `static` does anything

Re: Calling template member function?

2022-04-19 Thread Ali Çehreli via Digitalmars-d-learn
On 4/19/22 11:18, Andrey Zherikov wrote: > Is there a way/workaround to achieve the desired behavior? Can you describe the goal a little more. For example, I assume you really need a more useful lambda although the example you show seems unnecessary: enum dg = () => func(); That lambda

Re: Calling template member function?

2022-04-19 Thread Andrey Zherikov via Digitalmars-d-learn
I get the same error even with just `struct`: ```d struct S { static void f_new(alias func)() { func(); } } void f_new(alias func)() { func(); } void f(FUNC)(FUNC func) { f_new!(() => func()); // works // S.f_new!(() => func()); // doesn't work } ```

Re: Calling template member function?

2022-04-19 Thread Andrey Zherikov via Digitalmars-d-learn
On Tuesday, 19 April 2022 at 18:18:26 UTC, Andrey Zherikov wrote: Is there a way/workaround to achieve the desired behavior? Those two bugs pointed above were reported in 2017 and 2011 (!) which makes me think that they won't be fixed any time soon (I'm not sure that they are actually the same

Re: Calling template member function?

2022-04-19 Thread Andrey Zherikov via Digitalmars-d-learn
On Tuesday, 19 April 2022 at 16:38:42 UTC, Steven Schveighoffer wrote: On 4/19/22 11:46 AM, Paul Backus wrote: If you remove `static` from `f_new`, you get an error message talking about this explicitly: Interesting that `static` does anything there, since it's a no-op. -Steve I put

Re: Calling template member function?

2022-04-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/19/22 11:46 AM, Paul Backus wrote: On Tuesday, 19 April 2022 at 13:36:26 UTC, Andrey Zherikov wrote: I want to migrate my library API from standalone function that takes delegate as argument to a template member function that takes delegate as a template parameter but compiler errors out.

Re: Calling template member function?

2022-04-19 Thread Paul Backus via Digitalmars-d-learn
On Tuesday, 19 April 2022 at 13:36:26 UTC, Andrey Zherikov wrote: I want to migrate my library API from standalone function that takes delegate as argument to a template member function that takes delegate as a template parameter but compiler errors out. Here is code example: ```d import

Re: Calling template member function?

2022-04-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/19/22 9:36 AM, Andrey Zherikov wrote: I want to migrate my library API from standalone function that takes delegate as argument to a template member function that takes delegate as a template parameter but compiler errors out. Here is code example: ```d import std.stdio; template T(P) {