Please, can the langauge stop inferring scope and return for @trusted/@system?

Dennis dkorpel at gmail.com
Thu May 19 09:37:32 UTC 2022


On Thursday, 19 May 2022 at 07:13:05 UTC, Dukc wrote:
> There are times when you want to treat data in a scoped struct 
> as non-scoped.

I suggest using a helper function to cast away scope:
```D
auto ref assumeNonScope(T)(auto ref scope T arg)
{
     return *(cast(T*) cast(size_t) &arg);
}

struct MyType
{
     // (...)
     @trusted auto content() scope {return 
assumeNonScope(_content);}
}
```



More information about the Digitalmars-d mailing list