On 03/10/18 12:48, Corel wrote:
The fact that in D the structures to date are not moved, is known for
years ... take advantage of this fact, and move on.
I have no idea where you got this fact:
import std.stdio;
struct MoveTest {
static uint counter=1;
uint id;
@disable this(this);
@disable this(MoveTest);
this(uint dummy) {
id = counter++;
writefln("Constructed %s id %s", &this, id);
}
~this() {
writefln("Id %s destroyed at %s", id, &this);
}
}
MoveTest func1() {
return MoveTest(3);
}
void func2(MoveTest m) {
}
int main() {
func2(func1());
return 0;
}
$ rdmd movetest.d
Constructed 7FFDC7A663E0 id 1
Id 1 destroyed at 7FFDC7A66400
Our instance was constructed at one address, but destroyed at another.
In other words, it was moved.
Can we, please, put that myth to rest?
Shachar