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

H. S. Teoh via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Aug 13 14:10:51 PDT 2014


On Wed, Aug 13, 2014 at 08:52:32PM +0000, via Digitalmars-d-learn wrote:
> 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?

Sorry, my bad. It's just a function, not a function pointer. The type of
a function is not the same as the type of its return value (obviously).


T

-- 
Study gravitation, it's a field with a lot of potential.


More information about the Digitalmars-d-learn mailing list