On Monday, 24 November 2014 at 12:20:40 UTC, bearophile wrote:
Peter Alexander:
Should be able to do:
assert(result.save.all!(x => x < 10));
But iota's save isn't const, so you can't (that's a bug).
Mine was just an example of the general problem, another
example:
import std.range, std.algorithm;
auto foo()
out(result) {
assert(result.all!(b => b.length == 2));
} body {
auto a = new int[10];
return a.chunks(2);
}
void main() {}
Chunks.save should also be const, so result.save.{...} should
work.
It becomes a real problem with input ranges, because you can't
save them. That makes sense though, as there is no way to consume
the result in a post-condition check that doesn't consume it.
That's just a fact of life and a limitation of trying to verify
mutable data.