How to implement this?

Elvis Zhou elvis.x.zhou at gmail.com
Fri Apr 8 04:31:45 UTC 2022


struct A {}
struct B { A a; }
struct C { A a; }

A*[] structs;

B b;
init(&b);
structs ~= cast(A*)&b;
//Error: copying `cast(A*)& b` into allocated memory escapes a 
reference to local variable `b`

C c;
init(&c);
structs ~= cast(A*)&c;
//Error: copying `cast(A*)& c` into allocated memory escapes a 
reference to local variable `c`

batch_process(structs);


More information about the Digitalmars-d-learn mailing list