I have a DList of structs, DataPoint, ordered by a struct field,
time. I'm trying to insert a new entry preserving order, so I'm
trying to use `until` to find the insertion point and
`insertBefore` with the result.
struct DataPoint {
immutable ulong time;
ulong value;
}
void main() {
DList!DataPoint dataPoints;
void incrementAt(ulong time) {
auto dataPoint = until!(dp => dp.time >=
time)(dataPoints);
if (dataPoint.time == time) {
++dataPoint.value;
} else {
dataPoints.insertBefore(dataPoint, DataPoint(time,
1));
}
}
}
But I'm getting:
/dlang/dmd/linux/bin64/../../src/phobos/std/algorithm/searching.d(4898): Error:
template instance `onlineapp.main.incrementAt.Until!(__lambda2,
DList!(DataPoint), void)` does not match template declaration Until(alias pred,
Range, Sentinel) if (isInputRange!Range)
onlineapp.d(14): Error: template instance
`onlineapp.main.incrementAt.until!((dp) => dp.time >= time,
DList!(DataPoint))` error instantiating