DIP1000: Scoped Pointers

Walter Bright via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Tue Aug 16 13:30:03 PDT 2016


On 8/16/2016 11:25 AM, Meta wrote:
> What about this?
>
> struct Rnd
> {
>     int* state;
> }
>
> void test()
> {
>     scope rnd = new Rnd();
>     Rnd rnd2 = *rnd;
>
>     saveGlobalState(rnd2);
> }

'state' is set to null by 'new Rnd()', and so no pointers escape.


More information about the Digitalmars-d-announce mailing list