C++ vs D - Algorithm Optimization/Conversion (Using vectors/arrays)
How about: using res.length = 64; and then in your loop replace 

res ~= cast(int)log2(bitboard &amp; ~(bitboard-1));


by:

res[n] = cast(int)log2(bitboard &amp; ~(bitboard-1));


But to be honest this type of code will be completely dominated by allocations, which is not entirely interesting as a language benchmark. Try to reuse the same array instead.

And there is much faster ways of locating bits (see core.bitop).

tl;dr you're optimizing a slow program.