ref lost to opDispatch
Carl Sturtivant
sturtivant at gmail.com
Sat Jul 27 08:09:42 PDT 2013
I ran into the following behavior.
==============================================
void main() {
int x = 100;
B().modify( x, 99);
writeln( x); //still 100
modify( x, 99);
writeln( x); //now is 99
}
void modify( ref int x, int y) { x = y; }
struct B {
void opDispatch(string f, Args...)( Args args) {
mixin( f~"(args);");
}
}
==============================================
When dispatched through a general argument tuple, ref is lost and
the dispatched code therefore does not have the desired side
effect. Is there anything I can do about this?
More information about the Digitalmars-d-learn
mailing list