DIP1000: Scoped Pointers (Discussion)

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Thu Aug 11 15:00:06 PDT 2016


On 8/11/2016 4:46 AM, Robert burner Schadek wrote:
> Can I do this:
>
> ```
> struct Foo { int a; }
> auto rcs = RefCountedSlice!Foo(); // assume rcs.length > 0
>
> scope Foo zero = rcs[0];
> zero.a = 1337;
> assert(rcs[0].a == 1337);
> ```

No, because the lifetime of zero exceeds the lifetime of rcs[0].



More information about the Digitalmars-d mailing list