I never used those methods neither in D nor in C++ but I have a gut feeling it is the nextPermutation method in phobos, [...]--stephan
I think you're right, it probably is the nextPermutation() function:
<imports> long[] z = [1,1,2,2,3,3,4,4,5,5,6,6,0,0]; void main() { do { if (z[0] == 0) break; } while (nextPermutation(z)); }...takes approx. 31 seconds, compiled with "-m64 -O -release -inline".