Re: Passing refs with delegates

2016-08-03 Thread Mark J Twain via Digitalmars-d-learn
On Wednesday, 3 August 2016 at 08:12:00 UTC, Ali Çehreli wrote: On 08/02/2016 07:55 PM, Mark J Twain wrote: [...] I didn't know one could use 'auto ref' in this case but the following simple test works: auto foo(Func, Args...)(Func callback, auto ref Args args) { return callback(args);

Re: Passing refs with delegates

2016-08-03 Thread Ali Çehreli via Digitalmars-d-learn
On 08/02/2016 07:55 PM, Mark J Twain wrote: It's nice to be able to pass delegates and functions as callbacks. A nice feature is something like R foo(R,Args...)(R function(Args) callback, Args args) { return callback(args); } There are two problems with this. One is that type deduction doesn'

Passing refs with delegates

2016-08-02 Thread Mark J Twain via Digitalmars-d-learn
It's nice to be able to pass delegates and functions as callbacks. A nice feature is something like R foo(R,Args...)(R function(Args) callback, Args args) { return callback(args); } There are two problems with this. One is that type deduction doesn't work. I have to explicitly specify the t