Is there anyway to make opApply @nogc?
Gary Willoughby via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Jun 21 05:48:04 PDT 2016
On Monday, 20 June 2016 at 15:27:32 UTC, Adam D. Ruppe wrote:
> On Monday, 20 June 2016 at 15:13:53 UTC, Gary Willoughby wrote:
>> I think the problem is that the delegate which is required by
>> opApply is allocated using the GC.
>
> make the delegate in opApply scope
>
> int opApply(scope int delegate(whatever) dg)
I'm still not sure what this achieves. The description on the
stackoverflow question reads: "And when the compiler sees this on
delegates, it will avoid allocating a closure when taking the
address of a local function. This is essential in opApply loops."
I have no idea what that means. Can anyone shed more light on
this, please?
More information about the Digitalmars-d-learn
mailing list