Re: Accepting function or delegate as function argument

2016-05-06 Thread Gary Willoughby via Digitalmars-d-learn
On Wednesday, 4 May 2016 at 15:23:20 UTC, Rene Zwanenburg wrote: On Wednesday, 4 May 2016 at 14:54:39 UTC, chmike wrote: Two constructors, one accepting a function and the other one accepting a delegate would do the job for the API. Is there a simple method to convert a function pointer into a

Re: Accepting function or delegate as function argument

2016-05-04 Thread Rene Zwanenburg via Digitalmars-d-learn
On Wednesday, 4 May 2016 at 14:54:39 UTC, chmike wrote: Two constructors, one accepting a function and the other one accepting a delegate would do the job for the API. Is there a simple method to convert a function pointer into a delegate pointer that is also efficient ? http://dlang.org/phob

Re: Accepting function or delegate as function argument

2016-05-04 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 4 May 2016 at 14:54:39 UTC, chmike wrote: Two constructors, one accepting a function and the other one accepting a delegate would do the job for the API. Is there a simple method to convert a function pointer into a delegate pointer that is also efficient ? Do the overload and c

Accepting function or delegate as function argument

2016-05-04 Thread chmike via Digitalmars-d-learn
I have implemented the following class (simplified ;) ) class Foo(K,T) { this(T delegate (K) factory) { m_factory = factory; } T delegate (K) m_factory; T bar(K key) { return m_factory(key); } } string dummyFactory(string key) { return "Hello "~key; } void main() { auto foo