This is a bit nit-picky, but instead of duplicating the bulk of the function, I'd rather see a `static if` inside of the body. This reduces code duplication and size, and reduces the distance between the "comparable" parts of the algorithm (the inner loop):

```D
private void optimisticInsertionSort(alias less, Range)(Range r)
{
    alias binaryFun!less pred;
    if (r.length < 2)
        return;

    immutable maxJ = r.length - 1;
    for (size_t i = r.length - 2; i != size_t.max; --i)
    {
        //Todo: static if (isDynamicArray!Range)
        static if (hasAssignableElements!Range)
        {
            auto temp = r[i];
            for (size_t j = i; j < maxJ && pred(r[j + 1], temp); ++j)
                r[j] = r[j + 1];
            r[j] = temp;
        }
        else
        {
            for (size_t j = i; j < maxJ && pred(r[j + 1], r[j]); ++j)
                swapAt(r, j, j + 1);
        }
    }
}
```

Added bonuses are that it will be easier (later) to implement even more efficient insertion sort for dynamic arrays (a simple three way mem-move). It also avoids diverging styles (different bracing pattern in the old and new code), and avoids duplicating the little odd things that will require later double the fixing: (`binaryFun!less` vs `binaryFun!(less)`) and (`return;` vs `return ;`).

Also, if the elements being sorted have an elaborate `opAssign`, I'm not *sure* assignment is actually better than swapping... I'd settle for:
```D
static if (hasAssignableElements!Range && !hasElaborateAssign!(ElementType!Range))
```
I'm not certain about that one though. It could be better to just leave it as simple for now, and maybe just leave it as a comment (or do nothing)