Is this range behaviour correct?
Andrea Fontana
nospam at example.com
Thu Mar 14 03:45:53 PDT 2013
On Thursday, 14 March 2013 at 10:08:53 UTC, Andrea Fontana wrote:
> I'm trying to implement a db cursor as simple InputRange. I
> can't implement as forward range because using c-api I can't
> clone/save cursor.
>
> I wrote popFront() front() and empty() method and my range
> works fine.
>
> Using on a foreach() it browses all elements inside range until
> range is exausthed.
>
> If i do another foreach() it doesn't restart (empty() is called
> and it returns true, of course).
>
> Is it the correct behaviour of a inputrange or have i missed
> something?
Maybe I got it. I implemented this range as class, so it is
passed as reference to foreach, usually ranges are struct and
passed by value. I guess this is the problem.
Is there a way to make a class based range like a struct one?
More information about the Digitalmars-d-learn
mailing list