xxxxxxxxxx
import std.stdio;
struct A
{
int x;
auto ref opAssign()(auto ref typeof(this) rhs)
{
writefln("slice_bug.opAssign: begin");
scope(exit) writefln("slice_bug.opAssign: end");
return this;
}
}
void main(string[] args)
{
A[] a = [A(1), A(2), A(3)];
A[] b = [A(2), A(3), A(4)];
writeln("Using slice >>>");
a[] = b[]; // ops.. opAssign is not called
writefln("Using slice <<<\n");
// what I was expecting this to be
writeln("Using for >>>");
for (size_t i = 0; i < a.length; ++i)
{
a[i] = b[i];
}
writeln("Using for <<<");
}