The chance to call, in percentage.
The function to call. It must be a void function.
The variadic argument passed to fun.
false if no luck.
1 uint cnt; 2 bool test; 3 void foo(uint param0, out bool param1) @safe 4 { 5 cnt += param0; 6 param1 = true; 7 } 8 foreach(immutable i; 0 .. 100) 9 pickAndCall!(double)(75.0, &foo, 1, test); 10 assert(cnt > 25); 11 assert(test); 12 cnt = 0; 13 test = false; 14 foreach(immutable i; 0 .. 100) 15 pickAndCall!(byte)(0, &foo, 1, test); 16 assert(cnt == 0); 17 assert(!test);
Calls a function according to a probability