Why is the struct instance being copied here?
d coder
dlang.coder at gmail.com
Fri Mar 11 01:50:38 PST 2011
Greetings
Please look at the code down here. When compiled and run, I get the message
"Call to postblit" printed. I think it is because of the foreach block,
because the variable "i" is not declared as ref there. Is there a way to
make it a ref?
Regards
- Puneet
import std.stdio;
struct Foo {
this(this) {
writeln("Call to postblit");
}
}
class Bar {
Foo foo;
this() {
foreach(i, f; this.tupleof) {
// do nothing
}
}
}
void main()
{
Bar bar = new Bar();
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20110311/48c92a10/attachment.html>
More information about the Digitalmars-d-learn
mailing list