R.filter!(..).sort!(..)

Arjan arjan at ask.me.to
Tue Nov 28 13:10:15 UTC 2017


When applying a sort!() on a filtered range I get this compiler 
error:

Error: template std.algorithm.sorting.sort cannot deduce function 
from argument types !((a, b) => a.name < 
b.name)(FilterResult!(__lambda3, RangeT!(Array!(IssueType)))), 
candidates are:
C:\D\dmd2\windows\bin\..\..\src\phobos\std\algorithm\sorting.d(1851,1):        std.algorithm.sorting.sort(alias less = "a < b", SwapStrategy ss = SwapStrategy.unstable, Range)(Range r) if ((ss == SwapStrategy.unstable && (hasSwappableElements!Range || hasAssignableElements!Range) || ss != SwapStrategy.unstable && hasAssignableElements!Range) && isRandomAccessRange!Range && hasSlicing!Range && hasLength!Range)

But it seems the problem is with the filter!() result not being a 
isRandomAccessRange!Range because:
R.filter!(..).array.sort!(..) just works (by copying the filter 
results in a array).

Iaw is the compiler error msg wrong? Or i'm I wrong?





More information about the Digitalmars-d-learn mailing list