passing struct literals by reference (dmd 2.060, Windows)

Jack Applegame japplegame at gmail.com
Sat Nov 24 01:59:24 PST 2012


struct Foo {
   int a;
}
void modify(ref Foo foo) {
   foo.a++;
}
void main() {
   modify(Foo(1));
}

Why compiler doesn't report error? So as struct literal "Foo()" 
isn't a lvalue, it's impossible to pass it by reference. Isn't it?
Just like string or numeric literals.



More information about the Digitalmars-d-learn mailing list