Obsecure problem 2

pascal111 judas.the.messiah.111 at gmail.com
Wed Aug 3 16:59:53 UTC 2022


I tried to make a template that receive lambda expression to 
apply it on a given range the user specifies, but I found 
non-understood problem:


'''D

module main;

import std.stdio;
import std.functional;


     template foo(alias predicate)
     if (is(typeof(unaryFun!predicate)))
     {
         alias notfunny=unaryFun!predicate;

auto foo(Range)(Range range) if (isInputRange!(Unqual!Range)){

         foreach(x; range)
             notfunny(x);

         return range;}


}


int main()
{

         int[] lolo = [12, 66, 654, -98, 54];

         lolo.foo(a=>a+2);

         lolo.writeln;

         return 0;
     }
     '''


More information about the Digitalmars-d-learn mailing list