Hi,
When I use the chunks() template with iota(), for instance, with chunks(2), I can access both r.front and r.back. However, in a range of my own type (named iras in the code below), only r.front is working. I think the error given by r.back is not a bug related to chunks, is it?
import std.array, std.algorithm,
std.range,
std.stdio;
void main()
{
auto rng1 = iota!real(24.0, 1321.0, 16.5).take(8);
auto rng2 = iras!real(24.0, 1321.0, 16.5).take(8);
auto noError = rng1.chunks(2)
.map!(r =>
r.back - r.front);
assert(noError.equal([16.5, 16.5, 16.5, 16.5]));
/*
auto error = rng2.chunks(2)
.map!(r =>
r.back - r.front);/*
main.d(18): Error: none of the overloads of template
`std.range.primitives.back` are callable using
argument types `!()(Take!(InclusiveRange))`*/
}
/*
* iras v3
* (inclusiveRange) Source:
* https://forum.dlang.org/post/bnnxentwstkjnxkychro@forum.dlang.org
*/
The same problem occurs here:
struct Range(T)
{
T n = 3;
bool empty;
alias back = front;
auto front() => n.cube - n * 0.5;
auto popFront() => n += 2;
auto backFront() => n -= 2;
}
SDB@79