On Saturday, 19 November 2022 at 15:24:33 UTC, Dukc wrote:
On Saturday, 19 November 2022 at 15:02:54 UTC, Nick Treleaven wrote:
OK, so how do I make `lf` implicitly scope?

Have the `int*` inside it to point to a local, or assign another `scope int*` to it.

Thanks, this works:

```d
@safe:

struct S
{
    int* p;
    int[0] v; // dummy storage
    auto f() return @trusted => p ? p : v.ptr;
}

void main()
{
    int* p;
    {
        S s = S(new int);
        p = s.f; // error
    }
}
```

Reply via email to