xxxxxxxxxx
import std.stdio;
class SharedArray(T) {
public T[] array;
alias array this; // subtyping
final :
T front();
void popFront();
bool empty();
}
alias Filenames = SharedArray!(string);
struct S {
Filenames fns;
void alloc() {
fns = new Filenames();
}
}
void main(string[] args) {
S s0;
s0.alloc();
s0.fns ~= "abc";
foreach (i; 0..3) {
S* s1 = new S();
*s1 = s0; // copy the value from s0 to *s1
writeln(s0.fns);
}
}