Re: Templatized delegates

2022-05-31 Thread Andrey Zherikov via Digitalmars-d-learn
On Tuesday, 31 May 2022 at 23:15:24 UTC, Andrey Zherikov wrote: On Tuesday, 31 May 2022 at 21:53:17 UTC, Paul Backus wrote: If you want compile-time polymorphism, three's no other way. Yes, I want compile-time polymorphism. In case if `S.doSomething` is NOT template function then the proble

Re: Templatized delegates

2022-05-31 Thread Andrey Zherikov via Digitalmars-d-learn
On Tuesday, 31 May 2022 at 22:34:41 UTC, Christian Köstlin wrote: Would it help to not create the delegate in R's constructor, but feed the delegate into it (and create the delegate outside). This would also resemble your description (R is a delegate holder) more. That's possible but the prob

Re: Templatized delegates

2022-05-31 Thread Andrey Zherikov via Digitalmars-d-learn
On Tuesday, 31 May 2022 at 21:53:17 UTC, Paul Backus wrote: If you want compile-time polymorphism, three's no other way. Yes, I want compile-time polymorphism. ```d import std.stdio; struct S { // function that should be called from delegate void doSomething(T)(T value) { value.write

Re: Templatized delegates

2022-05-31 Thread Christian Köstlin via Digitalmars-d-learn
On 2022-05-31 23:15, Andrey Zherikov wrote: I have tightly coupled code which I'd like to decouple but I'm a bit stuck. For simplicity, I reduced the amount of code to something simple to understand. So I have a struct `S` that has templated member function that does something. On the other sid

Re: Templatized delegates

2022-05-31 Thread Paul Backus via Digitalmars-d-learn
On Tuesday, 31 May 2022 at 21:15:24 UTC, Andrey Zherikov wrote: I have tightly coupled code which I'd like to decouple but I'm a bit stuck. For simplicity, I reduced the amount of code to something simple to understand. So I have a struct `S` that has templated member function that does somethi

Templatized delegates

2022-05-31 Thread Andrey Zherikov via Digitalmars-d-learn
I have tightly coupled code which I'd like to decouple but I'm a bit stuck. For simplicity, I reduced the amount of code to something simple to understand. So I have a struct `S` that has templated member function that does something. On the other side I have delegate holder `R` - this delegate