Trouble creating bidirectional range

Martin Drasar drasar at ics.muni.cz
Sun Sep 29 14:06:35 PDT 2013


On 29.9.2013 22:45, Andrej Mitrovic wrote:
> On Sunday, 29 September 2013 at 20:42:20 UTC, Andrej Mitrovic wrote:
>> On Sunday, 29 September 2013 at 20:37:13 UTC, Martin Drasar wrote:
>>>  static assert(is(typeof(tmp.save) == MyRange!string));
>>
>> You should call it like this:
>>
>> static assert(is(typeof(tmp.save()) == MyRange!string));
> 
> Btw, as for the reason why that used to work, I think it's one of these:
> 
> In earlier versions typeof() might have checked the return type of the
> function, rather than the type of the function itself.
> 
> And purity (and other attributes) are now inferred for functions in
> templated aggregates. (but it may not be related to your code).

Hi Andrej,

this is just a copy&paste of code from std.range documentation. In fact,
the plain isForwardRange fails. It was just expanded to show where it fails.

Btw, I have this in range.d isForwardRange check:
static assert (is(typeof(r1.save) == R));

Does that mean that the std.range code is wrong?

Martin


More information about the Digitalmars-d-learn mailing list