This reminds me, we still need "allBefore" to implement nextPermutation correctly for bidirectional ranges. https://issues.dlang.org/show_bug.cgi?id=12188 I think this would help here also.