On Thursday, 8 December 2016 at 16:48:07 UTC, H. S. Teoh wrote:
On Thu, Dec 08, 2016 at 04:35:02PM +0000, Jerry via
Digitalmars-d-learn wrote:
The problem is with how isInputRange is defined, requires that
front be copyable.
auto h = r.front; // can get the front of the range
https://github.com/dlang/phobos/blob/v2.072.1/std/range/primitives.d#L168
It doesn't take into consideration that front exists and that
it's a reference to a struct that can't be copied. There was a
discussion a while back to change it but it seems nothing came
of it.
A possible workaround, which is somewhat ugly but should work,
is to have the range return pointers to the elements instead of
the elements themselves. For the most part, this should be
mostly transparent because the . operator automatically
dereferences.
T
It's not something that you should have to workaround,
isInputRange is not defined properly and should be fixed. You end
up complicating your code for no reason other than isInputRange
is poorly defined.