gcc/testsuite/gdc.test/runnable/test7595.d
raw| 1 | // EXTRA_SOURCES: imports/a7595.d |
| 2 | |
| 3 | template isSafe(alias func) |
| 4 | { |
| 5 | @safe void dummySafeFunc() |
| 6 | { |
| 7 | func(); |
| 8 | } |
| 9 | |
| 10 | enum isSafe = is(typeof(dummySafeFunc())); |
| 11 | } |
| 12 | |
| 13 | template areAllSafe(funcs...) |
| 14 | { |
| 15 | enum areAllSafe = isSafe!(funcs[0]); |
| 16 | } |
| 17 | |
| 18 | @safe benchmark(fun...)(uint n) |
| 19 | if (areAllSafe!fun) |
| 20 | { |
| 21 | foreach(i, unused; fun) |
| 22 | { |
| 23 | foreach (j; 0 .. n) |
| 24 | fun[i](); |
| 25 | } |
| 26 | } |