[Issue 14544] New: isForwardRange failed to recognise valid forward range
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Mon May 4 03:25:28 PDT 2015
https://issues.dlang.org/show_bug.cgi?id=14544
Issue ID: 14544
Summary: isForwardRange failed to recognise valid forward range
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P1
Component: Phobos
Assignee: nobody at puremagic.com
Reporter: ketmar at ketmar.no-ip.org
this code fails static assertion:
struct Input {
auto opSlice (size_t start, size_t end) {
static struct InputSlice {
@property bool empty () { return false; }
@property char front () { return 0; }
void popFront () {}
InputSlice save () { return this; }
}
import std.range.primitives;
static assert(isForwardRange!InputSlice);
return InputSlice();
}
}
fixing code like this tames `isForwardRange`:
template isForwardRange(R)
{
enum bool isForwardRange = isInputRange!R && is(typeof(
(inout int = 0)
{
R r1 = R.init;
//old: static assert (is(typeof(r1.save) == R));
auto s1 = r1.save;
static assert (is(typeof(s1) == R));
}));
}
i wonder if some other checking primitives has similar bug.
--
More information about the Digitalmars-d-bugs
mailing list