Linked list as a bidirectional range? I have some questions...

via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Aug 13 13:52:32 PDT 2014


On Wednesday, 13 August 2014 at 20:27:29 UTC, H. S. Teoh via 
Digitalmars-d-learn wrote:
> On Wed, Aug 13, 2014 at 07:58:49PM +0000, Gary Willoughby via 
> Digitalmars-d-learn wrote:
>> On Wednesday, 13 August 2014 at 19:43:20 UTC, H. S. Teoh via
>> Digitalmars-d-learn wrote:
>> >On Wed, Aug 13, 2014 at 07:37:09PM +0000, Gary Willoughby via
>> >Digitalmars-d-learn wrote:
>> >>On Wednesday, 13 August 2014 at 18:58:59 UTC, H. S. Teoh via
>> >>Digitalmars-d-learn wrote:
> [...]
>> >>>You need to put @property on .save.
> [...]
>> >>Gah! Thanks, i need sleep. :)
>> >
>> >No worries, the only reason I could pinpoint this almost 
>> >immediately was
>> >because I got bitten by exactly the same problem before, and 
>> >it took me
>> >*hours* to figure out what was wrong. :-/
>> >
>> >
>> >T
>> 
>> Thinking about it why should that matter when not compiled 
>> using
>> -property?  I'm guessing the template enforces it should be a
>> property?
>
> The problem is that this test is used in isForwardRange:
>
>         static assert (is(typeof(r1.save) == R));
>
> where R is the type of the range. So if .save is not @property, 
> then
> typeof(r1.save) would be a function pointer, rather than the 
> type of the
> function's return value, and so the test will fail.

But wouldn't an & be needed to get a function pointer?


More information about the Digitalmars-d-learn mailing list