Is there anyway to make opApply @nogc?

Mathias Lang via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Jun 20 07:34:33 PDT 2016


On Monday, 20 June 2016 at 14:08:58 UTC, Gary Willoughby wrote:
> Is there any way to make opApply @nogc? or provide the same 
> foreach functionality without implementing a range interface?
>
> I want to iterate over a piece of memory using a pointer. I 
> thought about using opSlice but that doesn't provide 
> information for an index in a foreach loop.
>
> auto opSlice()
> {
>     return this._pointer[0 .. size];
> }
>
> Anyone got any ideas?

Can't `opApply` with `auto` return type works since it infers 
attributes ?


More information about the Digitalmars-d-learn mailing list