Re: Taking a function or delegate as argument.

2012-01-10 Thread Jacob Carlborg
On 2012-01-11 02:21, Stewart Gordon wrote: On 10/01/2012 19:56, Jacob Carlborg wrote: A template parameter with a template constraint will accept any callable type. Function pointer, delegate, struct/class overloading the call operator and so on. Moreover, if you want to save the callback for

Re: Taking a function or delegate as argument.

2012-01-10 Thread Jacob Carlborg
On 2012-01-11 02:05, Stewart Gordon wrote: On 10/01/2012 19:56, Jacob Carlborg wrote: A template parameter with a template constraint will accept any callable type. Function pointer, delegate, struct/class overloading the call operator and so on. Indeed, this is done in the C++ STL quite a lo

Re: Taking a function or delegate as argument.

2012-01-10 Thread Stewart Gordon
On 10/01/2012 19:56, Jacob Carlborg wrote: A template parameter with a template constraint will accept any callable type. Function pointer, delegate, struct/class overloading the call operator and so on. Moreover, if you want to save the callback for later use, you need to distinguish the ca

Re: Taking a function or delegate as argument.

2012-01-10 Thread Stewart Gordon
On 10/01/2012 19:56, Jacob Carlborg wrote: A template parameter with a template constraint will accept any callable type. Function pointer, delegate, struct/class overloading the call operator and so on. Indeed, this is done in the C++ STL quite a lot. The drawback is that templated methods

Re: Taking a function or delegate as argument.

2012-01-10 Thread Jacob Carlborg
On 2012-01-10 20:24, bls wrote: On 01/10/2012 06:53 AM, Jacob Carlborg wrote: On 2012-01-10 14:48, simendsjo wrote: On 10.01.2012 14:43, Mike Parker wrote: On 1/10/2012 10:05 PM, simendsjo wrote: If I want to have a method taking a callback function, I have to specify if it should take a func

Re: Taking a function or delegate as argument.

2012-01-10 Thread bls
On 01/10/2012 06:53 AM, Jacob Carlborg wrote: On 2012-01-10 14:48, simendsjo wrote: On 10.01.2012 14:43, Mike Parker wrote: On 1/10/2012 10:05 PM, simendsjo wrote: If I want to have a method taking a callback function, I have to specify if it should take a function or delegate even if I don't

Re: Taking a function or delegate as argument.

2012-01-10 Thread simendsjo
On 10.01.2012 15:53, Jacob Carlborg wrote: On 2012-01-10 14:48, simendsjo wrote: On 10.01.2012 14:43, Mike Parker wrote: On 1/10/2012 10:05 PM, simendsjo wrote: If I want to have a method taking a callback function, I have to specify if it should take a function or delegate even if I don't rea

Re: Taking a function or delegate as argument.

2012-01-10 Thread simendsjo
On 10.01.2012 14:43, Mike Parker wrote: On 1/10/2012 10:05 PM, simendsjo wrote: If I want to have a method taking a callback function, I have to specify if it should take a function or delegate even if I don't really care. What's the best way to accept either? I cannot see any wrapper for someth

Re: Taking a function or delegate as argument.

2012-01-10 Thread Jacob Carlborg
On 2012-01-10 14:48, simendsjo wrote: On 10.01.2012 14:43, Mike Parker wrote: On 1/10/2012 10:05 PM, simendsjo wrote: If I want to have a method taking a callback function, I have to specify if it should take a function or delegate even if I don't really care. What's the best way to accept eith

Re: Taking a function or delegate as argument.

2012-01-10 Thread simendsjo
On 10.01.2012 14:43, Mike Parker wrote: On 1/10/2012 10:05 PM, simendsjo wrote: If I want to have a method taking a callback function, I have to specify if it should take a function or delegate even if I don't really care. What's the best way to accept either? I cannot see any wrapper for someth

Re: Taking a function or delegate as argument.

2012-01-10 Thread Mike Parker
On 1/10/2012 10:43 PM, Mike Parker wrote: On 1/10/2012 10:05 PM, simendsjo wrote: If I want to have a method taking a callback function, I have to specify if it should take a function or delegate even if I don't really care. What's the best way to accept either? I cannot see any wrapper for some

Re: Taking a function or delegate as argument.

2012-01-10 Thread Mike Parker
On 1/10/2012 10:05 PM, simendsjo wrote: If I want to have a method taking a callback function, I have to specify if it should take a function or delegate even if I don't really care. What's the best way to accept either? I cannot see any wrapper for something like this in std.typecons. The simp

Taking a function or delegate as argument.

2012-01-10 Thread simendsjo
If I want to have a method taking a callback function, I have to specify if it should take a function or delegate even if I don't really care. What's the best way to accept either? I cannot see any wrapper for something like this in std.typecons. import std.stdio, std.traits; void f(int i, v