I dun a DIP, possibly the best DIP ever

Walter Bright newshound2 at digitalmars.com
Fri Apr 24 04:22:47 UTC 2020


On 4/22/2020 6:18 AM, Steven Schveighoffer wrote:
> int double_int(int val) { return 2 * val; }
> 
> T double_int(T val) { return val; }
> 
> void double_ints(alias pred, T... args) {
>     pred(double_int(args)...);
> }

This can be done with the array syntax proposal using UFCS:

void double_ints(alias pred, T... args) {
     args.pred();
}


More information about the Digitalmars-d mailing list