How to implement this?
Stanislav Blinov
stanislav.blinov at gmail.com
Fri Apr 8 09:08:07 UTC 2022
On Friday, 8 April 2022 at 05:53:03 UTC, Elvis Zhou wrote:
> assumeNoEscapeOrWhatever!DynamicArray structs;
> structs ~= cast(A*)&b;
>
> is it possible?
That's what `@trusted` is for. And that's also why it should be
used with care, and on the smallest code possible.
```d
struct A {}
struct B { A a; }
struct C { A a; }
void main()
{
A*[] structs;
B b;
C c;
() @trusted {
structs ~= cast(A*)&b;
structs ~= cast(A*)&c;
} ();
}
```
More information about the Digitalmars-d-learn
mailing list