auto a = [1,2,3,4,5];
auto b = a[0..3];
assumeSafeAppend(b);
b ~= 0;
writeln(a);

prints [1, 2, 3, 0, 5], so b is not reallocated in this case.

Just to clarify: this is not guaranteed to print [1, 2, 3, 0, 5], it only does if there is still enough memory in a block allocated to b and it doesn't have
to be reallocated.

Reply via email to