Non-global template cannot use local lambda

Ali Çehreli acehreli at yahoo.com
Sun Jul 22 17:40:36 PDT 2012


I can't see why the following limitation:

class C
{
     void foo(alias Func)()
     {}
}

void main()
{
     auto c = new C();
     c.foo!(x => x)();  // <-- Compilation error
}

Error: template instance foo!(__lambda2) cannot use local 
'__lambda2(__T1)' as parameter to non-global template foo(alias Func)

Is this a bug?

I've noticed this problem in some of my online examples. The following 
line doesn't work with 2.059, where map() below is 
std.parallelism.TaskPool.map():

     auto results = map!(a => a.averageGrade)(students);

Ali



More information about the Digitalmars-d-learn mailing list